Пример #1
0
void
hangouts_auth_get_session_cookies_got_cb(PurpleHttpConnection *http_conn, PurpleHttpResponse *response, gpointer user_data)
{
	HangoutsAccount *ha = user_data;
	guint64 last_event_timestamp;
	
	gchar *sapisid_cookie = purple_http_cookie_jar_get(ha->cookie_jar, "SAPISID");
	
	if (sapisid_cookie == NULL) {
		purple_connection_error(ha->pc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, 
			_("SAPISID Cookie not received"));
		return;
	}
	
	//Restore the last_event_timestamp before it gets overridden by new events
	last_event_timestamp = purple_account_get_int(ha->account, "last_event_timestamp_high", 0);
	if (last_event_timestamp != 0) {
		last_event_timestamp = (last_event_timestamp << 32) | ((guint64) purple_account_get_int(ha->account, "last_event_timestamp_low", 0) & 0xFFFFFFFF);
		ha->last_event_timestamp = last_event_timestamp;
	}
	
	// SOUND THE TRUMPETS
	hangouts_fetch_channel_sid(ha);
	purple_connection_set_state(ha->pc, PURPLE_CONNECTION_CONNECTED);
	//TODO trigger event instead
	hangouts_get_self_info(ha);
	hangouts_get_conversation_list(ha);
	
	g_free(sapisid_cookie);
}
Пример #2
0
static void irc_login(PurpleAccount *account)
{
	PurpleConnection *gc;
	struct irc_conn *irc;
	char **userparts;
	const char *username = purple_account_get_username(account);

	gc = purple_account_get_connection(account);
	gc->flags |= PURPLE_CONNECTION_NO_NEWLINES;

	if (strpbrk(username, " \t\v\r\n") != NULL) {
		purple_connection_error(gc, _("IRC nicks may not contain whitespace"));
		return;
	}

	gc->proto_data = irc = g_new0(struct irc_conn, 1);
	irc->fd = -1;
	irc->account = account;
	irc->outbuf = purple_circ_buffer_new(512);

	userparts = g_strsplit(username, "@", 2);
	purple_connection_set_display_name(gc, userparts[0]);
	irc->server = g_strdup(userparts[1]);
	g_strfreev(userparts);

	irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal,
					     NULL, (GDestroyNotify)irc_buddy_free);
	irc->cmds = g_hash_table_new(g_str_hash, g_str_equal);
	irc_cmd_table_build(irc);
	irc->msgs = g_hash_table_new(g_str_hash, g_str_equal);
	irc_msg_table_build(irc);

	purple_connection_update_progress(gc, _("Connecting"), 1, 2);

	if (purple_account_get_bool(account, "ssl", FALSE)) {
		if (purple_ssl_is_supported()) {
			irc->gsc = purple_ssl_connect(account, irc->server,
					purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
					irc_login_cb_ssl, irc_ssl_connect_failure, gc);
		} else {
			purple_connection_error(gc, _("SSL support unavailable"));
			return;
		}
	}

	if (!irc->gsc) {

		if (purple_proxy_connect(gc, account, irc->server,
				 purple_account_get_int(account, "port", IRC_DEFAULT_PORT),
				 irc_login_cb, gc) == NULL)
		{
			purple_connection_error(gc, _("Couldn't create socket"));
			return;
		}
	}
}
Пример #3
0
static void
stress_login(PurpleAccount *account) {
	PurpleConnection *pc = NULL;
	PurpleGroup *g = NULL;
	gint n_buddies = 0, i = 0, interval = 0, maxevents = 0;

	/* build our possible events from the account settings */
	add_event("trigger_signon", STRESS_EVENT_SIGN_ON, STRESS_EVENT_SIGN_OFF);
	add_event("trigger_idle", STRESS_EVENT_IDLE, STRESS_EVENT_UNIDLE);
	add_event("trigger_away", STRESS_EVENT_AWAY, STRESS_EVENT_BACK);
	add_event("trigger_typing", STRESS_EVENT_TYPING, STRESS_EVENT_STOPPED_TYPING);
	add_event("send_messages", STRESS_EVENT_SEND_MESSAGE, -1);

	nevents = g_list_length(events);

	/* get our connection and set it as online */
	pc = purple_account_get_connection(account);
	purple_connection_set_state(pc, PURPLE_CONNECTED);

	/* grab the account settings we need for buddies */
	n_buddies = purple_account_get_int(account, "nbuddies", 50);
	maxevents = purple_account_get_int(account, "maxevents", 100);
	interval = (guint)purple_account_get_int(account, "interval", 500);
	message_min = purple_account_get_int(account, "message_min", 16);
	message_max = purple_account_get_int(account, "message_max", 128);

	g = purple_group_new("prpl-stress");

	for(i = 0; i < n_buddies; i++) {
		PurpleBuddy *b = NULL;
		StressBuddy *sb = NULL;
		gchar *name = NULL;

		/* create the buddy and it's name */
		name = g_strdup_printf("stress-%04x", i);
		b = purple_buddy_new(account, name, NULL);
		g_free(name);

		/* add our data to the buddy */
		sb = g_new0(StressBuddy, 1);
		sb->buddy = b;
		sb->maxevents = maxevents;
		purple_buddy_set_protocol_data(b, sb);

		/* add the buddy to our list and the purple blist */
		buddies = g_list_prepend(buddies, sb);
		purple_blist_add_buddy(b, NULL, g, NULL);

		/* add our event timer to the buddy */
		sb->timer_id = g_timeout_add(interval, stress_event_cb, sb);
	}
}
Пример #4
0
static void
pb_process_frame(PushBulletAccount *pba, const gchar *frame)
{
	JsonParser *parser = json_parser_new();
	JsonNode *root;
	
	purple_debug_info("pushbullet", "got frame data: %s\n", frame);
	
	if (!json_parser_load_from_data(parser, frame, -1, NULL))
	{
		purple_debug_error("pushbullet", "Error parsing response: %s\n", frame);
		return;
	}
	
	root = json_parser_get_root(parser);
	
	if (root != NULL) {
		JsonObject *message = json_node_get_object(root);
		const gchar *type = json_object_get_string_member(message, "type");
		if (purple_strequal(type, "tickle")) {
			pb_get_everything_since(pba, purple_account_get_int(pba->account, "last_message_timestamp", 0));
		} else if (purple_strequal(type, "push")) {
			JsonObject *push = json_object_get_object_member(message, "push");
			//{"type":"push","targets":["stream","android","ios"],"push":{"guid":"purple6e94d282","type":"messaging_extension_reply","package_name":"com.pushbullet.android","target_device_iden":"uffvytgsjAoIRwhIL6","conversation_iden":"+6421478252","message":"test2"}}
			//{"type":"push","targets":["stream"],"push":{"type":"sms_changed"}}
			type = json_object_get_string_member(push, "type");
			if (purple_strequal(type, "sms_changed")) {
				pb_get_phone_threads(pba, NULL);
			}
		}
	}
	
	g_object_unref(parser);
}
Пример #5
0
void silcpurple_idle_set(PurpleConnection *gc, int idle)

