- Timestamp:
- 2006-07-02T09:49:31Z (18 years ago)
- Branches:
- master
- Children:
- 911f2eb
- Parents:
- fef6116
- Location:
- protocols
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
rfef6116 r96863f6 563 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) … … 569 569 570 570 acc = GJ_GC(gjc)->acc; 571 if (acc->server) { 572 /* If there's a dot, assume there's a hostname in the beginning */ 573 if (strchr(acc->server, '.')) { 574 server = g_strdup(acc->server); 575 if ((s = strchr(server, ':'))) 576 *s = 0; 577 } 578 579 /* After the hostname, there can be a port number */ 580 s = strchr(acc->server, ':'); 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(acc->server, ":ssl") || g_strcasecmp(acc->server, "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) { 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) … … 613 595 gjc->fd = proxy_connect(server, port, gjab_connected, GJ_GC(gjc)); 614 596 } 615 616 g_free(server);617 597 618 598 if (!acc->gc || (gjc->fd < 0)) { … … 1516 1496 } 1517 1497 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 1518 1515 static void jabber_login(account_t *acc) 1519 1516 { 1520 struct gaim_connection *gc = new_gaim_conn(acc); 1521 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); 1522 char *loginname = create_valid_jid(acc->user, DEFAULT_SERVER, "BitlBee"); 1523 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 resource = set_getstr(&acc->set, "resource"); 1552 loginname = create_valid_jid(acc->user, DEFAULT_SERVER, resource); 1553 1524 1554 jd->hash = g_hash_table_new(g_str_hash, g_str_equal); 1525 1555 jd->chats = NULL; /* we have no chats yet */ … … 2337 2367 ret->name = "jabber"; 2338 2368 ret->away_states = jabber_away_states; 2369 ret->acc_init = jabber_acc_init; 2339 2370 ret->login = jabber_login; 2340 2371 ret->close = jabber_close; -
protocols/nogaim.h
rfef6116 r96863f6 129 129 const char *name; 130 130 131 void (* acc_init) (account_t *); 131 132 void (* login) (account_t *); 132 133 void (* keepalive) (struct gaim_connection *); -
protocols/oscar/oscar.c
rfef6116 r96863f6 356 356 } 357 357 358 static void oscar_acc_init(account_t *acc) 359 { 360 set_t *s; 361 362 s = set_add( &acc->set, "server", NULL, set_eval_account, acc ); 363 s->flags |= ACC_SET_NOSAVE | ACC_SET_OFFLINE_ONLY; 364 } 365 358 366 static void oscar_login(account_t *acc) { 359 367 aim_session_t *sess; … … 386 394 if (conn == NULL) { 387 395 hide_login_progress(gc, _("Unable to login to AIM")); 396 signoff(gc); 397 return; 398 } 399 400 if (acc->server == NULL) { 401 hide_login_progress(gc, "No servername specified"); 388 402 signoff(gc); 389 403 return; … … 2649 2663 ret->away_states = oscar_away_states; 2650 2664 ret->login = oscar_login; 2665 ret->acc_init = oscar_acc_init; 2651 2666 ret->close = oscar_close; 2652 2667 ret->send_im = oscar_send_im;
Note: See TracChangeset
for help on using the changeset viewer.