/*------------------------------------------------------------------------ * Create a new mxit session object * * @return The MXit session object */ static struct MXitSession* mxit_create_object( PurpleAccount* account ) { PurpleConnection* con = purple_account_get_connection( account ); struct MXitSession* session = NULL; /* currently the wapsite does not handle a '+' in front of the username (mxitid) so we just strip it */ { const char* username = purple_account_get_username( account ); if ( username[0] == '+' ) { char* fixed = g_strdup( &username[1] ); purple_account_set_username( account, fixed ); g_free( fixed ); } } session = g_new0( struct MXitSession, 1 ); session->con = con; session->acc = account; /* configure the connection (reference: "libpurple/connection.h") */ purple_connection_set_protocol_data( con, session ); purple_connection_set_flags( con, PURPLE_CONNECTION_FLAG_NO_BGCOLOR | PURPLE_CONNECTION_FLAG_NO_URLDESC | PURPLE_CONNECTION_FLAG_HTML | PURPLE_CONNECTION_FLAG_SUPPORT_MOODS ); /* configure the session (reference: "libpurple/account.h") */ g_strlcpy( session->server, purple_account_get_string( account, MXIT_CONFIG_SERVER_ADDR, DEFAULT_SERVER ), sizeof( session->server ) ); g_strlcpy( session->http_server, purple_account_get_string( account, MXIT_CONFIG_HTTPSERVER, DEFAULT_HTTP_SERVER ), sizeof( session->http_server ) ); session->port = purple_account_get_int( account, MXIT_CONFIG_SERVER_PORT, DEFAULT_PORT ); g_strlcpy( session->distcode, purple_account_get_string( account, MXIT_CONFIG_DISTCODE, "" ), sizeof( session->distcode ) ); g_strlcpy( session->clientkey, purple_account_get_string( account, MXIT_CONFIG_CLIENTKEY, "" ), sizeof( session->clientkey ) ); g_strlcpy( session->dialcode, purple_account_get_string( account, MXIT_CONFIG_DIALCODE, "" ), sizeof( session->dialcode ) ); session->http = purple_account_get_bool( account, MXIT_CONFIG_USE_HTTP, FALSE ); session->iimages = g_hash_table_new( g_str_hash, g_str_equal ); session->rx_state = RX_STATE_RLEN; session->http_interval = MXIT_HTTP_POLL_MIN; session->http_last_poll = mxit_now_milli(); session->async_http_reqs = purple_http_connection_set_new(); return session; }
static void skypeweb_login(PurpleAccount *account) { PurpleConnection *pc = purple_account_get_connection(account); SkypeWebAccount *sa = g_new0(SkypeWebAccount, 1); PurpleConnectionFlags flags; purple_connection_set_protocol_data(pc, sa); if (!purple_ssl_is_supported()) { purple_connection_error (pc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("Server requires TLS/SSL for login. No TLS/SSL support found.")); return; } flags = purple_connection_get_flags(pc); flags |= PURPLE_CONNECTION_FLAG_HTML | PURPLE_CONNECTION_FLAG_NO_BGCOLOR | PURPLE_CONNECTION_FLAG_NO_FONTSIZE; purple_connection_set_flags(pc, flags); if (!SKYPEWEB_BUDDY_IS_MSN(purple_account_get_username(account))) { sa->username = g_ascii_strdown(purple_account_get_username(account), -1); } sa->account = account; sa->pc = pc; sa->cookie_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); sa->hostname_ip_cache = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); sa->sent_messages_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); sa->waiting_conns = g_queue_new(); sa->messages_host = g_strdup(SKYPEWEB_DEFAULT_MESSAGES_HOST); if(strchr(purple_account_get_username(account), '@')) { //Has an email address for a username, probably a microsoft account? skypeweb_begin_oauth_login(sa); } else { skypeweb_begin_web_login(sa); } purple_signal_connect(purple_conversations_get_handle(), "conversation-updated", pc, PURPLE_CALLBACK(skypeweb_mark_conv_seen), NULL); }