{
	SilcPurple sg;
	SilcClient client;
	SilcClientConnection conn;
	SilcAttributeObjService service;
	const char *server;
	int port;

	sg = gc->proto_data;
	if (sg == NULL)
		return;

	client = sg->client;
	if (client == NULL)
		return;

	conn = sg->conn;
	if (conn == NULL)
		return;

	server = purple_account_get_string(sg->account, "server",
					 "silc.silcnet.org");
	port = purple_account_get_int(sg->account, "port", 706),

	memset(&service, 0, sizeof(service));
	silc_client_attribute_del(client, conn,
				  SILC_ATTRIBUTE_SERVICE, NULL);
	service.port = port;
	g_snprintf(service.address, sizeof(service.address), "%s", server);
	service.idle = idle;
	silc_client_attribute_add(client, conn, SILC_ATTRIBUTE_SERVICE,
				  &service, sizeof(service));
}
Пример #6
0
static void yahoo_xfer_init(PurpleXfer *xfer)
{
	struct yahoo_xfer_data *xfer_data;
	PurpleConnection *gc;
	PurpleAccount *account;
	struct yahoo_data *yd;

	xfer_data = xfer->data;
	gc = xfer_data->gc;
	yd = gc->proto_data;
	account = purple_connection_get_account(gc);

	if (purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) {
		if (yd->jp) {
			if (purple_proxy_connect(NULL, account, purple_account_get_string(account, "xferjp_host",  YAHOOJP_XFER_HOST),
			                       purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
			                       yahoo_sendfile_connected, xfer) == NULL)
			{
				purple_notify_error(gc, NULL, _("File Transfer Failed"),
				                _("Unable to establish file descriptor."));
				purple_xfer_cancel_remote(xfer);
			}
		} else {
			if (purple_proxy_connect(NULL, account, purple_account_get_string(account, "xfer_host",  YAHOO_XFER_HOST),
			                       purple_account_get_int(account, "xfer_port", YAHOO_XFER_PORT),
			                       yahoo_sendfile_connected, xfer) == NULL)
			{
				purple_notify_error(gc, NULL, _("File Transfer Failed"),
				                _("Unable to establish file descriptor."));
				purple_xfer_cancel_remote(xfer);
			}
		}
	} else {
		/* TODO: Using xfer->fd like this is probably a bad thing... */
		if (purple_proxy_connect(NULL, account, xfer_data->host, xfer_data->port,
		                              yahoo_receivefile_connected, xfer) == NULL)
			xfer->fd = -1;
		else
			xfer->fd = 0;
		if (xfer->fd == -1) {
			purple_notify_error(gc, NULL, _("File Transfer Failed"),
			             _("Unable to establish file descriptor."));
			purple_xfer_cancel_remote(xfer);
		}
	}
}
Пример #7
0
static void
pb_got_phone_threads(PushBulletAccount *pba, JsonNode *node, gpointer user_data)
{
	PurpleAccount *account = pba->account;
	JsonObject *rootobj = json_node_get_object(node);
	JsonObject *data = json_object_get_object_member(rootobj, "data");
	JsonArray *threads = json_object_get_array_member(data, "threads");
	gint i;
	guint len;
	gchar *device = user_data;
	gint last_message_timestamp = purple_account_get_int(account, "last_message_timestamp", 0);
	gint newest_phone_message_id = purple_account_get_int(account, "newest_phone_message_id", 0);
	
	for(i = 0, len = json_array_get_length(threads); i < len; i++)
	{
		JsonObject *thread = json_array_get_object_element(threads, i);
		const gchar *id = json_object_get_string_member(thread, "id");
		JsonArray *recipients = json_object_get_array_member(thread, "recipients");
		const gchar *from = NULL;
		
		if (json_array_get_length(recipients) > 0) {
			JsonObject *first_recipient = json_array_get_object_element(recipients, 0);
			from = json_object_get_string_member(first_recipient, "number");
			
			if (json_object_has_member(first_recipient, "thumbnail")) {
				pb_set_base64_icon_for_buddy(json_object_get_string_member(first_recipient, "thumbnail"), purple_find_buddy(account, from));
			}
		}
		if (from == NULL) {
			continue;
		}
		if (json_object_has_member(thread, "latest"))
		{
			JsonObject *latest = json_object_get_object_member(thread, "latest");
			gint64 timestamp = json_object_get_int_member(latest, "timestamp");
			gint msgid = atoi(json_object_get_string_member(latest, "id"));
			
			if (timestamp > last_message_timestamp || msgid > newest_phone_message_id) {
				pb_get_phone_thread_by_id(pba, device, id, from);
			}
		}
		
	}
	
	g_free(device);
}
Пример #8
0
/** Convert point size to msim pixel height font size specification, for outgoing messages. */
static guint
msim_point_to_height(MsimSession *session, guint point)
{
	guint dpi;

	dpi = purple_account_get_int(session->account, "dpi", MSIM_DEFAULT_DPI);

	return (guint)msim_round((dpi * 1. / POINTS_PER_INCH) * point);
}
Пример #9
0
/** Convert a msim markup font pixel height to the more usual point size, for incoming messages. */
static guint
msim_height_to_point(MsimSession *session, guint height)
{
	guint dpi;

	dpi = purple_account_get_int(session->account, "dpi", MSIM_DEFAULT_DPI);

	return (guint)msim_round((POINTS_PER_INCH * 1. / dpi) * height);

	/* See also: libpurple/protocols/bonjour/jabber.c
	 * _font_size_ichat_to_purple */
}
Пример #10
0
static gboolean
pb_poll_everything(PushBulletAccount *pba)
{
	if (purple_account_is_connected(pba->account)) {
		pb_get_everything_since(pba, purple_account_get_int(pba->account, "last_message_timestamp", 0));
		return TRUE;
	}
	
	pba->everything_poll = 0;
	
	return FALSE;
}
Пример #11
0
static void
nap_login(PurpleAccount *account) {
    PurpleConnection *gc = purple_account_get_connection(account);

    purple_connection_update_progress(gc, _("Connecting"), 0, NAPSTER_CONNECT_STEPS);

    gc->proto_data = g_new0(struct nap_data, 1);
    if (purple_proxy_connect(gc, account,
                             purple_account_get_string(account, "server", NAP_SERVER),
                             purple_account_get_int(account, "port", NAP_PORT),
                             nap_login_connect, gc) != 0) {
        purple_connection_error(gc, _("Unable to connect."));
    }
}
Пример #12
0
/*------------------------------------------------------------------------
 * We now have a connection established with MXit, so we can start the
 * login procedure
 *
 * @param session	The MXit session object
 */
