comparison libpurple/protocols/silc/ops.c @ 32724:44fc11beefab

propagate from branch 'im.pidgin.pidgin.2.x.y' (head b9c74c3f836a7a1a64710fc8244c9ec1f3f21b97) to branch 'im.pidgin.pidgin' (head fcd1b3766ec3998ed589bfddde2bffefd9d99e65)
author Mark Doliner <mark@kingant.net>
date Wed, 05 Oct 2011 07:33:20 +0000
parents d9d33a4b5632 3899615cef8a
children
comparison
equal deleted inserted replaced
32723:952120a8ee02 32724:44fc11beefab
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;
262 SilcChannelPrivateKey key, SilcMessageFlags flags, 262 SilcChannelPrivateKey key, SilcMessageFlags flags,
263 const unsigned char *message, 263 const unsigned char *message,
264 SilcUInt32 message_len) 264 SilcUInt32 message_len)
265 { 265 {
266 PurpleConnection *gc = client->application; 266 PurpleConnection *gc = client->application;
267 SilcPurple sg = gc->proto_data; 267 SilcPurple sg = purple_connection_get_protocol_data(gc);
268 PurpleConversation *convo = NULL; 268 PurpleConversation *convo = NULL;
269 char *msg, *tmp; 269 char *msg, *tmp;
270 270
271 if (!message) 271 if (!message)
272 return; 272 return;
352 SilcClientEntry sender, SilcMessagePayload payload, 352 SilcClientEntry sender, SilcMessagePayload payload,
353 SilcMessageFlags flags, const unsigned char *message, 353 SilcMessageFlags flags, const unsigned char *message,
354 SilcUInt32 message_len) 354 SilcUInt32 message_len)
355 { 355 {
356 PurpleConnection *gc = client->application; 356 PurpleConnection *gc = client->application;
357 SilcPurple sg = gc->proto_data; 357 SilcPurple sg = purple_connection_get_protocol_data(gc);
358 PurpleConversation *convo = NULL; 358 PurpleConversation *convo = NULL;
359 char *msg, *tmp; 359 char *msg, *tmp;
360 360
361 if (!message) 361 if (!message)
362 return; 362 return;
436 silc_notify(SilcClient client, SilcClientConnection conn, 436 silc_notify(SilcClient client, SilcClientConnection conn,
437 SilcNotifyType type, ...) 437 SilcNotifyType type, ...)
438 { 438 {
439 va_list va; 439 va_list va;
440 PurpleConnection *gc = client->application; 440 PurpleConnection *gc = client->application;
441 SilcPurple sg = gc->proto_data; 441 SilcPurple sg = purple_connection_get_protocol_data(gc);
442 PurpleAccount *account = purple_connection_get_account(gc); 442 PurpleAccount *account = purple_connection_get_account(gc);
443 PurpleConversation *convo; 443 PurpleConversation *convo;
444 SilcClientEntry client_entry, client_entry2; 444 SilcClientEntry client_entry, client_entry2;
445 SilcChannelEntry channel; 445 SilcChannelEntry channel;
446 SilcServerEntry server_entry; 446 SilcServerEntry server_entry;
946 silc_command(SilcClient client, SilcClientConnection conn, 946 silc_command(SilcClient client, SilcClientConnection conn,
947 SilcBool success, SilcCommand command, SilcStatus status, 947 SilcBool success, SilcCommand command, SilcStatus status,
948 SilcUInt32 argc, unsigned char **argv) 948 SilcUInt32 argc, unsigned char **argv)
949 { 949 {
950 PurpleConnection *gc = client->application; 950 PurpleConnection *gc = client->application;
951 SilcPurple sg = gc->proto_data; 951 SilcPurple sg = purple_connection_get_protocol_data(gc);
952 952
953 switch (command) { 953 switch (command) {
954 954
955 case SILC_COMMAND_CMODE: 955 case SILC_COMMAND_CMODE:
956 if (argc == 3 && !strcmp((char *)argv[2], "+C")) 956 if (argc == 3 && !strcmp((char *)argv[2], "+C"))
1083 silc_command_reply(SilcClient client, SilcClientConnection conn, 1083 silc_command_reply(SilcClient client, SilcClientConnection conn,
1084 SilcCommand command, SilcStatus status, 1084 SilcCommand command, SilcStatus status,
1085 SilcStatus error, va_list ap) 1085 SilcStatus error, va_list ap)
1086 { 1086 {
1087 PurpleConnection *gc = client->application; 1087 PurpleConnection *gc = client->application;
1088 SilcPurple sg = gc->proto_data; 1088 SilcPurple sg = purple_connection_get_protocol_data(gc);
1089 PurpleConversation *convo; 1089 PurpleConversation *convo;
1090 1090
1091 switch (command) { 1091 switch (command) {
1092 case SILC_COMMAND_JOIN: 1092 case SILC_COMMAND_JOIN:
1093 { 1093 {
1167 case SILC_COMMAND_WHOIS: 1167 case SILC_COMMAND_WHOIS:
1168 { 1168 {
1169 SilcUInt32 idle, *user_modes; 1169 SilcUInt32 idle, *user_modes;
1170 SilcDList channels; 1170 SilcDList channels;
1171 SilcClientEntry client_entry; 1171 SilcClientEntry client_entry;
1172 char tmp[1024], *tmp2; 1172 char tmp[1024];
1173 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; 1173 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr;
1174 PurpleNotifyUserInfo *user_info; 1174 PurpleNotifyUserInfo *user_info;
1175 1175
1176 if (status != SILC_STATUS_OK) { 1176 if (status != SILC_STATUS_OK) {
1177 purple_notify_error(gc, _("User Information"), 1177 purple_notify_error(gc, _("User Information"),
1189 idle = va_arg(ap, SilcUInt32); 1189 idle = va_arg(ap, SilcUInt32);
1190 (void)va_arg(ap, unsigned char *); 1190 (void)va_arg(ap, unsigned char *);
1191 user_modes = va_arg(ap, SilcUInt32 *); 1191 user_modes = va_arg(ap, SilcUInt32 *);
1192 1192
1193 user_info = purple_notify_user_info_new(); 1193 user_info = purple_notify_user_info_new();
1194 tmp2 = g_markup_escape_text(client_entry->nickname, -1); 1194 purple_notify_user_info_add_pair_plaintext(user_info, _("Nickname"), client_entry->nickname);
1195 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp2);
1196 g_free(tmp2);
1197 if (client_entry->realname) { 1195 if (client_entry->realname) {
1198 tmp2 = g_markup_escape_text(client_entry->realname, -1); 1196 purple_notify_user_info_add_pair_plaintext(user_info, _("Real Name"), client_entry->realname);
1199 purple_notify_user_info_add_pair(user_info, _("Real Name"), tmp2); 1197 }
1198 if (*client_entry->hostname) {
1199 gchar *tmp2;
1200 tmp2 = g_strdup_printf("%s@%s", client_entry->username, client_entry->hostname);
1201 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), tmp2);
1200 g_free(tmp2); 1202 g_free(tmp2);
1201 }
1202 tmp2 = g_markup_escape_text(client_entry->username, -1);
1203 if (*client_entry->hostname) {
1204 gchar *tmp3;
1205 tmp3 = g_strdup_printf("%s@%s", tmp2, client_entry->hostname);
1206 purple_notify_user_info_add_pair(user_info, _("Username"), tmp3);
1207 g_free(tmp3);
1208 } else 1203 } else
1209 purple_notify_user_info_add_pair(user_info, _("Username"), tmp2); 1204 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), client_entry->username);
1210 g_free(tmp2);
1211 1205
1212 if (client_entry->mode) { 1206 if (client_entry->mode) {
1213 memset(tmp, 0, sizeof(tmp)); 1207 memset(tmp, 0, sizeof(tmp));
1214 silcpurple_get_umode_string(client_entry->mode, 1208 silcpurple_get_umode_string(client_entry->mode,
1215 tmp, sizeof(tmp) - strlen(tmp)); 1209 tmp, sizeof(tmp) - strlen(tmp));
1216 purple_notify_user_info_add_pair(user_info, _("User Modes"), tmp); 1210 /* TODO: Check whether it's correct to call add_pair_html,
1211 or if we should be using add_pair_plaintext */
1212 purple_notify_user_info_add_pair_html(user_info, _("User Modes"), tmp);
1217 } 1213 }
1218 1214
1219 silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr); 1215 silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr);
1220 if (moodstr) { 1216 if (moodstr) {
1221 purple_notify_user_info_add_pair(user_info, _("Mood"), moodstr); 1217 /* TODO: Check whether it's correct to call add_pair_html,
1218 or if we should be using add_pair_plaintext */
1219 purple_notify_user_info_add_pair_html(user_info, _("Mood"), moodstr);
1222 g_free(moodstr); 1220 g_free(moodstr);
1223 } 1221 }
1224 1222
1225 if (statusstr) { 1223 if (statusstr) {
1226 tmp2 = g_markup_escape_text(statusstr, -1); 1224 purple_notify_user_info_add_pair_plaintext(user_info, _("Status Text"), statusstr);
1227 purple_notify_user_info_add_pair(user_info, _("Status Text"), tmp2);
1228 g_free(statusstr); 1225 g_free(statusstr);
1229 g_free(tmp2);
1230 } 1226 }
1231 1227
1232 if (contactstr) { 1228 if (contactstr) {
1233 purple_notify_user_info_add_pair(user_info, _("Preferred Contact"), contactstr); 1229 /* TODO: Check whether it's correct to call add_pair_html,
1230 or if we should be using add_pair_plaintext */
1231 purple_notify_user_info_add_pair_html(user_info, _("Preferred Contact"), contactstr);
1234 g_free(contactstr); 1232 g_free(contactstr);
1235 } 1233 }
1236 1234
1237 if (langstr) { 1235 if (langstr) {
1238 purple_notify_user_info_add_pair(user_info, _("Preferred Language"), langstr); 1236 /* TODO: Check whether it's correct to call add_pair_html,
1237 or if we should be using add_pair_plaintext */
1238 purple_notify_user_info_add_pair_html(user_info, _("Preferred Language"), langstr);
1239 g_free(langstr); 1239 g_free(langstr);
1240 } 1240 }
1241 1241
1242 if (devicestr) { 1242 if (devicestr) {
1243 purple_notify_user_info_add_pair(user_info, _("Device"), devicestr); 1243 /* TODO: Check whether it's correct to call add_pair_html,
1244 or if we should be using add_pair_plaintext */
1245 purple_notify_user_info_add_pair_html(user_info, _("Device"), devicestr);
1244 g_free(devicestr); 1246 g_free(devicestr);
1245 } 1247 }
1246 1248
1247 if (tzstr) { 1249 if (tzstr) {
1248 purple_notify_user_info_add_pair(user_info, _("Timezone"), tzstr); 1250 /* TODO: Check whether it's correct to call add_pair_html,
1251 or if we should be using add_pair_plaintext */
1252 purple_notify_user_info_add_pair_html(user_info, _("Timezone"), tzstr);
1249 g_free(tzstr); 1253 g_free(tzstr);
1250 } 1254 }
1251 1255
1252 if (geostr) { 1256 if (geostr) {
1253 purple_notify_user_info_add_pair(user_info, _("Geolocation"), geostr); 1257 /* TODO: Check whether it's correct to call add_pair_html,
1258 or if we should be using add_pair_plaintext */
1259 purple_notify_user_info_add_pair_html(user_info, _("Geolocation"), geostr);
1254 g_free(geostr); 1260 g_free(geostr);
1255 } 1261 }
1256 1262
1257 if (*client_entry->server) 1263 if (*client_entry->server) {
1258 purple_notify_user_info_add_pair(user_info, _("Server"), client_entry->server); 1264 /* TODO: Check whether it's correct to call add_pair_html,
1265 or if we should be using add_pair_plaintext */
1266 purple_notify_user_info_add_pair_html(user_info, _("Server"), client_entry->server);
1267 }
1259 1268
1260 if (channels && user_modes) { 1269 if (channels && user_modes) {
1261 SilcChannelPayload entry; 1270 SilcChannelPayload entry;
1262 int i = 0; 1271 int i = 0;
1263 1272
1271 silc_strncat(tmp, sizeof(tmp) - 1, m, strlen(m)); 1280 silc_strncat(tmp, sizeof(tmp) - 1, m, strlen(m));
1272 silc_strncat(tmp, sizeof(tmp) - 1, name, name_len); 1281 silc_strncat(tmp, sizeof(tmp) - 1, name, name_len);
1273 silc_strncat(tmp, sizeof(tmp) - 1, " ", 1); 1282 silc_strncat(tmp, sizeof(tmp) - 1, " ", 1);
1274 silc_free(m); 1283 silc_free(m);
1275 } 1284 }
1276 tmp2 = g_markup_escape_text(tmp, -1); 1285 purple_notify_user_info_add_pair_plaintext(user_info, _("Currently on"), tmp);
1277 purple_notify_user_info_add_pair(user_info, _("Currently on"), tmp2);
1278 g_free(tmp2);
1279 } 1286 }
1280 1287
1281 if (client_entry->public_key) { 1288 if (client_entry->public_key) {
1282 char *fingerprint, *babbleprint; 1289 char *fingerprint, *babbleprint;
1283 unsigned char *pk; 1290 unsigned char *pk;
1284 SilcUInt32 pk_len; 1291 SilcUInt32 pk_len;
1285 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len); 1292 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);
1286 if (pk) { 1293 if (pk) {
1287 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); 1294 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
1288 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); 1295 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
1289 purple_notify_user_info_add_pair(user_info, _("Public Key Fingerprint"), fingerprint); 1296 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Fingerprint"), fingerprint);
1290 purple_notify_user_info_add_pair(user_info, _("Public Key Babbleprint"), babbleprint); 1297 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Babbleprint"), babbleprint);
1291 silc_free(fingerprint); 1298 silc_free(fingerprint);
1292 silc_free(babbleprint); 1299 silc_free(babbleprint);
1293 silc_free(pk); 1300 silc_free(pk);
1294 } 1301 }
1295 } 1302 }
1309 break; 1316 break;
1310 1317
1311 case SILC_COMMAND_WHOWAS: 1318 case SILC_COMMAND_WHOWAS:
1312 { 1319 {
1313 SilcClientEntry client_entry; 1320 SilcClientEntry client_entry;
1314 char *nickname, *realname, *username, *tmp; 1321 char *nickname, *realname, *username;
1315 PurpleNotifyUserInfo *user_info; 1322 PurpleNotifyUserInfo *user_info;
1316 1323
1317 if (status != SILC_STATUS_OK) { 1324 if (status != SILC_STATUS_OK) {
1318 purple_notify_error(gc, _("User Information"), 1325 purple_notify_error(gc, _("User Information"),
1319 _("Cannot get user information"), 1326 _("Cannot get user information"),
1327 realname = va_arg(ap, char *); 1334 realname = va_arg(ap, char *);
1328 if (!nickname) 1335 if (!nickname)
1329 break; 1336 break;
1330 1337
1331 user_info = purple_notify_user_info_new(); 1338 user_info = purple_notify_user_info_new();
1332 tmp = g_markup_escape_text(nickname, -1); 1339 purple_notify_user_info_add_pair_plaintext(user_info, _("Nickname"), nickname);
1333 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); 1340 if (realname)
1334 g_free(tmp); 1341 purple_notify_user_info_add_pair_plaintext(user_info, _("Real Name"), realname);
1335 if (realname) {
1336 tmp = g_markup_escape_text(realname, -1);
1337 purple_notify_user_info_add_pair(user_info, _("Real Name"), tmp);
1338 g_free(tmp);
1339 }
1340 if (username) { 1342 if (username) {
1341 tmp = g_markup_escape_text(username, -1);
1342 if (client_entry && *client_entry->hostname) { 1343 if (client_entry && *client_entry->hostname) {
1343 gchar *tmp3; 1344 gchar *tmp;
1344 tmp3 = g_strdup_printf("%s@%s", tmp, client_entry->hostname); 1345 tmp = g_strdup_printf("%s@%s", username, client_entry->hostname);
1345 purple_notify_user_info_add_pair(user_info, _("Username"), tmp3); 1346 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), tmp);
1346 g_free(tmp3); 1347 g_free(tmp);
1347 } else 1348 } else
1348 purple_notify_user_info_add_pair(user_info, _("Username"), tmp); 1349 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), username);
1349 g_free(tmp); 1350 }
1350 } 1351 if (client_entry && *client_entry->server) {
1351 if (client_entry && *client_entry->server) 1352 /* TODO: Check whether it's correct to call add_pair_html,
1352 purple_notify_user_info_add_pair(user_info, _("Server"), client_entry->server); 1353 or if we should be using add_pair_plaintext */
1354 purple_notify_user_info_add_pair_html(user_info, _("Server"), client_entry->server);
1355 }
1353 1356
1354 1357
1355 if (client_entry && client_entry->public_key) { 1358 if (client_entry && client_entry->public_key) {
1356 char *fingerprint, *babbleprint; 1359 char *fingerprint, *babbleprint;
1357 unsigned char *pk; 1360 unsigned char *pk;
1358 SilcUInt32 pk_len; 1361 SilcUInt32 pk_len;
1359 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len); 1362 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);
1360 if (pk) { 1363 if (pk) {
1361 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); 1364 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
1362 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); 1365 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
1363 purple_notify_user_info_add_pair(user_info, _("Public Key Fingerprint"), fingerprint); 1366 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Fingerprint"), fingerprint);
1364 purple_notify_user_info_add_pair(user_info, _("Public Key Babbleprint"), babbleprint); 1367 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Babbleprint"), babbleprint);
1365 silc_free(fingerprint); 1368 silc_free(fingerprint);
1366 silc_free(babbleprint); 1369 silc_free(babbleprint);
1367 silc_free(pk); 1370 silc_free(pk);
1368 } 1371 }
1369 } 1372 }
1726 char *hostname, SilcUInt16 port, 1729 char *hostname, SilcUInt16 port,
1727 SilcAuthMethod auth_method, 1730 SilcAuthMethod auth_method,
1728 SilcGetAuthMeth completion, void *context) 1731 SilcGetAuthMeth completion, void *context)
1729 { 1732 {
1730 PurpleConnection *gc = client->application; 1733 PurpleConnection *gc = client->application;
1731 SilcPurple sg = gc->proto_data; 1734 SilcPurple sg = purple_connection_get_protocol_data(gc);
1732 SilcPurpleAskPassphrase internal; 1735 SilcPurpleAskPassphrase internal;
1733 const char *password; 1736 const char *password;
1734 1737
1735 /* Progress */ 1738 /* Progress */
1736 if (sg->resuming) 1739 if (sg->resuming)
1777 SilcConnectionType conn_type, 1780 SilcConnectionType conn_type,
1778 SilcPublicKey public_key, 1781 SilcPublicKey public_key,
1779 SilcVerifyPublicKey completion, void *context) 1782 SilcVerifyPublicKey completion, void *context)
1780 { 1783 {
1781 PurpleConnection *gc = client->application; 1784 PurpleConnection *gc = client->application;
1782 SilcPurple sg = gc->proto_data; 1785 SilcPurple sg = purple_connection_get_protocol_data(gc);
1783 1786
1784 if (!sg->conn && (conn_type == SILC_CONN_SERVER || 1787 if (!sg->conn && (conn_type == SILC_CONN_SERVER ||
1785 conn_type == SILC_CONN_ROUTER)) { 1788 conn_type == SILC_CONN_ROUTER)) {
1786 /* Progress */ 1789 /* Progress */
1787 if (sg->resuming) 1790 if (sg->resuming)