Beispiel #1
0
static void _elim_connect_progress        ( PurpleConnection *gc ,
                                            const char     *text ,
                                            size_t          step ,
                                            size_t    step_count )
{
    PurpleAccount *acct = purple_connection_get_account( gc );
    fprintf( stderr, "(_elim_connect_progress)\n" );

    if( acct )
    {
        char       *ID    = new_elim_id();
        xmlnode    *alist = xnode_new( "alist" );
        xmlnode    *mcall = func_call( "elim-connection-progress", ID, alist );
        const char *aname = purple_account_get_username   ( acct );
        const char *proto = purple_account_get_protocol_id( acct );
        int         state = purple_connection_get_state   ( gc   );
        g_free( ID );

        AL_PTR ( alist, "account-uid" , acct       );
        AL_STR ( alist, "account-name", aname      );
        AL_STR ( alist, "im-protocol" , proto      );
        AL_INT ( alist, "step"        , step       );
        AL_INT ( alist, "step-count"  , step_count );        
        AL_STR ( alist, "message"     , text       );
        AL_ENUM( alist, "state"       , state      , ":connection-state" );

        add_outbound_sexp( mcall );
    }

}
Beispiel #2
0
static void _elim_report_disconnect_reason( PurpleConnection     *conn   ,
                                            PurpleConnectionError reason ,
                                            const char           *text   )
{
    PurpleAccount *acct = purple_connection_get_account( conn );
    if( acct )
    {
        char       *ID    = new_elim_id();
        xmlnode    *alist = xnode_new( "alist" );
        fprintf( stderr, "(_elim_report_disconnect_reason)\n" );

        xmlnode    *mcall = func_call( "elim-disconnect-reason", ID, alist );
        const char *aname = purple_account_get_username   ( acct );
        const char *proto = purple_account_get_protocol_id( acct );
        int         state = purple_connection_get_state   ( conn );
        g_free( ID );

        AL_PTR ( alist, "account-uid" , acct  );
        AL_STR ( alist, "account-name", aname );
        AL_STR ( alist, "im-protocol" , proto );
        AL_STR ( alist, "message"     , text  );
        AL_ENUM( alist, "reason-code" , reason, ":connection-error" );
        AL_ENUM( alist, "state"       , state , ":connection-state" );

        add_outbound_sexp( mcall );
    }
}
Beispiel #3
0
void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	PurpleConnection *gc = purple_account_get_connection(irc->account);
	if (purple_connection_get_state(gc) == PURPLE_CONNECTED) {
		purple_notify_error(gc, _("Invalid nickname"),
				  _("Invalid nickname"),
				  _("Your selected nickname was rejected by the server.  It probably contains invalid characters."));

	} else {
		purple_connection_error_reason (gc,
				  PURPLE_CONNECTION_ERROR_INVALID_SETTINGS,
				  _("Your selected account name was rejected by the server.  It probably contains invalid characters."));
	}
}
Beispiel #4
0
void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args)
{
	char *newnick, *buf, *end;
	PurpleConnection *gc = purple_account_get_connection(irc->account);

	if (!args || !args[1])
		return;

	if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTED) {
		/* We only want to do the following dance if the connection
		   has not been successfully completed.  If it has, just
		   notify the user that their /nick command didn't go. */
		buf = g_strdup_printf("The nickname \"%s\" is already being used.",
				      irc->reqnick);
		purple_notify_error(gc, "Nickname in use",
				    "Nickname in use", buf);
		g_free(buf);
		g_free(irc->reqnick);
		irc->reqnick = NULL;
		return;
	}

	if (strlen(args[1]) < strlen(irc->reqnick) || irc->nickused)
		newnick = g_strdup(args[1]);
	else
		newnick = g_strdup_printf("%s0", args[1]);
	end = newnick + strlen(newnick) - 1;
	/* try fallbacks */
	if((*end < '9') && (*end >= '1')) {
			*end = *end + 1;
	} else *end = '1';

	g_free(irc->reqnick);
	irc->reqnick = newnick;
	irc->nickused = TRUE;

	purple_connection_set_display_name(
		purple_account_get_connection(irc->account), newnick);

	buf = irc_format(irc, "vn", "NICK", newnick);
	irc_send(irc, buf);
	g_free(buf);
}
Beispiel #5
0
static void _elim_notice ( PurpleConnection *conn, const char *msg )
{
    PurpleAccount *acct = purple_connection_get_account( conn );
    if( acct )
    {
        char       *ID    = new_elim_id();
        xmlnode    *alist = xnode_new( "alist" );
        xmlnode    *mcall = func_call( "elim-connection-state", ID, alist );
        const char *aname = purple_account_get_username   ( acct );
        const char *proto = purple_account_get_protocol_id( acct );
        int         state = purple_connection_get_state   ( conn );
        g_free( ID );

        AL_PTR ( alist, "account-uid" , acct  );
        AL_STR ( alist, "account-name", aname );
        AL_STR ( alist, "im-protocol" , proto );
        AL_STR ( alist, "message"     , msg   );
        AL_ENUM( alist, "state"       , state , ":connection-state" );

        add_outbound_sexp( mcall );
    }
}
void
_purple_connection_destroy(PurpleConnection *gc)
{
	PurpleAccount *account;
	GSList *buddies;
	PurplePluginProtocolInfo *prpl_info = NULL;
	gboolean remove = FALSE;

	g_return_if_fail(gc != NULL);

	account = purple_connection_get_account(gc);

	purple_debug_info("connection", "Disconnecting connection %p\n", gc);

	if (purple_connection_get_state(gc) != PURPLE_CONNECTING)
		remove = TRUE;

	purple_signal_emit(purple_connections_get_handle(), "signing-off", gc);

	while (gc->buddy_chats)
	{
		PurpleConversation *b = gc->buddy_chats->data;

		gc->buddy_chats = g_slist_remove(gc->buddy_chats, b);
		purple_conv_chat_left(PURPLE_CONV_CHAT(b));
	}

	update_keepalive(gc, FALSE);

	purple_proxy_connect_cancel_with_handle(gc);

	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
	if (prpl_info->close)
		(prpl_info->close)(gc);

	/* Clear out the proto data that was freed in the prpl close method*/
	buddies = purple_find_buddies(account, NULL);
	while (buddies != NULL) {
		PurpleBuddy *buddy = buddies->data;
		purple_buddy_set_protocol_data(buddy, NULL);
		buddies = g_slist_delete_link(buddies, buddies);
	}

	connections = g_list_remove(connections, gc);

	purple_connection_set_state(gc, PURPLE_DISCONNECTED);

	if (remove)
		purple_blist_remove_account(account);

	purple_signal_emit(purple_connections_get_handle(), "signed-off", gc);

	purple_account_request_close_with_account(account);
	purple_request_close_with_handle(gc);
	purple_notify_close_with_handle(gc);

	purple_debug_info("connection", "Destroying connection %p\n", gc);

	purple_account_set_connection(account, NULL);

	g_free(gc->password);
	g_free(gc->display_name);

	if (gc->disconnect_timeout > 0)
		purple_timeout_remove(gc->disconnect_timeout);

	PURPLE_DBUS_UNREGISTER_POINTER(gc);
	g_free(gc);
}