static void mxit_connected( struct MXitSession* session )
{
	int			state;

	purple_debug_info( MXIT_PLUGIN_ID, "mxit_connected\n" );

	session->flags |= MXIT_FLAG_CONNECTED;
	purple_connection_update_progress( session->con, _( "Logging In..." ), 2, 4 );

	/* create a timer to send a ping packet if the connection is idle */
	session->last_tx = mxit_now_milli();

	/* encrypt the user password */
	session->encpwd = mxit_encrypt_password( session );

	state = purple_account_get_int( session->acc, MXIT_CONFIG_STATE, MXIT_STATE_LOGIN );
	if ( state == MXIT_STATE_LOGIN ) {
		/* create and send login packet */
		mxit_send_login( session );
	}
	else {
		if ( !session->profile ) {
			/* we have lost the session profile, so ask the user to enter it again */
			mxit_register_view( session );
		}
		else {
			/* create and send the register packet */
			mxit_send_register( session );
		}
	}

	/* enable signals */
	mxit_enable_signals( session );

#ifdef		MXIT_LINK_CLICK
	/* register for uri click notification */
	mxit_register_uri_handler();
#endif

	/* start the polling if this is a HTTP connection */
	if ( session->http ) {
		session->http_timer_id = purple_timeout_add_seconds( 2, mxit_manage_polling, session );
	}

	/* This timer might already exist if we're registering a new account */
	if ( session->q_slow_timer_id == 0 ) {
		/* start the tx queue manager timer */
		session->q_slow_timer_id = purple_timeout_add_seconds( 2, mxit_manage_queue_slow, session );
	}
}
Пример #13
0
static void waprpl_login(PurpleAccount * acct)
{
	PurpleConnection *gc = purple_account_get_connection(acct);

	purple_debug_info(WHATSAPP_ID, "logging in %s\n", purple_account_get_username(acct));

	purple_connection_update_progress(gc, "Connecting", 0, 4);

	whatsapp_connection *wconn = g_new0(whatsapp_connection, 1);
	wconn->fd = -1;
	wconn->sslfd = -1;
	wconn->account = acct;
	wconn->rh = 0;
	wconn->wh = 0;
	wconn->timer = 0;
	wconn->connected = 0;
	wconn->conv_id = 1;
	wconn->gsc = 0;
	wconn->sslrh = 0;
	wconn->sslwh = 0;

	const char *username = purple_account_get_username(acct);
	const char *password = purple_account_get_password(acct);
	const char *nickname = purple_account_get_string(acct, "nick", "");

	wconn->waAPI = waAPI_create(username, password, nickname);
	purple_connection_set_protocol_data(gc, wconn);

	const char *hostname = purple_account_get_string(acct, "server", "");
	int port = purple_account_get_int(acct, "port", WHATSAPP_DEFAULT_PORT);

	char hn[256];
	if (strlen(hostname) == 0) {
		sprintf(hn, "e%d.whatsapp.net", rand() % 9 + 1);
		hostname = hn;
	}

	if (purple_proxy_connect(gc, acct, hostname, port, waprpl_connect_cb, gc) == NULL) {
		purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "Unable to connect");
	}

	static int sig_con = 0;
	if (!sig_con) {
		sig_con = 1;
		purple_signal_connect(purple_blist_get_handle(), "blist-node-removed", _whatsapp_protocol, PURPLE_CALLBACK(waprpl_blist_node_removed), NULL);
		purple_signal_connect(purple_blist_get_handle(), "blist-node-added", _whatsapp_protocol, PURPLE_CALLBACK(waprpl_blist_node_added), NULL);
	}
}
Пример #14
0
static void
pb_start_polling(PushBulletAccount *pba)
{
	if (!purple_account_is_connected(pba->account))
		return;
	
	if (!pba->phone_threads_poll && pba->main_sms_device) {
		pb_get_phone_threads(pba, NULL);
		pba->phone_threads_poll = purple_timeout_add_seconds(10, (GSourceFunc) pb_poll_phone_threads, pba);
	}
	
	if (!pba->everything_poll) {
		pb_get_everything_since(pba, purple_account_get_int(pba->account, "last_message_timestamp", 0));
		pba->everything_poll = purple_timeout_add_seconds(10, (GSourceFunc) pb_poll_everything, pba);
	}
}
Пример #15
0
/*------------------------------------------------------------------------
 * 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;
}
Пример #16
0
time_t
purple_buddy_icons_get_account_icon_timestamp(PurpleAccount *account)
{
	time_t ret;

	g_return_val_if_fail(account != NULL, 0);

	ret = purple_account_get_int(account, "buddy_icon_timestamp", 0);

	/* This deals with migration cases. */
	if (ret == 0 && purple_account_get_string(account, "buddy_icon", NULL) != NULL)
	{
		ret = time(NULL);
		purple_account_set_int(account, "buddy_icon_timestamp", ret);
	}

	return ret;
}
Пример #17
0
/** Convert HTML font size to point size. */
static guint
msim_purple_size_to_point(MsimSession *session, guint size)
{
	gdouble scale;
	guint point;
	guint base;

	scale = _font_scale[CLAMP(size, 1, MAX_FONT_SIZE) - 1];

	base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE);

	point = (guint)msim_round(scale * base);

	purple_debug_info("msim", "msim_purple_size_to_point: size=%d -> %d pt\n",
					size, point);

	return point;
}
Пример #18
0
void flist_login(PurpleAccount *pa) {
    PurpleConnection *pc = purple_account_get_connection(pa);
    FListAccount *fla;
    gchar **ac_split;

    fla = g_new0(FListAccount, 1);
    fla->pa = pa;
    fla->pc = pc;

    fla->all_characters = g_hash_table_new_full((GHashFunc)flist_str_hash, (GEqualFunc)flist_str_equal, g_free, (GDestroyNotify)flist_character_free);

    fla->rx_buf = g_malloc0(256); fla->rx_len = 0;
    pc->proto_data = fla;

    ac_split = g_strsplit(purple_account_get_username(pa), ":", 2);
    fla->username = g_strdup(ac_split[0]);
    fla->character = g_strdup(ac_split[1]);
    fla->password = g_strdup(purple_account_get_password(pa));

    //we don't want to display the whole username:character thing
    if(purple_account_get_alias(pa) == NULL || flist_str_equal(purple_account_get_username(pa), purple_account_get_alias(pa))) {
        purple_account_set_alias(pa, fla->character);
    }

    
    /* login options */
    fla->server_address = g_strdup(purple_account_get_string(pa, "server_address", "chat.f-list.net"));
    fla->server_port = purple_account_get_int(pa, "server_port", FLIST_PORT);
    
    fla->sync_bookmarks = purple_account_get_bool(pa, "sync_bookmarks", FALSE);
    fla->sync_friends = purple_account_get_bool(pa, "sync_friends", TRUE);
    
    fla->debug_mode = purple_account_get_bool(pa, "debug_mode", FALSE);
    
    flist_channel_subsystem_load(fla);
    flist_clear_filter(fla);
    flist_global_kinks_load(pc);
    flist_profile_load(pc);
    flist_friends_load(fla);
    
    flist_ticket_timer(fla, 0);
    g_strfreev(ac_split);
}
Пример #19
0
/** Convert typographical font point size to HTML font size.
 * Based on libpurple/gtkimhtml.c */
