static void steam_login(account_t *acc) { gchar *str; SteamApiReq *req; SteamData *sata; sata = steam_data_new(acc); imcb_log(sata->ic, "Connecting"); if ((sata->api->token == NULL) || (sata->api->sessid == NULL)) { str = set_getstr(&acc->set, "cgid"); g_free(sata->api->cgid); sata->api->cgid = g_strdup(str); str = set_getstr(&acc->set, "esid"); g_free(sata->api->esid); sata->api->esid = g_strdup(str); sata->api->autht = set_getint(&acc->set, "autht"); imcb_log(sata->ic, "Requesting authentication key"); req = steam_api_req_new(sata->api, steam_cb_key, sata); steam_api_req_key(req, acc->user); return; } imcb_log(sata->ic, "Sending logon request"); req = steam_api_req_new(sata->api, steam_cb_logon, sata); steam_api_req_logon(req); }
static void twitter_main_loop_start(struct im_connection *ic) { struct twitter_data *td = ic->proto_data; /* Create the room now that we "logged in". */ if (td->flags & TWITTER_MODE_CHAT) twitter_groupchat_init(ic); imcb_log(ic, "Getting initial statuses"); // Run this once. After this queue the main loop function (or open the // stream if available). twitter_main_loop(ic, -1, 0); if (set_getbool(&ic->acc->set, "stream")) { /* That fetch was just to get backlog, the stream will give us the rest. \o/ */ twitter_open_stream(ic); /* Stream sends keepalives (empty lines) or actual data at least twice a minute. Disconnect if this stops. */ ic->flags |= OPT_PONGS; } else { /* Not using the streaming API, so keep polling the old- fashioned way. :-( */ td->main_loop_id = b_timeout_add(set_getint(&ic->acc->set, "fetch_interval") * 1000, twitter_main_loop, ic); } }
static gboolean twitter_length_check(struct im_connection *ic, gchar * msg) { int max = set_getint(&ic->acc->set, "message_length"), len; int target_len = set_getint(&ic->acc->set, "target_url_length"); int url_len_diff = 0; if (target_len > 0) url_len_diff = twitter_url_len_diff(msg, target_len); if (max == 0 || (len = g_utf8_strlen(msg, -1) + url_len_diff) <= max) return TRUE; twitter_log(ic, "Maximum message length exceeded: %d > %d", len, max); return FALSE; }
void Skype_login (account_t* account) { im_connection* connection = imcb_new(account); SkypeData* skype = g_new0(struct SkypeData, 1); connection->proto_data = skype; imcb_log(connection, "Connecting"); skype->ssl = ssl_connect( set_getstr(&account->set, "server"), set_getint(&account->set, "port"), Skype_connected, connection ); skype->fd = skype->ssl ? ssl_getfd(skype->ssl) : -1; skype->username = g_strdup(account->user); skype->connection = connection; if (set_getbool(&account->set, "skypeconsole")) { imcb_add_buddy(connection, "skypeconsole", NULL); } }
static void purple_sync_settings( account_t *acc, PurpleAccount *pa ) { PurplePlugin *prpl = purple_plugins_find_with_id( pa->protocol_id ); PurplePluginProtocolInfo *pi = prpl->info->extra_info; GList *i; for( i = pi->protocol_options; i; i = i->next ) { PurpleAccountOption *o = i->data; const char *name; set_t *s; name = purple_account_option_get_setting( o ); s = set_find( &acc->set, name ); if( s->value == NULL ) continue; switch( purple_account_option_get_type( o ) ) { case PURPLE_PREF_STRING: case PURPLE_PREF_STRING_LIST: purple_account_set_string( pa, name, set_getstr( &acc->set, name ) ); break; case PURPLE_PREF_INT: purple_account_set_int( pa, name, set_getint( &acc->set, name ) ); break; case PURPLE_PREF_BOOLEAN: purple_account_set_bool( pa, name, set_getbool( &acc->set, name ) ); break; default: break; } } if( pi->options & OPT_PROTO_MAIL_CHECK ) purple_account_set_check_mail( pa, set_getbool( &acc->set, "mail_notifications" ) ); }
/* Separate this from jabber_login() so we can do OAuth first if necessary. Putting this in io.c would probably be more correct. */ void jabber_connect( struct im_connection *ic ) { account_t *acc = ic->acc; struct jabber_data *jd = ic->proto_data; int i; char *connect_to; struct ns_srv_reply **srvl = NULL, *srv = NULL; /* Figure out the hostname to connect to. */ if( acc->server && *acc->server ) connect_to = acc->server; else if( ( srvl = srv_lookup( "xmpp-client", "tcp", jd->server ) ) || ( srvl = srv_lookup( "jabber-client", "tcp", jd->server ) ) ) { /* Find the lowest-priority one. These usually come back in random/shuffled order. Not looking at weights etc for now. */ srv = *srvl; for( i = 1; srvl[i]; i ++ ) if( srvl[i]->prio < srv->prio ) srv = srvl[i]; connect_to = srv->name; } else connect_to = jd->server; imcb_log( ic, "Connecting" ); for( i = 0; jabber_port_list[i] > 0; i ++ ) if( set_getint( &acc->set, "port" ) == jabber_port_list[i] ) break; if( jabber_port_list[i] == 0 ) { imcb_log( ic, "Illegal port number" ); imc_logout( ic, FALSE ); return; } /* For non-SSL connections we can try to use the port # from the SRV reply, but let's not do that when using SSL, SSL usually runs on non-standard ports... */ if( set_getbool( &acc->set, "ssl" ) ) { jd->ssl = ssl_connect( connect_to, set_getint( &acc->set, "port" ), FALSE, jabber_connected_ssl, ic ); jd->fd = jd->ssl ? ssl_getfd( jd->ssl ) : -1; } else { jd->fd = proxy_connect( connect_to, srv ? srv->port : set_getint( &acc->set, "port" ), jabber_connected_plain, ic ); } srv_free( srvl ); if( jd->fd == -1 ) { imcb_error( ic, "Could not connect to server" ); imc_logout( ic, TRUE ); return; } if( set_getbool( &acc->set, "xmlconsole" ) ) { jd->flags |= JFLAG_XMLCONSOLE; /* Shouldn't really do this at this stage already, maybe. But I think this shouldn't break anything. */ imcb_add_buddy( ic, JABBER_XMLCONSOLE_HANDLE, NULL ); } jabber_generate_id_hash( jd ); }
t = set_add(&s, "name", "default", NULL, data); set_setstr(&s, "name", "foo"); fail_unless(strcmp(set_getstr(&s, "name"), "foo") == 0); END_TEST START_TEST(test_set_get_str_unknown) set_t *s = NULL; fail_unless(set_getstr(&s, "name") == NULL); END_TEST START_TEST(test_setint) void *data = "data"; set_t *s = NULL, *t; t = set_add(&s, "name", "10", NULL, data); set_setint(&s, "name", 3); fail_unless(set_getint(&s, "name") == 3); END_TEST START_TEST(test_setstr) void *data = "data"; set_t *s = NULL, *t; t = set_add(&s, "name", "foo", NULL, data); set_setstr(&s, "name", "bloe"); fail_unless(strcmp(set_getstr(&s, "name"), "bloe") == 0); END_TEST START_TEST(test_set_get_int_unknown) set_t *s = NULL; fail_unless(set_getint(&s, "foo") == 0); END_TEST
/* Separate this from jabber_login() so we can do OAuth first if necessary. Putting this in io.c would probably be more correct. */ void jabber_connect(struct im_connection *ic) { account_t *acc = ic->acc; struct jabber_data *jd = ic->proto_data; int i; char *connect_to; struct ns_srv_reply **srvl = NULL, *srv = NULL; /* Figure out the hostname to connect to. */ if (acc->server && *acc->server) { connect_to = acc->server; } else if ((srvl = srv_lookup("xmpp-client", "tcp", jd->server)) || (srvl = srv_lookup("jabber-client", "tcp", jd->server))) { /* Find the lowest-priority one. These usually come back in random/shuffled order. Not looking at weights etc for now. */ srv = *srvl; for (i = 1; srvl[i]; i++) { if (srvl[i]->prio < srv->prio) { srv = srvl[i]; } } connect_to = srv->name; } else { connect_to = jd->server; } imcb_log(ic, "Connecting"); for (i = 0; jabber_port_list[i] > 0; i++) { if (set_getint(&acc->set, "port") == jabber_port_list[i]) { break; } } if (jabber_port_list[i] == 0) { imcb_log(ic, "Illegal port number"); imc_logout(ic, FALSE); return; } /* For non-SSL connections we can try to use the port # from the SRV reply, but let's not do that when using SSL, SSL usually runs on non-standard ports... */ if (set_getbool(&acc->set, "ssl")) { jd->ssl = ssl_connect(connect_to, set_getint(&acc->set, "port"), set_getbool(&acc->set, "tls_verify"), jabber_connected_ssl, ic); jd->fd = jd->ssl ? ssl_getfd(jd->ssl) : -1; } else { jd->fd = proxy_connect(connect_to, srv ? srv->port : set_getint(&acc->set, "port"), jabber_connected_plain, ic); } srv_free(srvl); if (jd->fd == -1) { imcb_error(ic, "Could not connect to server"); imc_logout(ic, TRUE); return; } if (set_getbool(&acc->set, "xmlconsole")) { jabber_xmlconsole_enable(ic); } if (set_getbool(&acc->set, "mail_notifications")) { /* It's gmail specific, but it checks for server support before enabling it */ jd->flags |= JFLAG_GMAILNOTIFY; if (set_getstr(&acc->set, "mail_notifications_handle")) { imcb_add_buddy(ic, set_getstr(&acc->set, "mail_notifications_handle"), NULL); } } jabber_generate_id_hash(jd); }