Changeset d8d63a2 for protocols/jabber
- Timestamp:
- 2006-12-05T20:40:17Z (18 years ago)
- Branches:
- master
- Children:
- 7740c4c
- Parents:
- f4aa393 (diff), 55078f5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
rf4aa393 rd8d63a2 561 561 static void gjab_start(gjconn gjc) 562 562 { 563 struct aim_user *user;563 account_t *acc; 564 564 int port = -1, ssl = 0; 565 char *server = NULL , *s;565 char *server = NULL; 566 566 567 567 if (!gjc || gjc->state != JCONN_STATE_OFF) 568 568 return; 569 569 570 user = GJ_GC(gjc)->user; 571 if (*user->proto_opt[0]) { 572 /* If there's a dot, assume there's a hostname in the beginning */ 573 if (strchr(user->proto_opt[0], '.')) { 574 server = g_strdup(user->proto_opt[0]); 575 if ((s = strchr(server, ':'))) 576 *s = 0; 577 } 578 579 /* After the hostname, there can be a port number */ 580 s = strchr(user->proto_opt[0], ':'); 581 if (s && isdigit(s[1])) 582 sscanf(s + 1, "%d", &port); 583 584 /* And if there's the string ssl, the user wants an SSL-connection */ 585 if (strstr(user->proto_opt[0], ":ssl") || g_strcasecmp(user->proto_opt[0], "ssl") == 0) 586 ssl = 1; 587 } 588 589 if (port == -1 && !ssl) 590 port = DEFAULT_PORT; 591 else if (port == -1 && ssl) 592 port = DEFAULT_PORT_SSL; 593 else if (port < JABBER_PORT_MIN || port > JABBER_PORT_MAX) { 570 acc = GJ_GC(gjc)->acc; 571 server = acc->server; 572 port = set_getint(&acc->set, "port"); 573 ssl = set_getbool(&acc->set, "ssl"); 574 575 if (port < JABBER_PORT_MIN || port > JABBER_PORT_MAX) { 594 576 serv_got_crap(GJ_GC(gjc), "For security reasons, the Jabber port number must be in the %d-%d range.", JABBER_PORT_MIN, JABBER_PORT_MAX); 595 577 STATE_EVT(JCONN_STATE_OFF) … … 614 596 } 615 597 616 g_free(server); 617 618 if (!user->gc || (gjc->fd < 0)) { 598 if (!acc->gc || (gjc->fd < 0)) { 619 599 STATE_EVT(JCONN_STATE_OFF) 620 600 return; … … 1516 1496 } 1517 1497 1518 static void jabber_login(struct aim_user *user) 1519 { 1520 struct gaim_connection *gc = new_gaim_conn(user); 1521 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); 1522 char *loginname = create_valid_jid(user->username, DEFAULT_SERVER, "BitlBee"); 1523 1498 static void jabber_acc_init(account_t *acc) 1499 { 1500 set_t *s; 1501 1502 s = set_add( &acc->set, "port", "5222", set_eval_int, acc ); 1503 s->flags |= ACC_SET_OFFLINE_ONLY; 1504 1505 s = set_add( &acc->set, "resource", "BitlBee", NULL, acc ); 1506 s->flags |= ACC_SET_OFFLINE_ONLY; 1507 1508 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); 1509 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 1510 1511 s = set_add( &acc->set, "ssl", "false", set_eval_bool, acc ); 1512 s->flags |= ACC_SET_OFFLINE_ONLY; 1513 } 1514 1515 static void jabber_login(account_t *acc) 1516 { 1517 struct gaim_connection *gc; 1518 struct jabber_data *jd; 1519 char *resource, *loginname; 1520 1521 /* Time to move some data/things from the old syntax to the new one: */ 1522 if (acc->server) { 1523 char *s, *tmp_server; 1524 int port; 1525 1526 if (g_strcasecmp(acc->server, "ssl") == 0) { 1527 set_setstr(&acc->set, "server", ""); 1528 set_setint(&acc->set, "port", DEFAULT_PORT_SSL); 1529 set_setstr(&acc->set, "ssl", "true"); 1530 1531 g_free(acc->server); 1532 acc->server = NULL; 1533 } else if ((s = strchr(acc->server, ':'))) { 1534 if (strstr(acc->server, ":ssl")) { 1535 set_setint(&acc->set, "port", DEFAULT_PORT_SSL); 1536 set_setstr(&acc->set, "ssl", "true"); 1537 } 1538 if (isdigit(s[1])) { 1539 if (sscanf(s + 1, "%d", &port) == 1) 1540 set_setint(&acc->set, "port", port); 1541 } 1542 tmp_server = g_strndup(acc->server, s - acc->server); 1543 set_setstr(&acc->set, "server", tmp_server); 1544 g_free(tmp_server); 1545 } 1546 } 1547 1548 gc = new_gaim_conn(acc); 1549 jd = gc->proto_data = g_new0(struct jabber_data, 1); 1550 1551 if( strchr( acc->user, '@' ) == NULL ) 1552 { 1553 hide_login_progress( gc, "Invalid account name" ); 1554 signoff( gc ); 1555 return; 1556 } 1557 1558 resource = set_getstr(&acc->set, "resource"); 1559 loginname = create_valid_jid(acc->user, DEFAULT_SERVER, resource); 1560 1524 1561 jd->hash = g_hash_table_new(g_str_hash, g_str_equal); 1525 1562 jd->chats = NULL; /* we have no chats yet */ … … 1527 1564 set_login_progress(gc, 1, _("Connecting")); 1528 1565 1529 if (!(jd->gjc = gjab_new(loginname, user->password, gc))) {1566 if (!(jd->gjc = gjab_new(loginname, acc->pass, gc))) { 1530 1567 g_free(loginname); 1531 1568 hide_login_progress(gc, _("Unable to connect")); … … 2337 2374 ret->name = "jabber"; 2338 2375 ret->away_states = jabber_away_states; 2376 ret->acc_init = jabber_acc_init; 2339 2377 ret->login = jabber_login; 2340 2378 ret->close = jabber_close; … … 2349 2387 ret->alias_buddy = jabber_roster_update; 2350 2388 ret->group_buddy = jabber_group_change; 2351 ret-> cmp_buddynames= g_strcasecmp;2389 ret->handle_cmp = g_strcasecmp; 2352 2390 2353 2391 register_protocol (ret);
Note: See TracChangeset
for help on using the changeset viewer.