static guint
msim_point_to_purple_size(MsimSession *session, guint point)
{
	guint size, this_point, base;

	base = purple_account_get_int(session->account, "base_font_size", MSIM_BASE_FONT_POINT_SIZE);

	for (size = 0; size < MAX_FONT_SIZE; ++size) {
		this_point = (guint)msim_round(base * _font_scale[size]);

		if (this_point >= point) {
			purple_debug_info("msim", "msim_point_to_purple_size: %d pt -> size=%d\n",
					point, size);
			return size;
		}
	}

	/* No HTML font size was this big; return largest possible. */
	return this_point;
}
Пример #20
0
void ycht_connection_open(PurpleConnection *gc)
{
	YchtConn *ycht;
	YahooData *yd = purple_connection_get_protocol_data(gc);
	PurpleAccount *account = purple_connection_get_account(gc);

	ycht = g_new0(YchtConn, 1);
	ycht->gc = gc;
	ycht->fd = -1;

	yd->ycht = ycht;

	if (purple_proxy_connect(gc, account,
	                       purple_account_get_string(account, "ycht-server",  YAHOO_YCHT_HOST),
	                       purple_account_get_int(account, "ycht-port", YAHOO_YCHT_PORT),
	                       ycht_got_connected, ycht) == NULL)
	{
		ycht_connection_error(ycht, _("Unable to connect"));
		return;
	}
}
Пример #21
0
static void
np_socket_login(NPSession *session)
{
    
    PurpleConnection *gc;
	PurplePresence *presence;
	const char *host;
	gboolean http_method = FALSE;
	int port;
    PurpleAccount *account ;
    
    account = session->account;
    

    host = purple_account_get_string(account, "server", NP_IM_SERVER);
	port = purple_account_get_int(account, "port", NP_IM_PORT);
    
//    session = np_session_new(account);
    
    purple_debug_warning("np","=====> session : %p ",session);
    
    gc = purple_account_get_connection(account);
	g_return_if_fail(gc != NULL);
    
    gc->proto_data = session;
    
	gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_AUTO_RESP;
    
    np_session_set_login_step(session, NP_LOGIN_STEP_START);
    presence = purple_account_get_presence(account);
    
	if (!np_session_connect(session, host, port, http_method))
		purple_connection_error_reason(gc,
                                       PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
                                       _("Unable to connect"));

    
}
Пример #22
0
static time_t tgp_msg_oldest_relevant_ts (struct tgl_state *TLS) {
  connection_data *conn = TLS->ev_base;
  int days = purple_account_get_int (conn->pa, TGP_KEY_HISTORY_RETRIEVAL_THRESHOLD,
                                     TGP_DEFAULT_HISTORY_RETRIEVAL_THRESHOLD);
  return days > 0 ? tgp_time_n_days_ago (days) : 0;
}
Пример #23
0
int twitter_option_cutoff_time(PurpleAccount * account)
{
    return purple_account_get_int(account, TWITTER_ONLINE_CUTOFF_TIME_HOURS, TWITTER_ONLINE_CUTOFF_TIME_HOURS_DEFAULT);
}
Пример #24
0
gint twitter_option_user_status_timeout(PurpleAccount * account)
{
    return purple_account_get_int(account, TWITTER_PREF_USER_STATUS_TIMEOUT, TWITTER_PREF_USER_STATUS_TIMEOUT_DEFAULT);
}
Пример #25
0
gint twitter_option_list_max_tweets(PurpleAccount * account)
{
    return purple_account_get_int(account, TWITTER_PREF_HOME_TIMELINE_MAX_TWEETS, TWITTER_PREF_HOME_TIMELINE_MAX_TWEETS_DEFAULT);
}
Пример #26
0
gint twitter_option_dms_timeout(PurpleAccount * account)
{
    return purple_account_get_int(account, TWITTER_PREF_DMS_TIMEOUT, TWITTER_PREF_DMS_TIMEOUT_DEFAULT);
}
Пример #27
0
gint twitter_option_search_timeout(PurpleAccount * account)
{
    return purple_account_get_int(account, TWITTER_PREF_SEARCH_TIMEOUT, TWITTER_PREF_SEARCH_TIMEOUT_DEFAULT);
}
static gboolean
exec_skype()
{
	if (!connected && !in_progress)
	{
		in_progress = TRUE;
		PurpleAccount *acct = skype_get_account(NULL);
		purple_proxy_connect(acct->gc, acct, purple_account_get_string(acct, "host", "skype.robbmob.com"), purple_account_get_int(acct, "port", 5000), connect_function, acct);
		g_thread_create((GThreadFunc)skype_read_thread, acct, FALSE, NULL);
		purple_timeout_add_seconds(10, connection_timeout, acct);
	}
	return TRUE;
}
Пример #29
0
static void fb_got_notifications_cb(FacebookAccount *fba, gchar *url_text, gsize len, gpointer userdata)
{
	gchar *salvaged;
	time_t last_fetch_time;
	time_t time_of_message;
	time_t newest_message = 0;
	xmlnode *channel;//VOXOX - CJC - 2009.07.06 
	xmlnode *rss_root;//VOXOX - CJC - 2009.07.06 
	xmlnode *item;//VOXOX - CJC - 2009.07.06 
	xmlnode *link;//VOXOX - CJC - 2009.07.06 
	xmlnode *title;//VOXOX - CJC - 2009.07.06 
	gchar *tmp;
	gchar month_string[4], weekday[4];
	guint year, month, day, hour, minute, second;
	long timezone;
	gchar *subject, *url;

	month_string[3] = weekday[3] = '\0';
	year = month = day = hour = minute = second = 0;

	if (!url_text || !len)
		return;

	last_fetch_time = purple_account_get_int(fba->account, "facebook_notifications_last_fetch", 0);
	/* purple_debug_info("facebook", "last fetch time: %zu\n", last_fetch_time); */

	salvaged = purple_utf8_salvage(url_text);
	rss_root = xmlnode_from_str(salvaged, -1);
	g_free(salvaged);

	if (rss_root == NULL)
	{
		purple_debug_error("facebook", "Could not load RSS file\n");
		return;
	}
	channel = xmlnode_get_child(rss_root, "channel");
	if (channel == NULL)
	{
		purple_debug_warning("facebook", "Invalid RSS feed\n");
		xmlnode_free(rss_root);
		return;
	}
	item = xmlnode_get_child(channel, "item");
	if (item == NULL)
	{
		purple_debug_info("facebook", "No new notifications\n");
	}
	for (; item != NULL; item = xmlnode_get_next_twin(item))
	{
		xmlnode *pubDate = xmlnode_get_child(item, "pubDate");
		if (!pubDate)
			continue;
		tmp = xmlnode_get_data_unescaped(pubDate);
		/* rss times are in Thu, 19 Jun 2008 15:51:25 -1100 format */
		sscanf(tmp, "%3s, %2u %3s %4u %2u:%2u:%2u %5ld", (char*)&weekday, &day, (char*)&month_string, &year, &hour, &minute, &second, &timezone);
		if (g_str_equal(month_string, "Jan")) month = 0;
		else if (g_str_equal(month_string, "Feb")) month = 1;
		else if (g_str_equal(month_string, "Mar")) month = 2;
		else if (g_str_equal(month_string, "Apr")) month = 3;
		else if (g_str_equal(month_string, "May")) month = 4;
		else if (g_str_equal(month_string, "Jun")) month = 5;
		else if (g_str_equal(month_string, "Jul")) month = 6;
		else if (g_str_equal(month_string, "Aug")) month = 7;
		else if (g_str_equal(month_string, "Sep")) month = 8;
		else if (g_str_equal(month_string, "Oct")) month = 9;
		else if (g_str_equal(month_string, "Nov")) month = 10;
		else if (g_str_equal(month_string, "Dec")) month = 11;
		g_free(tmp);

		/* try using pidgin's functions */
		tmp = g_strdup_printf("%04u%02u%02uT%02u%02u%02u%05ld", year, month, day, hour, minute, second, timezone);
		time_of_message = purple_str_to_time(tmp, FALSE, NULL, NULL, NULL);
		g_free(tmp);

		if (time_of_message <= 0)
		{
			/* there's no cross-platform, portable way of converting string to time
			   which doesn't need a new version of glib, so just cheat */
			time_of_message = second + 60*minute + 3600*hour + 86400*day + 2592000*month + 31536000*(year-1970);
		}

		if (time_of_message > newest_message)
		{
			/* we'll keep the newest message to save */
			newest_message = time_of_message;
		}

		if (time_of_message <= last_fetch_time)
		{
			/* fortunatly, rss messages are ordered from newest to oldest */
			/* so if this message is older than the last one, ignore rest */
			break;
		}
		
		link = xmlnode_get_child(item, "link");
		if (link)
		{
			url = xmlnode_get_data_unescaped(link);
		} else {
			url = g_strdup("");
		}
		
		title = xmlnode_get_child(item, "title");
		if (title)
		{
			subject = xmlnode_get_data_unescaped(title);
		} else {
			subject = g_strdup("");
		}
		
		purple_notify_email(fba->pc, subject, NULL, fba->account->username, url, NULL, NULL);
		g_free(subject);
		g_free(url);
	}
	xmlnode_free(rss_root);

	if (newest_message > last_fetch_time)
	{
		/* update the last fetched time if we had newer messages */
		purple_account_set_int(fba->account, "facebook_notifications_last_fetch", newest_message);
	}
}
Пример #30
0
static void qq_login(PurpleAccount *account)
{
	PurpleConnection *gc;
	qq_data *qd;
	PurplePresence *presence;
	const gchar *version_str;

	g_return_if_fail(account != NULL);

	gc = purple_account_get_connection(account);
	g_return_if_fail(gc != NULL);

	gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_AUTO_RESP;

	qd = g_new0(qq_data, 1);
	memset(qd, 0, sizeof(qq_data));
	qd->gc = gc;
	gc->proto_data = qd;

	presence = purple_account_get_presence(account);
	if(purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_INVISIBLE)) {
		qd->login_mode = QQ_LOGIN_MODE_HIDDEN;
	} else if(purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_AWAY)
			|| purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_EXTENDED_AWAY)) {
		qd->login_mode = QQ_LOGIN_MODE_AWAY;
	} else {
		qd->login_mode = QQ_LOGIN_MODE_NORMAL;
	}

	server_list_create(account);
	purple_debug_info("QQ", "Server list has %d\n", g_list_length(qd->servers));

	version_str = purple_account_get_string(account, "client_version", NULL);
	qd->client_tag = QQ_CLIENT_2227;	/* set default as QQ2011 */
	qd->client_version = 2011;
	if (version_str != NULL && strlen(version_str) != 0) {
		if (strcmp(version_str, "qq2010") == 0) {
			qd->client_tag = QQ_CLIENT_1E0D;
			qd->client_version = 2010;
		}
		if (strcmp(version_str, "qq2011") == 0) {
			qd->client_tag = QQ_CLIENT_2227;
			qd->client_version = 2011;
		}
		if (strcmp(version_str, "qq2012") == 0) {
			qd->client_tag = QQ_CLIENT_2227;
			qd->client_version = 2012;
		}
	}


	qd->is_show_notice = purple_account_get_bool(account, "show_notice", TRUE);
	qd->is_show_news = purple_account_get_bool(account, "show_news", TRUE);
	qd->is_show_chat = purple_account_get_bool(account, "show_chat", TRUE);

	qd->resend_times = purple_prefs_get_int("/plugins/prpl/qq/resend_times");
	if (qd->resend_times <= 1) qd->itv_config.resend = 4;

	qd->itv_config.resend = purple_prefs_get_int("/plugins/prpl/qq/resend_interval");
	if (qd->itv_config.resend <= 0) qd->itv_config.resend = 4;
	purple_debug_info("QQ", "Resend interval %d, retries %d\n",
			qd->itv_config.resend, qd->resend_times);

	qd->itv_config.keep_alive = purple_account_get_int(account, "keep_alive_interval", 60);
	if (qd->itv_config.keep_alive < 30) qd->itv_config.keep_alive = 40;
	qd->itv_config.keep_alive /= qd->itv_config.resend;
	qd->itv_count.keep_alive = qd->itv_config.keep_alive;

	qd->itv_config.update = purple_account_get_int(account, "update_interval", 300);
	if (qd->itv_config.update > 0) {
		if (qd->itv_config.update < qd->itv_config.keep_alive) {
			qd->itv_config.update = qd->itv_config.keep_alive;
		}
		qd->itv_config.update /= qd->itv_config.resend;
		qd->itv_count.update = qd->itv_config.update;
	} else {
		qd->itv_config.update = 0;
	}

	qd->connect_watcher = purple_timeout_add_seconds(0, qq_connect_later, gc);
}