/*
 *  Copyright (C) 1997 Cullen Jennings
 *  Copyright (C) 1998 Elmer Joandiu, elmer@ylenurme.ee
 *  GNU General Public License applies
 * This module provides support for the Arlan 655 card made by Aironet
 */

#include "arlan.h"

#if BITS_PER_LONG != 32
#  error FIXME: this driver requires a 32-bit platform
#endif

static const char *arlan_version = "C.Jennigs 97 & Elmer.Joandi@ut.ee  Oct'98, http://www.ylenurme.ee/~elmer/655/";

struct net_device *arlan_device[MAX_ARLANS];

static int SID = SIDUNKNOWN;
static int radioNodeId = radioNodeIdUNKNOWN;
static char encryptionKey[12] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
int arlan_debug = debugUNKNOWN;
static int spreadingCode = spreadingCodeUNKNOWN;
static int channelNumber = channelNumberUNKNOWN;
static int channelSet = channelSetUNKNOWN;
static int systemId = systemIdUNKNOWN;
static int registrationMode = registrationModeUNKNOWN;
static int keyStart;
static int tx_delay_ms;
static int retries = 5;
static int tx_queue_len = 1;
static int arlan_EEPROM_bad;

#ifdef ARLAN_DEBUGGING

static int testMemory = testMemoryUNKNOWN;
static int irq = irqUNKNOWN;
static int txScrambled = 1;
static int mdebug;

module_param(irq, int, 0);
module_param(mdebug, int, 0);
module_param(testMemory, int, 0);
module_param(txScrambled, int, 0);
MODULE_PARM_DESC(irq, "(unused)");
MODULE_PARM_DESC(testMemory, "(unused)");
MODULE_PARM_DESC(mdebug, "Arlan multicast debugging (0-1)");
#endif

module_param_named(debug, arlan_debug, int, 0);
module_param(spreadingCode, int, 0);
module_param(channelNumber, int, 0);
module_param(channelSet, int, 0);
module_param(systemId, int, 0);
module_param(registrationMode, int, 0);
module_param(radioNodeId, int, 0);
module_param(SID, int, 0);
module_param(keyStart, int, 0);
module_param(tx_delay_ms, int, 0);
module_param(retries, int, 0);
module_param(tx_queue_len, int, 0);
module_param_named(EEPROM_bad, arlan_EEPROM_bad, int, 0);
MODULE_PARM_DESC(debug, "Arlan debug enable (0-1)");
MODULE_PARM_DESC(retries, "Arlan maximum packet retransmisions");
#ifdef ARLAN_ENTRY_EXIT_DEBUGGING
static int arlan_entry_debug;
static int arlan_exit_debug;
static int arlan_entry_and_exit_debug;
module_param_named(entry_debug, arlan_entry_debug, int, 0);
module_param_named(exit_debug, arlan_exit_debug, int, 0);
module_param_named(entry_and_exit_debug, arlan_entry_and_exit_debug, int, 0);
MODULE_PARM_DESC(entry_debug, "Arlan driver function entry debugging");
MODULE_PARM_DESC(exit_debug, "Arlan driver function exit debugging");
MODULE_PARM_DESC(entry_and_exit_debug, "Arlan driver function entry and exit debugging");
#endif

struct arlan_conf_stru arlan_conf[MAX_ARLANS];
static int arlans_found;

static  int 	arlan_open(struct net_device *dev);
static  int 	arlan_tx(struct sk_buff *skb, struct net_device *dev);
static  irqreturn_t arlan_interrupt(int irq, void *dev_id);
static  int 	arlan_close(struct net_device *dev);
static  struct net_device_stats *
		arlan_statistics		(struct net_device *dev);
static  void 	arlan_set_multicast		(struct net_device *dev);
static  int 	arlan_hw_tx			(struct net_device* dev, char *buf, int length );
static  int	arlan_hw_config			(struct net_device * dev);
static  void 	arlan_tx_done_interrupt		(struct net_device * dev, int status);
static  void	arlan_rx_interrupt		(struct net_device * dev, u_char rxStatus, u_short, u_short);
static  void	arlan_process_interrupt		(struct net_device * dev);
static	void	arlan_tx_timeout		(struct net_device *dev);

static inline long us2ticks(int us)
{
	return us * (1000000 / HZ);
}

#ifdef ARLAN_ENTRY_EXIT_DEBUGGING
#define ARLAN_DEBUG_ENTRY(name) \
	{\
	struct timeval timev;\
	do_gettimeofday(&timev);\
		if (arlan_entry_debug || arlan_entry_and_exit_debug)\
			printk("--->>>" name " %ld " "\n",((long int) timev.tv_sec * 1000000 + timev.tv_usec));\
	}
#define ARLAN_DEBUG_EXIT(name) \
	{\
	struct timeval timev;\
	do_gettimeofday(&timev);\
		if (arlan_exit_debug || arlan_entry_and_exit_debug)\
			printk("<<<---" name " %ld " "\n",((long int) timev.tv_sec * 1000000 + timev.tv_usec) );\
	}
#else
#define ARLAN_DEBUG_ENTRY(name)
#define ARLAN_DEBUG_EXIT(name)
#endif

#define arlan_interrupt_ack(dev)\
        clearClearInterrupt(dev);\
        setClearInterrupt(dev);

static inline int arlan_drop_tx(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	priv->stats.tx_errors++;
	if (priv->Conf->tx_delay_ms)
	{
		priv->tx_done_delayed = jiffies + priv->Conf->tx_delay_ms * HZ / 1000 + 1;
	}
	else
	{
		priv->waiting_command_mask &= ~ARLAN_COMMAND_TX;
		TXHEAD(dev).offset = 0;
		TXTAIL(dev).offset = 0;
		priv->txLast = 0;
		priv->bad = 0;
		if (!priv->under_reset && !priv->under_config)
			netif_wake_queue (dev);
	}
	return 1;
}

int arlan_command(struct net_device *dev, int command_p)
{
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	struct arlan_conf_stru *conf = priv->Conf;
	int udelayed = 0;
	int i = 0;
	unsigned long flags;

	ARLAN_DEBUG_ENTRY("arlan_command");

	if (priv->card_polling_interval)
		priv->card_polling_interval = 1;

	if (arlan_debug & ARLAN_DEBUG_CHAIN_LOCKS)
		printk(KERN_DEBUG "arlan_command, %lx commandByte %x waiting %lx incoming %x \n",
		jiffies, READSHMB(arlan->commandByte),
		       priv->waiting_command_mask, command_p);

	priv->waiting_command_mask |= command_p;

	if (priv->waiting_command_mask & ARLAN_COMMAND_RESET)
		if (time_after(jiffies, priv->lastReset + 5 * HZ))
			priv->waiting_command_mask &= ~ARLAN_COMMAND_RESET;

	if (priv->waiting_command_mask & ARLAN_COMMAND_INT_ACK)
	{
		arlan_interrupt_ack(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_INT_ACK;
	}
	if (priv->waiting_command_mask & ARLAN_COMMAND_INT_ENABLE)
	{
		setInterruptEnable(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_INT_ENABLE;
	}

	/* Card access serializing lock */
	spin_lock_irqsave(&priv->lock, flags);

	/* Check cards status and waiting */

	if (priv->waiting_command_mask & (ARLAN_COMMAND_LONG_WAIT_NOW | ARLAN_COMMAND_WAIT_NOW))
	{
		while (priv->waiting_command_mask & (ARLAN_COMMAND_LONG_WAIT_NOW | ARLAN_COMMAND_WAIT_NOW))
		{
			if (READSHMB(arlan->resetFlag) ||
				READSHMB(arlan->commandByte))	/* ||
								   (readControlRegister(dev) & ARLAN_ACCESS))
								 */
				udelay(40);
			else
				priv->waiting_command_mask &= ~(ARLAN_COMMAND_LONG_WAIT_NOW | ARLAN_COMMAND_WAIT_NOW);

			udelayed++;

			if (priv->waiting_command_mask & ARLAN_COMMAND_LONG_WAIT_NOW)
			{
				if (udelayed * 40 > 1000000)
				{
					printk(KERN_ERR "%s long wait too long \n", dev->name);
					priv->waiting_command_mask |= ARLAN_COMMAND_RESET;
					break;
				}
			}
			else if (priv->waiting_command_mask & ARLAN_COMMAND_WAIT_NOW)
			{
				if (udelayed * 40 > 1000)
				{
					printk(KERN_ERR "%s short wait too long \n", dev->name);
					goto bad_end;
				}
			}
		}
	}
	else
	{
		i = 0;
		while ((READSHMB(arlan->resetFlag) ||
			READSHMB(arlan->commandByte)) &&
			conf->pre_Command_Wait > (i++) * 10)
			udelay(10);

		if ((READSHMB(arlan->resetFlag) ||
			READSHMB(arlan->commandByte)) &&
			!(priv->waiting_command_mask & ARLAN_COMMAND_RESET))
		{
			goto card_busy_end;
		}
	}
	if (priv->waiting_command_mask & ARLAN_COMMAND_RESET)
		priv->under_reset = 1;
	if (priv->waiting_command_mask & ARLAN_COMMAND_CONF)
		priv->under_config = 1;

	/* Issuing command */
	arlan_lock_card_access(dev);
	if (priv->waiting_command_mask & ARLAN_COMMAND_POWERUP)
	{
	//     if (readControlRegister(dev) & (ARLAN_ACCESS && ARLAN_POWER))
		setPowerOn(dev);
		arlan_interrupt_lancpu(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_POWERUP;
		priv->waiting_command_mask |= ARLAN_COMMAND_RESET;
		priv->card_polling_interval = HZ / 10;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_ACTIVATE)
	{
		WRITESHMB(arlan->commandByte, ARLAN_COM_ACTIVATE);
		arlan_interrupt_lancpu(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_ACTIVATE;
		priv->card_polling_interval = HZ / 10;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_RX_ABORT)
	{
		if (priv->rx_command_given)
		{
			WRITESHMB(arlan->commandByte, ARLAN_COM_RX_ABORT);
			arlan_interrupt_lancpu(dev);
			priv->rx_command_given = 0;
		}
		priv->waiting_command_mask &= ~ARLAN_COMMAND_RX_ABORT;
		priv->card_polling_interval = 1;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_TX_ABORT)
	{
		if (priv->tx_command_given)
		{
			WRITESHMB(arlan->commandByte, ARLAN_COM_TX_ABORT);
			arlan_interrupt_lancpu(dev);
			priv->tx_command_given = 0;
		}
		priv->waiting_command_mask &= ~ARLAN_COMMAND_TX_ABORT;
		priv->card_polling_interval = 1;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_RESET)
	{
		priv->under_reset=1;
		netif_stop_queue (dev);

		arlan_drop_tx(dev);
		if (priv->tx_command_given || priv->rx_command_given)
		{
			printk(KERN_ERR "%s: Reset under tx or rx command \n", dev->name);
		}
		netif_stop_queue (dev);
		if (arlan_debug & ARLAN_DEBUG_RESET)
			printk(KERN_ERR "%s: Doing chip reset\n", dev->name);
		priv->lastReset = jiffies;
		WRITESHM(arlan->commandByte, 0, u_char);
		/* hold card in reset state */
		setHardwareReset(dev);
		/* set reset flag and then release reset */
		WRITESHM(arlan->resetFlag, 0xff, u_char);
		clearChannelAttention(dev);
		clearHardwareReset(dev);
		priv->card_polling_interval = HZ / 4;
		priv->waiting_command_mask &= ~ARLAN_COMMAND_RESET;
		priv->waiting_command_mask |= ARLAN_COMMAND_INT_RACK;
//		priv->waiting_command_mask |= ARLAN_COMMAND_INT_RENABLE;
//		priv->waiting_command_mask |= ARLAN_COMMAND_RX;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_INT_RACK)
	{
		clearHardwareReset(dev);
		clearClearInterrupt(dev);
		setClearInterrupt(dev);
		setInterruptEnable(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_INT_RACK;
		priv->waiting_command_mask |= ARLAN_COMMAND_CONF;
		priv->under_config = 1;
		priv->under_reset = 0;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_INT_RENABLE)
	{
		setInterruptEnable(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_INT_RENABLE;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_CONF)
	{
		if (priv->tx_command_given || priv->rx_command_given)
		{
			printk(KERN_ERR "%s: Reset under tx or rx command \n", dev->name);
		}
		arlan_drop_tx(dev);
		setInterruptEnable(dev);
		arlan_hw_config(dev);
		arlan_interrupt_lancpu(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_CONF;
		priv->card_polling_interval = HZ / 10;
//		priv->waiting_command_mask |= ARLAN_COMMAND_INT_RACK;
//		priv->waiting_command_mask |= ARLAN_COMMAND_INT_ENABLE;
		priv->waiting_command_mask |= ARLAN_COMMAND_CONF_WAIT;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_CONF_WAIT)
	{
		if (READSHMB(arlan->configuredStatusFlag) != 0 &&
			READSHMB(arlan->diagnosticInfo) == 0xff)
		{
			priv->waiting_command_mask &= ~ARLAN_COMMAND_CONF_WAIT;
			priv->waiting_command_mask |= ARLAN_COMMAND_RX;
			priv->waiting_command_mask |= ARLAN_COMMAND_TBUSY_CLEAR;
			priv->card_polling_interval = HZ / 10;
			priv->tx_command_given = 0;
			priv->under_config = 0;
		}
		else
		{
			priv->card_polling_interval = 1;
			if (arlan_debug & ARLAN_DEBUG_TIMING)
				printk(KERN_ERR "configure delayed \n");
		}
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_RX)
	{
		if (!registrationBad(dev))
		{
			setInterruptEnable(dev);
			memset_io(arlan->commandParameter, 0, 0xf);
			WRITESHMB(arlan->commandByte, ARLAN_COM_INT | ARLAN_COM_RX_ENABLE);
			WRITESHMB(arlan->commandParameter[0], conf->rxParameter);
			arlan_interrupt_lancpu(dev);
			priv->rx_command_given = 0; // mnjah, bad
			priv->waiting_command_mask &= ~ARLAN_COMMAND_RX;
			priv->card_polling_interval = 1;
		}
		else
			priv->card_polling_interval = 2;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_TBUSY_CLEAR)
	{
		if ( !registrationBad(dev) &&
		     (netif_queue_stopped(dev) || !netif_running(dev)) )
			{
				priv->waiting_command_mask &= ~ARLAN_COMMAND_TBUSY_CLEAR;
				netif_wake_queue (dev);
			}
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_TX)
	{
		if (!test_and_set_bit(0, (void *) &priv->tx_command_given))
		{
			if (time_after(jiffies,
				       priv->tx_last_sent + us2ticks(conf->rx_tweak1))
			    || time_before(jiffies,
					   priv->last_rx_int_ack_time + us2ticks(conf->rx_tweak2)))
			{
				setInterruptEnable(dev);
				memset_io(arlan->commandParameter, 0, 0xf);
				WRITESHMB(arlan->commandByte, ARLAN_COM_TX_ENABLE | ARLAN_COM_INT);
				memcpy_toio(arlan->commandParameter, &TXLAST(dev), 14);
//				for ( i=1 ; i < 15 ; i++) printk("%02x:",READSHMB(arlan->commandParameter[i]));
				priv->tx_last_sent = jiffies;
				arlan_interrupt_lancpu(dev);
				priv->tx_command_given = 1;
				priv->waiting_command_mask &= ~ARLAN_COMMAND_TX;
				priv->card_polling_interval = 1;
			}
			else
			{
				priv->tx_command_given = 0;
				priv->card_polling_interval = 1;
			}
		}
		else if (arlan_debug & ARLAN_DEBUG_CHAIN_LOCKS)
			printk(KERN_ERR "tx command when tx chain locked \n");
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_NOOPINT)
	{
		{
			WRITESHMB(arlan->commandByte, ARLAN_COM_NOP | ARLAN_COM_INT);
		}
		arlan_interrupt_lancpu(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_NOOPINT;
		priv->card_polling_interval = HZ / 3;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_NOOP)
	{
		WRITESHMB(arlan->commandByte, ARLAN_COM_NOP);
		arlan_interrupt_lancpu(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_NOOP;
		priv->card_polling_interval = HZ / 3;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_SLOW_POLL)
	{
		WRITESHMB(arlan->commandByte, ARLAN_COM_GOTO_SLOW_POLL);
		arlan_interrupt_lancpu(dev);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_SLOW_POLL;
		priv->card_polling_interval = HZ / 3;
	}
	else if (priv->waiting_command_mask & ARLAN_COMMAND_POWERDOWN)
	{
		setPowerOff(dev);
		if (arlan_debug & ARLAN_DEBUG_CARD_STATE)
			printk(KERN_WARNING "%s: Arlan Going Standby\n", dev->name);
		priv->waiting_command_mask &= ~ARLAN_COMMAND_POWERDOWN;
		priv->card_polling_interval = 3 * HZ;
	}
	arlan_unlock_card_access(dev);
	for (i = 0; READSHMB(arlan->commandByte) && i < 20; i++)
		udelay(10);
	if (READSHMB(arlan->commandByte))
		if (arlan_debug & ARLAN_DEBUG_CARD_STATE)
			printk(KERN_ERR "card busy leaving command %lx\n", priv->waiting_command_mask);

	spin_unlock_irqrestore(&priv->lock, flags);
	ARLAN_DEBUG_EXIT("arlan_command");
	priv->last_command_buff_free_time = jiffies;
	return 0;

card_busy_end:
	if (time_after(jiffies, priv->last_command_buff_free_time + HZ))
		priv->waiting_command_mask |= ARLAN_COMMAND_CLEAN_AND_RESET;

	if (arlan_debug & ARLAN_DEBUG_CARD_STATE)
		printk(KERN_ERR "%s arlan_command card busy end \n", dev->name);
	spin_unlock_irqrestore(&priv->lock, flags);
	ARLAN_DEBUG_EXIT("arlan_command");
	return 1;

bad_end:
	printk(KERN_ERR "%s arlan_command bad end \n", dev->name);

	spin_unlock_irqrestore(&priv->lock, flags);
	ARLAN_DEBUG_EXIT("arlan_command");

	return -1;
}

static inline void arlan_command_process(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	int times = 0;
	while (priv->waiting_command_mask && times < 8)
	{
		if (priv->waiting_command_mask)
		{
			if (arlan_command(dev, 0))
				break;
			times++;
		}
		/* if long command, we won't repeat trying */ ;
		if (priv->card_polling_interval > 1)
			break;
		times++;
	}
}

static inline void arlan_retransmit_now(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	ARLAN_DEBUG_ENTRY("arlan_retransmit_now");
	if (TXLAST(dev).offset == 0)
	{
		if (TXHEAD(dev).offset)
		{
			priv->txLast = 0;
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_DEBUG "TX buff switch to head \n");

		}
		else if (TXTAIL(dev).offset)
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_DEBUG "TX buff switch to tail \n");
			priv->txLast = 1;
		}
		else
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "ReTransmit buff empty");
		netif_wake_queue (dev);
		return;

	}
	arlan_command(dev, ARLAN_COMMAND_TX);

	priv->Conf->driverRetransmissions++;
	priv->retransmissions++;

	IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk("Retransmit %d bytes \n", TXLAST(dev).length);

	ARLAN_DEBUG_EXIT("arlan_retransmit_now");
}

static void arlan_registration_timer(unsigned long data)
{
	struct net_device *dev = (struct net_device *) data;
	struct arlan_private *priv = netdev_priv(dev);
	int bh_mark_needed = 0;
	int next_tick = 1;
	long lostTime = ((long)jiffies - (long)priv->registrationLastSeen)
			* (1000/HZ);

	if (registrationBad(dev))
	{
		priv->registrationLostCount++;
		if (lostTime > 7000 && lostTime < 7200)
		{
			printk(KERN_NOTICE "%s registration Lost \n", dev->name);
		}
		if (lostTime / priv->reRegisterExp > 2000)
			arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_CONF);
		if (lostTime / (priv->reRegisterExp) > 3500)
			arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET);
		if (priv->reRegisterExp < 400)
			priv->reRegisterExp += 2;
		if (lostTime > 7200)
		{
			next_tick = HZ;
			arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET);
		}
	}
	else
	{
		if (priv->Conf->registrationMode && lostTime > 10000 &&
			priv->registrationLostCount)
		{
			printk(KERN_NOTICE "%s registration is back after %ld milliseconds\n",
			       dev->name, lostTime);
		}
		priv->registrationLastSeen = jiffies;
		priv->registrationLostCount = 0;
		priv->reRegisterExp = 1;
		if (!netif_running(dev) )
			netif_wake_queue(dev);
		if (time_after(priv->tx_last_sent,priv->tx_last_cleared) &&
		    time_after(jiffies, priv->tx_last_sent * 5*HZ) ){
			arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET);
			priv->tx_last_cleared = jiffies;
		}
	}

	if (!registrationBad(dev) && priv->ReTransmitRequested)
	{
		IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
			printk(KERN_ERR "Retransmit from timer \n");
		priv->ReTransmitRequested = 0;
		arlan_retransmit_now(dev);
	}
	if (!registrationBad(dev) &&
		time_after(jiffies, priv->tx_done_delayed) &&
		priv->tx_done_delayed != 0)
	{
		TXLAST(dev).offset = 0;
		if (priv->txLast)
			priv->txLast = 0;
		else if (TXTAIL(dev).offset)
			priv->txLast = 1;
		if (TXLAST(dev).offset)
		{
			arlan_retransmit_now(dev);
			dev->trans_start = jiffies;
		}
		if (!(TXHEAD(dev).offset && TXTAIL(dev).offset))
		{
			netif_wake_queue (dev);
		}
		priv->tx_done_delayed = 0;
		bh_mark_needed = 1;
	}
	if (bh_mark_needed)
	{
		netif_wake_queue (dev);
	}
	arlan_process_interrupt(dev);

	if (next_tick < priv->card_polling_interval)
		next_tick = priv->card_polling_interval;

	priv->timer.expires = jiffies + next_tick;

	add_timer(&priv->timer);
}

#ifdef ARLAN_DEBUGGING

static void arlan_print_registers(struct net_device *dev, int line)
{
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem *arlan = priv->card;

	u_char hostcpuLock, lancpuLock, controlRegister, cntrlRegImage,
		txStatus, rxStatus, interruptInProgress, commandByte;

	ARLAN_DEBUG_ENTRY("arlan_print_registers");
	READSHM(interruptInProgress, arlan->interruptInProgress, u_char);
	READSHM(hostcpuLock, arlan->hostcpuLock, u_char);
	READSHM(lancpuLock, arlan->lancpuLock, u_char);
	READSHM(controlRegister, arlan->controlRegister, u_char);
	READSHM(cntrlRegImage, arlan->cntrlRegImage, u_char);
	READSHM(txStatus, arlan->txStatus, u_char);
	READSHM(rxStatus, arlan->rxStatus, u_char);
	READSHM(commandByte, arlan->commandByte, u_char);

	printk(KERN_WARNING "line %04d IP %02x HL %02x LL %02x CB %02x CR %02x CRI %02x TX %02x RX %02x\n",
		line, interruptInProgress, hostcpuLock, lancpuLock, commandByte,
		controlRegister, cntrlRegImage, txStatus, rxStatus);

	ARLAN_DEBUG_EXIT("arlan_print_registers");
}
#endif

static int arlan_hw_tx(struct net_device *dev, char *buf, int length)
{
	int i;

	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	struct arlan_conf_stru *conf = priv->Conf;

	int tailStarts = 0x800;
	int headEnds = 0x0;

	ARLAN_DEBUG_ENTRY("arlan_hw_tx");
	if (TXHEAD(dev).offset)
		headEnds = (((TXHEAD(dev).offset + TXHEAD(dev).length - offsetof(struct arlan_shmem, txBuffer)) / 64) + 1) * 64;
	if (TXTAIL(dev).offset)
		tailStarts = 0x800 - (((TXTAIL(dev).offset - offsetof(struct arlan_shmem, txBuffer)) / 64) + 2) * 64;

	if (!TXHEAD(dev).offset && length < tailStarts)
	{
		IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
			printk(KERN_ERR "TXHEAD insert, tailStart %d\n", tailStarts);

		TXHEAD(dev).offset =
			offsetof(struct arlan_shmem, txBuffer);
		TXHEAD(dev).length = length - ARLAN_FAKE_HDR_LEN;
		for (i = 0; i < 6; i++)
			TXHEAD(dev).dest[i] = buf[i];
		TXHEAD(dev).clear = conf->txClear;
		TXHEAD(dev).retries = conf->txRetries;	/* 0 is use default */
		TXHEAD(dev).routing = conf->txRouting;
		TXHEAD(dev).scrambled = conf->txScrambled;
		memcpy_toio((char __iomem *)arlan + TXHEAD(dev).offset, buf + ARLAN_FAKE_HDR_LEN, TXHEAD(dev).length);
	}
	else if (!TXTAIL(dev).offset && length < (0x800 - headEnds))
	{
		IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
			printk(KERN_ERR "TXTAIL insert, headEnd %d\n", headEnds);

		TXTAIL(dev).offset =
			offsetof(struct arlan_shmem, txBuffer) + 0x800 - (length / 64 + 2) * 64;
		TXTAIL(dev).length = length - ARLAN_FAKE_HDR_LEN;
		for (i = 0; i < 6; i++)
			TXTAIL(dev).dest[i] = buf[i];
		TXTAIL(dev).clear = conf->txClear;
		TXTAIL(dev).retries = conf->txRetries;
		TXTAIL(dev).routing = conf->txRouting;
		TXTAIL(dev).scrambled = conf->txScrambled;
		memcpy_toio(((char __iomem *)arlan + TXTAIL(dev).offset), buf + ARLAN_FAKE_HDR_LEN, TXTAIL(dev).length);
	}
	else
	{
		netif_stop_queue (dev);
		IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
			printk(KERN_ERR "TX TAIL & HEAD full, return, tailStart %d headEnd %d\n", tailStarts, headEnds);
		return -1;
	}
	priv->out_bytes += length;
	priv->out_bytes10 += length;
	if (conf->measure_rate < 1)
		conf->measure_rate = 1;
	if (time_after(jiffies, priv->out_time + conf->measure_rate * HZ))
	{
		conf->out_speed = priv->out_bytes / conf->measure_rate;
		priv->out_bytes = 0;
		priv->out_time = jiffies;
	}
	if (time_after(jiffies, priv->out_time10 + conf->measure_rate * 10*HZ))
	{
		conf->out_speed10 = priv->out_bytes10 / (10 * conf->measure_rate);
		priv->out_bytes10 = 0;
		priv->out_time10 = jiffies;
	}
	if (TXHEAD(dev).offset && TXTAIL(dev).offset)
	{
		netif_stop_queue (dev);
		return 0;
	}
	else
		netif_start_queue (dev);

	IFDEBUG(ARLAN_DEBUG_HEADER_DUMP)
		printk(KERN_WARNING "%s Transmit t %2x:%2x:%2x:%2x:%2x:%2x f %2x:%2x:%2x:%2x:%2x:%2x \n", dev->name,
		   (unsigned char) buf[0], (unsigned char) buf[1], (unsigned char) buf[2], (unsigned char) buf[3],
		   (unsigned char) buf[4], (unsigned char) buf[5], (unsigned char) buf[6], (unsigned char) buf[7],
		   (unsigned char) buf[8], (unsigned char) buf[9], (unsigned char) buf[10], (unsigned char) buf[11]);

	IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk(KERN_ERR "TX command prepare for buffer %d\n", priv->txLast);

	arlan_command(dev, ARLAN_COMMAND_TX);

	priv->tx_last_sent = jiffies;

	IFDEBUG(ARLAN_DEBUG_TX_CHAIN) printk("%s TX Qued %d bytes \n", dev->name, length);

	ARLAN_DEBUG_EXIT("arlan_hw_tx");

	return 0;
}

static int arlan_hw_config(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	struct arlan_conf_stru *conf = priv->Conf;

	ARLAN_DEBUG_ENTRY("arlan_hw_config");

	printk(KERN_NOTICE "%s arlan configure called \n", dev->name);
	if (arlan_EEPROM_bad)
		printk(KERN_NOTICE "arlan configure with eeprom bad option \n");

	WRITESHM(arlan->spreadingCode, conf->spreadingCode, u_char);
	WRITESHM(arlan->channelSet, conf->channelSet, u_char);

	if (arlan_EEPROM_bad)
		WRITESHM(arlan->defaultChannelSet, conf->channelSet, u_char);

	WRITESHM(arlan->channelNumber, conf->channelNumber, u_char);

	WRITESHM(arlan->scramblingDisable, conf->scramblingDisable, u_char);
	WRITESHM(arlan->txAttenuation, conf->txAttenuation, u_char);

	WRITESHM(arlan->systemId, conf->systemId, u_int);

	WRITESHM(arlan->maxRetries, conf->maxRetries, u_char);
	WRITESHM(arlan->receiveMode, conf->receiveMode, u_char);
	WRITESHM(arlan->priority, conf->priority, u_char);
	WRITESHM(arlan->rootOrRepeater, conf->rootOrRepeater, u_char);
	WRITESHM(arlan->SID, conf->SID, u_int);

	WRITESHM(arlan->registrationMode, conf->registrationMode, u_char);

	WRITESHM(arlan->registrationFill, conf->registrationFill, u_char);
	WRITESHM(arlan->localTalkAddress, conf->localTalkAddress, u_char);
	WRITESHM(arlan->codeFormat, conf->codeFormat, u_char);
	WRITESHM(arlan->numChannels, conf->numChannels, u_char);
	WRITESHM(arlan->channel1, conf->channel1, u_char);
	WRITESHM(arlan->channel2, conf->channel2, u_char);
	WRITESHM(arlan->channel3, conf->channel3, u_char);
	WRITESHM(arlan->channel4, conf->channel4, u_char);
	WRITESHM(arlan->radioNodeId, conf->radioNodeId, u_short);
	WRITESHM(arlan->SID, conf->SID, u_int);
	WRITESHM(arlan->waitTime, conf->waitTime, u_short);
	WRITESHM(arlan->lParameter, conf->lParameter, u_short);
	memcpy_toio(&(arlan->_15), &(conf->_15), 3);
	WRITESHM(arlan->_15, conf->_15, u_short);
	WRITESHM(arlan->headerSize, conf->headerSize, u_short);
	if (arlan_EEPROM_bad)
		WRITESHM(arlan->hardwareType, conf->hardwareType, u_char);
	WRITESHM(arlan->radioType, conf->radioType, u_char);
	if (arlan_EEPROM_bad)
		WRITESHM(arlan->radioModule, conf->radioType, u_char);

	memcpy_toio(arlan->encryptionKey + keyStart, encryptionKey, 8);
	memcpy_toio(arlan->name, conf->siteName, 16);

	WRITESHMB(arlan->commandByte, ARLAN_COM_INT | ARLAN_COM_CONF);	/* do configure */
	memset_io(arlan->commandParameter, 0, 0xf);	/* 0xf */
	memset_io(arlan->commandParameter + 1, 0, 2);
	if (conf->writeEEPROM)
	{
		  memset_io(arlan->commandParameter, conf->writeEEPROM, 1);
//		conf->writeEEPROM=0;
	}
	if (conf->registrationMode && conf->registrationInterrupts)
		memset_io(arlan->commandParameter + 3, 1, 1);
	else
		memset_io(arlan->commandParameter + 3, 0, 1);

	priv->irq_test_done = 0;

	if (conf->tx_queue_len)
		dev->tx_queue_len = conf->tx_queue_len;
	udelay(100);

	ARLAN_DEBUG_EXIT("arlan_hw_config");
	return 0;
}

static int arlan_read_card_configuration(struct net_device *dev)
{
	u_char tlx415;
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	struct arlan_conf_stru *conf = priv->Conf;

	ARLAN_DEBUG_ENTRY("arlan_read_card_configuration");

	if (radioNodeId == radioNodeIdUNKNOWN)
	{
		READSHM(conf->radioNodeId, arlan->radioNodeId, u_short);
	}
	else
		conf->radioNodeId = radioNodeId;

	if (SID == SIDUNKNOWN)
	{
		READSHM(conf->SID, arlan->SID, u_int);
	}
	else conf->SID = SID;

	if (spreadingCode == spreadingCodeUNKNOWN)
	{
		  READSHM(conf->spreadingCode, arlan->spreadingCode, u_char);
	}
	else
		conf->spreadingCode = spreadingCode;

	if (channelSet == channelSetUNKNOWN)
	{
		READSHM(conf->channelSet, arlan->channelSet, u_char);
	}
	else conf->channelSet = channelSet;

	if (channelNumber == channelNumberUNKNOWN)
	{
		READSHM(conf->channelNumber, arlan->channelNumber, u_char);
	}
	else conf->channelNumber = channelNumber;

	READSHM(conf->scramblingDisable, arlan->scramblingDisable, u_char);
	READSHM(conf->txAttenuation, arlan->txAttenuation, u_char);

	if (systemId == systemIdUNKNOWN)
	{
		READSHM(conf->systemId, arlan->systemId, u_int);
	}
	else conf->systemId = systemId;

	READSHM(conf->maxDatagramSize, arlan->maxDatagramSize, u_short);
	READSHM(conf->maxFrameSize, arlan->maxFrameSize, u_short);
	READSHM(conf->maxRetries, arlan->maxRetries, u_char);
	READSHM(conf->receiveMode, arlan->receiveMode, u_char);
	READSHM(conf->priority, arlan->priority, u_char);
	READSHM(conf->rootOrRepeater, arlan->rootOrRepeater, u_char);

	if (SID == SIDUNKNOWN)
	{
		  READSHM(conf->SID, arlan->SID, u_int);
	}
	else conf->SID = SID;

	if (registrationMode == registrationModeUNKNOWN)
	{
		  READSHM(conf->registrationMode, arlan->registrationMode, u_char);
	}
	else conf->registrationMode = registrationMode;

	READSHM(conf->registrationFill, arlan->registrationFill, u_char);
	READSHM(conf->localTalkAddress, arlan->localTalkAddress, u_char);
	READSHM(conf->codeFormat, arlan->codeFormat, u_char);
	READSHM(conf->numChannels, arlan->numChannels, u_char);
	READSHM(conf->channel1, arlan->channel1, u_char);
	READSHM(conf->channel2, arlan->channel2, u_char);
	READSHM(conf->channel3, arlan->channel3, u_char);
	READSHM(conf->channel4, arlan->channel4, u_char);
	READSHM(conf->waitTime, arlan->waitTime, u_short);
	READSHM(conf->lParameter, arlan->lParameter, u_short);
	READSHM(conf->_15, arlan->_15, u_short);
	READSHM(conf->headerSize, arlan->headerSize, u_short);
	READSHM(conf->hardwareType, arlan->hardwareType, u_char);
	READSHM(conf->radioType, arlan->radioModule, u_char);

	if (conf->radioType == 0)
		conf->radioType = 0xc;

	WRITESHM(arlan->configStatus, 0xA5, u_char);
	READSHM(tlx415, arlan->configStatus, u_char);

	if (tlx415 != 0xA5)
		printk(KERN_INFO "%s tlx415 chip \n", dev->name);

	conf->txClear = 0;
	conf->txRetries = 1;
	conf->txRouting = 1;
	conf->txScrambled = 0;
	conf->rxParameter = 1;
	conf->txTimeoutMs = 4000;
	conf->waitCardTimeout = 100000;
	conf->receiveMode = ARLAN_RCV_CLEAN;
	memcpy_fromio(conf->siteName, arlan->name, 16);
	conf->siteName[16] = '\0';
	conf->retries = retries;
	conf->tx_delay_ms = tx_delay_ms;
	conf->ReTransmitPacketMaxSize = 200;
	conf->waitReTransmitPacketMaxSize = 200;
	conf->txAckTimeoutMs = 900;
	conf->fastReTransCount = 3;

	ARLAN_DEBUG_EXIT("arlan_read_card_configuration");

	return 0;
}

static int lastFoundAt = 0xbe000;

/*
 * This is the real probe routine. Linux has a history of friendly device
 * probes on the ISA bus. A good device probes avoids doing writes, and
 * verifies that the correct device exists and functions.
 */
#define ARLAN_SHMEM_SIZE	0x2000
static int __init arlan_check_fingerprint(unsigned long memaddr)
{
	static const char probeText[] = "TELESYSTEM SLW INC.    ARLAN \0";
	volatile struct arlan_shmem __iomem *arlan = (struct arlan_shmem *) memaddr;
	unsigned long paddr = virt_to_phys((void *) memaddr);
	char tempBuf[49];

	ARLAN_DEBUG_ENTRY("arlan_check_fingerprint");

	if (!request_mem_region(paddr, ARLAN_SHMEM_SIZE, "arlan")) {
		// printk(KERN_WARNING "arlan: memory region %lx excluded from probing \n",paddr);
		return -ENODEV;
	}

	memcpy_fromio(tempBuf, arlan->textRegion, 29);
	tempBuf[30] = 0;

	/* check for card at this address */
	if (0 != strncmp(tempBuf, probeText, 29)){
 		release_mem_region(paddr, ARLAN_SHMEM_SIZE);
		return -ENODEV;
	}

//   printk(KERN_INFO "arlan found at 0x%x \n",memaddr);
	ARLAN_DEBUG_EXIT("arlan_check_fingerprint");

	return 0;
}

static int arlan_change_mtu(struct net_device *dev, int new_mtu)
{
	struct arlan_private *priv = netdev_priv(dev);
	struct arlan_conf_stru *conf = priv->Conf;

	ARLAN_DEBUG_ENTRY("arlan_change_mtu");
	if (new_mtu > 2032)
		return -EINVAL;
	dev->mtu = new_mtu;
	if (new_mtu < 256)
		new_mtu = 256;	/* cards book suggests 1600 */
	conf->maxDatagramSize = new_mtu;
	conf->maxFrameSize = new_mtu + 48;

	arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_CONF);
	printk(KERN_NOTICE "%s mtu changed to %d \n", dev->name, new_mtu);

	ARLAN_DEBUG_EXIT("arlan_change_mtu");

	return 0;
}

static int arlan_mac_addr(struct net_device *dev, void *p)
{
	struct sockaddr *addr = p;

	ARLAN_DEBUG_ENTRY("arlan_mac_addr");
	return -EINVAL;

	if (!netif_running(dev))
		return -EBUSY;
	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);

	ARLAN_DEBUG_EXIT("arlan_mac_addr");
	return 0;
}

static int __init arlan_setup_device(struct net_device *dev, int num)
{
	struct arlan_private *ap = netdev_priv(dev);
	int err;

	ARLAN_DEBUG_ENTRY("arlan_setup_device");

	ap->conf = (struct arlan_shmem *)(ap+1);

	dev->tx_queue_len = tx_queue_len;
	dev->open = arlan_open;
	dev->stop = arlan_close;
	dev->hard_start_xmit = arlan_tx;
	dev->get_stats = arlan_statistics;
	dev->set_multicast_list = arlan_set_multicast;
	dev->change_mtu = arlan_change_mtu;
	dev->set_mac_address = arlan_mac_addr;
	dev->tx_timeout = arlan_tx_timeout;
	dev->watchdog_timeo = 3*HZ;

	ap->irq_test_done = 0;
	ap->Conf = &arlan_conf[num];

	ap->Conf->pre_Command_Wait = 40;
	ap->Conf->rx_tweak1 = 30;
	ap->Conf->rx_tweak2 = 0;

	err = register_netdev(dev);
	if (err) {
		release_mem_region(virt_to_phys((void *) dev->mem_start),
			   ARLAN_SHMEM_SIZE);
		free_netdev(dev);
		return err;
	}
	arlan_device[num] = dev;
	ARLAN_DEBUG_EXIT("arlan_setup_device");
	return 0;
}

static int __init arlan_probe_here(struct net_device *dev,
				   unsigned long memaddr)
{
	struct arlan_private *ap = netdev_priv(dev);

	ARLAN_DEBUG_ENTRY("arlan_probe_here");

	if (arlan_check_fingerprint(memaddr))
		return -ENODEV;

	printk(KERN_NOTICE "%s: Arlan found at %x, \n ", dev->name,
	       (int) virt_to_phys((void*)memaddr));

	ap->card = (void *) memaddr;
	dev->mem_start = memaddr;
	dev->mem_end = memaddr + ARLAN_SHMEM_SIZE-1;

	if (dev->irq < 2)
	{
		READSHM(dev->irq, ap->card->irqLevel, u_char);
	} else if (dev->irq == 2)
		dev->irq = 9;

	arlan_read_card_configuration(dev);

	ARLAN_DEBUG_EXIT("arlan_probe_here");
	return 0;
}

static int arlan_open(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	int ret = 0;

	ARLAN_DEBUG_ENTRY("arlan_open");

	ret = request_irq(dev->irq, &arlan_interrupt, 0, dev->name, dev);
	if (ret)
	{
		printk(KERN_ERR "%s: unable to get IRQ %d .\n",
			dev->name, dev->irq);
		return ret;
	}

	priv->bad = 0;
	priv->lastReset = 0;
	priv->reset = 0;
	memcpy_fromio(dev->dev_addr, arlan->lanCardNodeId, 6);
	memset(dev->broadcast, 0xff, 6);
	dev->tx_queue_len = tx_queue_len;
	priv->interrupt_processing_active = 0;
	spin_lock_init(&priv->lock);

	netif_start_queue (dev);

	priv->registrationLostCount = 0;
	priv->registrationLastSeen = jiffies;
	priv->txLast = 0;
	priv->tx_command_given = 0;
	priv->rx_command_given = 0;

	priv->reRegisterExp = 1;
	priv->tx_last_sent = jiffies - 1;
	priv->tx_last_cleared = jiffies;
	priv->Conf->writeEEPROM = 0;
	priv->Conf->registrationInterrupts = 1;

	init_timer(&priv->timer);
	priv->timer.expires = jiffies + HZ / 10;
	priv->timer.data = (unsigned long) dev;
	priv->timer.function = &arlan_registration_timer;	/* timer handler */

	arlan_command(dev, ARLAN_COMMAND_POWERUP | ARLAN_COMMAND_LONG_WAIT_NOW);
	mdelay(200);
	add_timer(&priv->timer);

	ARLAN_DEBUG_EXIT("arlan_open");
	return 0;
}

static void arlan_tx_timeout (struct net_device *dev)
{
	printk(KERN_ERR "%s: arlan transmit timed out, kernel decided\n", dev->name);
	/* Try to restart the adaptor. */
	arlan_command(dev, ARLAN_COMMAND_CLEAN_AND_RESET);
	// dev->trans_start = jiffies;
	// netif_start_queue (dev);
}

static int arlan_tx(struct sk_buff *skb, struct net_device *dev)
{
	short length;
	unsigned char *buf;

	ARLAN_DEBUG_ENTRY("arlan_tx");

	length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN;
	buf = skb->data;

	if (length + 0x12 > 0x800) {
		printk(KERN_ERR "TX RING overflow \n");
		netif_stop_queue (dev);
	}

	if (arlan_hw_tx(dev, buf, length) == -1)
		goto bad_end;

	dev->trans_start = jiffies;

	dev_kfree_skb(skb);

	arlan_process_interrupt(dev);
	ARLAN_DEBUG_EXIT("arlan_tx");
	return 0;

bad_end:
	arlan_process_interrupt(dev);
	netif_stop_queue (dev);
	ARLAN_DEBUG_EXIT("arlan_tx");
	return 1;
}

static inline int DoNotReTransmitCrap(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	if (TXLAST(dev).length < priv->Conf->ReTransmitPacketMaxSize)
		return 1;
	return 0;

}

static inline int DoNotWaitReTransmitCrap(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	if (TXLAST(dev).length < priv->Conf->waitReTransmitPacketMaxSize)
		return 1;
	return 0;
}

static inline void arlan_queue_retransmit(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	ARLAN_DEBUG_ENTRY("arlan_queue_retransmit");

	if (DoNotWaitReTransmitCrap(dev))
	{
		  arlan_drop_tx(dev);
	} else
		priv->ReTransmitRequested++;

	ARLAN_DEBUG_EXIT("arlan_queue_retransmit");
}

static inline void RetryOrFail(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	ARLAN_DEBUG_ENTRY("RetryOrFail");

	if (priv->retransmissions > priv->Conf->retries ||
	    DoNotReTransmitCrap(dev))
	{
		arlan_drop_tx(dev);
	}
	else if (priv->bad <= priv->Conf->fastReTransCount)
	{
		arlan_retransmit_now(dev);
	}
	else arlan_queue_retransmit(dev);

	ARLAN_DEBUG_EXIT("RetryOrFail");
}

static void arlan_tx_done_interrupt(struct net_device *dev, int status)
{
	struct arlan_private *priv = netdev_priv(dev);

	ARLAN_DEBUG_ENTRY("arlan_tx_done_interrupt");

	priv->tx_last_cleared = jiffies;
	priv->tx_command_given = 0;
	switch (status)
	{
		case 1:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit OK\n");
			priv->stats.tx_packets++;
			priv->bad = 0;
			priv->reset = 0;
			priv->retransmissions = 0;
			if (priv->Conf->tx_delay_ms)
			{
				priv->tx_done_delayed = jiffies + (priv->Conf->tx_delay_ms * HZ) / 1000 + 1;
			}
			else
			{
				TXLAST(dev).offset = 0;
				if (priv->txLast)
					priv->txLast = 0;
				else if (TXTAIL(dev).offset)
					priv->txLast = 1;
				if (TXLAST(dev).offset)
				{
					arlan_retransmit_now(dev);
					dev->trans_start = jiffies;
				}
				if (!TXHEAD(dev).offset || !TXTAIL(dev).offset)
				{
					netif_wake_queue (dev);
				}
			}
		}
		break;

		case 2:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit timed out\n");
			priv->bad += 1;
			//arlan_queue_retransmit(dev);
			RetryOrFail(dev);
		}
		break;

		case 3:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit max retries\n");
			priv->bad += 1;
			priv->reset = 0;
			//arlan_queue_retransmit(dev);
			RetryOrFail(dev);
		}
		break;

		case 4:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit aborted\n");
			priv->bad += 1;
			arlan_queue_retransmit(dev);
			//RetryOrFail(dev);
		}
		break;

		case 5:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit not registered\n");
			priv->bad += 1;
			//debug=101;
			arlan_queue_retransmit(dev);
		}
		break;

		case 6:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit destination full\n");
			priv->bad += 1;
			priv->reset = 0;
			//arlan_drop_tx(dev);
			arlan_queue_retransmit(dev);
		}
		break;

		case 7:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit unknown ack\n");
			priv->bad += 1;
			priv->reset = 0;
			arlan_queue_retransmit(dev);
		}
		break;

		case 8:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit dest mail box full\n");
			priv->bad += 1;
			priv->reset = 0;
			//arlan_drop_tx(dev);
			arlan_queue_retransmit(dev);
		}
		break;

		case 9:
		{
			IFDEBUG(ARLAN_DEBUG_TX_CHAIN)
				printk("arlan intr: transmit root dest not reg.\n");
			priv->bad += 1;
			priv->reset = 1;
			//arlan_drop_tx(dev);
			arlan_queue_retransmit(dev);
		}
		break;

		default:
		{
			printk(KERN_ERR "arlan intr: transmit status unknown\n");
			priv->bad += 1;
			priv->reset = 1;
			arlan_drop_tx(dev);
		}
	}

	ARLAN_DEBUG_EXIT("arlan_tx_done_interrupt");
}

static void arlan_rx_interrupt(struct net_device *dev, u_char rxStatus, u_short rxOffset, u_short pkt_len)
{
	char *skbtmp;
	int i = 0;

	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	struct arlan_conf_stru *conf = priv->Conf;

	ARLAN_DEBUG_ENTRY("arlan_rx_interrupt");
	// by spec,   not                WRITESHMB(arlan->rxStatus,0x00);
	// prohibited here              arlan_command(dev, ARLAN_COMMAND_RX);

	if (pkt_len < 10 || pkt_len > 2048)
	{
		printk(KERN_WARNING "%s: got too short or long packet, len %d \n", dev->name, pkt_len);
		return;
	}
	if (rxOffset + pkt_len > 0x2000)
	{
		printk("%s: got too long packet, len %d offset %x\n", dev->name, pkt_len, rxOffset);
		return;
	}
	priv->in_bytes += pkt_len;
	priv->in_bytes10 += pkt_len;
	if (conf->measure_rate < 1)
		conf->measure_rate = 1;
	if (time_after(jiffies, priv->in_time + conf->measure_rate * HZ))
	{
		conf->in_speed = priv->in_bytes / conf->measure_rate;
		priv->in_bytes = 0;
		priv->in_time = jiffies;
	}
	if (time_after(jiffies, priv->in_time10 + conf->measure_rate * 10*HZ))
	{
		conf->in_speed10 = priv->in_bytes10 / (10 * conf->measure_rate);
		priv->in_bytes10 = 0;
		priv->in_time10 = jiffies;
	}
	DEBUGSHM(1, "arlan rcv pkt rxStatus= %d ", arlan->rxStatus, u_char);
	switch (rxStatus)
	{
		case 1:
		case 2:
		case 3:
		{
			/* Malloc up new buffer. */
			struct sk_buff *skb;

			DEBUGSHM(50, "arlan recv pkt offs=%d\n", arlan->rxOffset, u_short);
			DEBUGSHM(1, "arlan rxFrmType = %d \n", arlan->rxFrmType, u_char);
			DEBUGSHM(1, KERN_INFO "arlan rx scrambled = %d \n", arlan->scrambled, u_char);

			/* here we do multicast filtering to avoid slow 8-bit memcopy */
#ifdef ARLAN_MULTICAST
			if (!(dev->flags & IFF_ALLMULTI) &&
				!(dev->flags & IFF_PROMISC) &&
				dev->mc_list)
			{
				char hw_dst_addr[6];
				struct dev_mc_list *dmi = dev->mc_list;
				int i;

				memcpy_fromio(hw_dst_addr, arlan->ultimateDestAddress, 6);
				if (hw_dst_addr[0] == 0x01)
				{
					if (mdebug)
						if (hw_dst_addr[1] == 0x00)
							printk(KERN_ERR "%s mcast 0x0100 \n", dev->name);
						else if (hw_dst_addr[1] == 0x40)
							printk(KERN_ERR "%s m/bcast 0x0140 \n", dev->name);
					while (dmi)
					{							if (dmi->dmi_addrlen == 6)
						{
							if (arlan_debug & ARLAN_DEBUG_HEADER_DUMP)
								printk(KERN_ERR "%s mcl %2x:%2x:%2x:%2x:%2x:%2x \n", dev->name,
										 dmi->dmi_addr[0], dmi->dmi_addr[1], dmi->dmi_addr[2],
										 dmi->dmi_addr[3], dmi->dmi_addr[4], dmi->dmi_addr[5]);
							for (i = 0; i < 6; i++)
								if (dmi->dmi_addr[i] != hw_dst_addr[i])
									break;
							if (i == 6)
								break;
						}
						else
							printk(KERN_ERR "%s: invalid multicast address length given.\n", dev->name);
						dmi = dmi->next;
					}
					/* we reach here if multicast filtering is on and packet
					 * is multicast and not for receive */
					goto end_of_interrupt;
				}
			}
#endif				// ARLAN_MULTICAST
			/* multicast filtering ends here */
			pkt_len += ARLAN_FAKE_HDR_LEN;

			skb = dev_alloc_skb(pkt_len + 4);
			if (skb == NULL)
			{
				printk(KERN_ERR "%s: Memory squeeze, dropping packet.\n", dev->name);
				priv->stats.rx_dropped++;
				break;
			}
			skb_reserve(skb, 2);
			skbtmp = skb_put(skb, pkt_len);

			memcpy_fromio(skbtmp + ARLAN_FAKE_HDR_LEN, ((char __iomem *) arlan) + rxOffset, pkt_len - ARLAN_FAKE_HDR_LEN);
			memcpy_fromio(skbtmp, arlan->ultimateDestAddress, 6);
			memcpy_fromio(skbtmp + 6, arlan->rxSrc, 6);
			WRITESHMB(arlan->rxStatus, 0x00);
			arlan_command(dev, ARLAN_COMMAND_RX);

			IFDEBUG(ARLAN_DEBUG_HEADER_DUMP)
			{
				char immedDestAddress[6];
				char immedSrcAddress[6];
				memcpy_fromio(immedDestAddress, arlan->immedDestAddress, 6);
				memcpy_fromio(immedSrcAddress, arlan->immedSrcAddress, 6);

				printk(KERN_WARNING "%s t %2x:%2x:%2x:%2x:%2x:%2x f %2x:%2x:%2x:%2x:%2x:%2x imd %2x:%2x:%2x:%2x:%2x:%2x ims %2x:%2x:%2x:%2x:%2x:%2x\n", dev->name,
					(unsigned char) skbtmp[0], (unsigned char) skbtmp[1], (unsigned char) skbtmp[2], (unsigned char) skbtmp[3],
					(unsigned char) skbtmp[4], (unsigned char) skbtmp[5], (unsigned char) skbtmp[6], (unsigned char) skbtmp[7],
					(unsigned char) skbtmp[8], (unsigned char) skbtmp[9], (unsigned char) skbtmp[10], (unsigned char) skbtmp[11],
					immedDestAddress[0], immedDestAddress[1], immedDestAddress[2],
					immedDestAddress[3], immedDestAddress[4], immedDestAddress[5],
					immedSrcAddress[0], immedSrcAddress[1], immedSrcAddress[2],
					immedSrcAddress[3], immedSrcAddress[4], immedSrcAddress[5]);
			}
			skb->protocol = eth_type_trans(skb, dev);
			IFDEBUG(ARLAN_DEBUG_HEADER_DUMP)
				if (skb->protocol != 0x608 && skb->protocol != 0x8)
				{
					for (i = 0; i <= 22; i++)
						printk("%02x:", (u_char) skbtmp[i + 12]);
					printk(KERN_ERR "\n");
					printk(KERN_WARNING "arlan kernel pkt type trans %x \n", skb->protocol);
				}
			netif_rx(skb);
			dev->last_rx = jiffies;
			priv->stats.rx_packets++;
			priv->stats.rx_bytes += pkt_len;
		}
		break;

		default:
			printk(KERN_ERR "arlan intr: received unknown status\n");
			priv->stats.rx_crc_errors++;
			break;
	}
	ARLAN_DEBUG_EXIT("arlan_rx_interrupt");
}

static void arlan_process_interrupt(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	u_char rxStatus = READSHMB(arlan->rxStatus);
	u_char txStatus = READSHMB(arlan->txStatus);
	u_short rxOffset = READSHMS(arlan->rxOffset);
	u_short pkt_len = READSHMS(arlan->rxLength);
	int interrupt_count = 0;

	ARLAN_DEBUG_ENTRY("arlan_process_interrupt");

	if (test_and_set_bit(0, (void *) &priv->interrupt_processing_active))
	{
		if (arlan_debug & ARLAN_DEBUG_CHAIN_LOCKS)
			printk(KERN_ERR "interrupt chain reentering \n");
		goto end_int_process;
	}
	while ((rxStatus || txStatus || priv->interrupt_ack_requested)
			&& (interrupt_count < 5))
	{
		if (rxStatus)
			priv->last_rx_int_ack_time = jiffies;

		arlan_command(dev, ARLAN_COMMAND_INT_ACK);
		arlan_command(dev, ARLAN_COMMAND_INT_ENABLE);

		IFDEBUG(ARLAN_DEBUG_INTERRUPT)
			printk(KERN_ERR "%s:  got IRQ rx %x tx %x comm %x rxOff %x rxLen %x \n",
					dev->name, rxStatus, txStatus, READSHMB(arlan->commandByte),
					rxOffset, pkt_len);

		if (rxStatus == 0 && txStatus == 0)
		{
			if (priv->irq_test_done)
			{
				if (!registrationBad(dev))
					IFDEBUG(ARLAN_DEBUG_INTERRUPT) printk(KERN_ERR "%s unknown interrupt(nop? regLost ?) reason tx %d rx %d ",
										    dev->name, txStatus, rxStatus);
			} else {
				IFDEBUG(ARLAN_DEBUG_INTERRUPT)
					printk(KERN_INFO "%s irq $%d test OK \n", dev->name, dev->irq);

			}
			priv->interrupt_ack_requested = 0;
			goto ends;
		}
		if (txStatus != 0)
		{
			WRITESHMB(arlan->txStatus, 0x00);
			arlan_tx_done_interrupt(dev, txStatus);
			goto ends;
		}
		if (rxStatus == 1 || rxStatus == 2)
		{		/* a packet waiting */
			arlan_rx_interrupt(dev, rxStatus, rxOffset, pkt_len);
			goto ends;
		}
		if (rxStatus > 2 && rxStatus < 0xff)
		{
			WRITESHMB(arlan->rxStatus, 0x00);
			printk(KERN_ERR "%s unknown rxStatus reason tx %d rx %d ",
				dev->name, txStatus, rxStatus);
			goto ends;
		}
		if (rxStatus == 0xff)
		{
			WRITESHMB(arlan->rxStatus, 0x00);
			arlan_command(dev, ARLAN_COMMAND_RX);
			if (registrationBad(dev))
				netif_device_detach(dev);
			if (!registrationBad(dev))
			{
				priv->registrationLastSeen = jiffies;
				if (!netif_queue_stopped(dev) && !priv->under_reset && !priv->under_config)
					netif_wake_queue (dev);
			}
			goto ends;
		}
ends:

		arlan_command_process(dev);

		rxStatus = READSHMB(arlan->rxStatus);
		txStatus = READSHMB(arlan->txStatus);
		rxOffset = READSHMS(arlan->rxOffset);
		pkt_len = READSHMS(arlan->rxLength);

		priv->irq_test_done = 1;

		interrupt_count++;
	}
	priv->interrupt_processing_active = 0;

end_int_process:
	arlan_command_process(dev);

	ARLAN_DEBUG_EXIT("arlan_process_interrupt");
	return;
}

static irqreturn_t arlan_interrupt(int irq, void *dev_id)
{
	struct net_device *dev = dev_id;
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	u_char rxStatus = READSHMB(arlan->rxStatus);
	u_char txStatus = READSHMB(arlan->txStatus);

	ARLAN_DEBUG_ENTRY("arlan_interrupt");

	if (!rxStatus && !txStatus)
		priv->interrupt_ack_requested++;

	arlan_process_interrupt(dev);

	priv->irq_test_done = 1;

	ARLAN_DEBUG_EXIT("arlan_interrupt");
	return IRQ_HANDLED;

}

static int arlan_close(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);

	ARLAN_DEBUG_ENTRY("arlan_close");

	del_timer_sync(&priv->timer);

	arlan_command(dev, ARLAN_COMMAND_POWERDOWN);

	IFDEBUG(ARLAN_DEBUG_STARTUP)
		printk(KERN_NOTICE "%s: Closing device\n", dev->name);

	netif_stop_queue(dev);
	free_irq(dev->irq, dev);

	ARLAN_DEBUG_EXIT("arlan_close");
	return 0;
}

#ifdef ARLAN_DEBUGGING
static long alignLong(volatile u_char * ptr)
{
	long ret;
	memcpy_fromio(&ret, (void *) ptr, 4);
	return ret;
}
#endif

/*
 * Get the current statistics.
 * This may be called with the card open or closed.
 */

static struct net_device_stats *arlan_statistics(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;

	ARLAN_DEBUG_ENTRY("arlan_statistics");

	/* Update the statistics from the device registers. */

	READSHM(priv->stats.collisions, arlan->numReTransmissions, u_int);
	READSHM(priv->stats.rx_crc_errors, arlan->numCRCErrors, u_int);
	READSHM(priv->stats.rx_dropped, arlan->numFramesDiscarded, u_int);
	READSHM(priv->stats.rx_fifo_errors, arlan->numRXBufferOverflows, u_int);
	READSHM(priv->stats.rx_frame_errors, arlan->numReceiveFramesLost, u_int);
	READSHM(priv->stats.rx_over_errors, arlan->numRXOverruns, u_int);
	READSHM(priv->stats.rx_packets, arlan->numDatagramsReceived, u_int);
	READSHM(priv->stats.tx_aborted_errors, arlan->numAbortErrors, u_int);
	READSHM(priv->stats.tx_carrier_errors, arlan->numStatusTimeouts, u_int);
	READSHM(priv->stats.tx_dropped, arlan->numDatagramsDiscarded, u_int);
	READSHM(priv->stats.tx_fifo_errors, arlan->numTXUnderruns, u_int);
	READSHM(priv->stats.tx_packets, arlan->numDatagramsTransmitted, u_int);
	READSHM(priv->stats.tx_window_errors, arlan->numHoldOffs, u_int);

	ARLAN_DEBUG_EXIT("arlan_statistics");

	return &priv->stats;
}

static void arlan_set_multicast(struct net_device *dev)
{
	struct arlan_private *priv = netdev_priv(dev);
	volatile struct arlan_shmem __iomem *arlan = priv->card;
	struct arlan_conf_stru *conf = priv->Conf;
	int board_conf_needed = 0;

	ARLAN_DEBUG_ENTRY("arlan_set_multicast");

	if (dev->flags & IFF_PROMISC)
	{
		unsigned char recMode;
		READSHM(recMode, arlan->receiveMode, u_char);
		conf->receiveMode = (ARLAN_RCV_PROMISC | ARLAN_RCV_CONTROL);
		if (conf->receiveMode != recMode)
			board_conf_needed = 1;
	}
	else
	{
		/* turn off promiscuous mode  */
		unsigned char recMode;
		READSHM(recMode, arlan->receiveMode, u_char);
		conf->receiveMode = ARLAN_RCV_CLEAN | ARLAN_RCV_CONTROL;
		if (conf->receiveMode != recMode)
			board_conf_needed = 1;
	}
	if (board_conf_needed)
		arlan_command(dev, ARLAN_COMMAND_CONF);

	ARLAN_DEBUG_EXIT("arlan_set_multicast");
}

struct net_device * __init arlan_probe(int unit)
{
	struct net_device *dev;
	int err;
	int m;

	ARLAN_DEBUG_ENTRY("arlan_probe");

	if (arlans_found == MAX_ARLANS)
		return ERR_PTR(-ENODEV);

	/*
	 * Reserve space for local data and a copy of the shared memory
	 * that is used by the /proc interface.
	 */
	dev = alloc_etherdev(sizeof(struct arlan_private)
			     + sizeof(struct arlan_shmem));
	if (!dev)
		return ERR_PTR(-ENOMEM);

	SET_MODULE_OWNER(dev);

	if (unit >= 0) {
		sprintf(dev->name, "eth%d", unit);
		netdev_boot_setup_check(dev);

		if (dev->mem_start) {
			if (arlan_probe_here(dev, dev->mem_start) == 0)
				goto found;
			goto not_found;
		}

	}

	for (m = (int)phys_to_virt(lastFoundAt) + ARLAN_SHMEM_SIZE;
	     m <= (int)phys_to_virt(0xDE000);
	     m += ARLAN_SHMEM_SIZE)
	{
		if (arlan_probe_here(dev, m) == 0)
		{
			lastFoundAt = (int)virt_to_phys((void*)m);
			goto found;
		}
	}

	if (lastFoundAt == 0xbe000)
		printk(KERN_ERR "arlan: No Arlan devices found \n");

 not_found:
	free_netdev(dev);
	return ERR_PTR(-ENODEV);

 found:
	err = arlan_setup_device(dev, arlans_found);
	if (err)
		dev = ERR_PTR(err);
	else if (!arlans_found++)
		printk(KERN_INFO "Arlan driver %s\n", arlan_version);

	return dev;
}

#ifdef  MODULE
int __init init_module(void)
{
	int i = 0;

	ARLAN_DEBUG_ENTRY("init_module");

	if (channelSet != channelSetUNKNOWN || channelNumber != channelNumberUNKNOWN || systemId != systemIdUNKNOWN)
		return -EINVAL;

	for (i = 0; i < MAX_ARLANS; i++) {
		struct net_device *dev = arlan_probe(i);

		if (IS_ERR(dev))
			return PTR_ERR(dev);
	}
	init_arlan_proc();
	printk(KERN_INFO "Arlan driver %s\n", arlan_version);
	ARLAN_DEBUG_EXIT("init_module");
	return 0;
}

void __exit cleanup_module(void)
{
	int i = 0;
	struct net_device *dev;

	ARLAN_DEBUG_ENTRY("cleanup_module");

	IFDEBUG(ARLAN_DEBUG_SHUTDOWN)
		printk(KERN_INFO "arlan: unloading module\n");

	cleanup_arlan_proc();

	for (i = 0; i < MAX_ARLANS; i++)
	{
		dev = arlan_device[i];
		if (dev) {
			arlan_command(dev, ARLAN_COMMAND_POWERDOWN );

			unregister_netdev(dev);
			release_mem_region(virt_to_phys((void *) dev->mem_start),
					   ARLAN_SHMEM_SIZE);
			free_netdev(dev);
			arlan_device[i] = NULL;
		}
	}

	ARLAN_DEBUG_EXIT("cleanup_module");
}

#endif
MODULE_LICENSE("GPL");


#!/bin/bash

wget https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.zip --quiet -O spec/dynamodb_temp.zip
unzip -qq spec/dynamodb_temp.zip -d spec/DynamoDBLocal-latest
rm spec/dynamodb_temp.zip


<?php

namespace Illuminate\Auth\Access;

trait HandlesAuthorization
{
    /**
     * Create a new access response.
     *
     * @param  string|null  $message
     * @return \Illuminate\Auth\Access\Response
     */
    protected function allow($message = null)
    {
        return new Response($message);
    }

    /**
     * Throws an unauthorized exception.
     *
     * @param  string  $message
     * @return void
     *
     * @throws \Illuminate\Auth\Access\AuthorizationException
     */
    protected function deny($message = 'This action is unauthorized.')
    {
        throw new AuthorizationException($message);
    }
}


package com.tmall.pokemon.bulbasaur.service;

import java.util.Collection;
import java.util.concurrent.atomic.AtomicLong;

import com.tmall.pokemon.bulbasaur.JUnit4ClassRunner;
import com.tmall.pokemon.bulbasaur.persist.domain.InvokeResult;
import com.tmall.pokemon.bulbasaur.persist.domain.QueryResult;
import com.tmall.pokemon.bulbasaur.persist.domain.TaskDO;
import com.tmall.pokemon.bulbasaur.schedule.ScheduleMachine;
import com.tmall.pokemon.bulbasaur.schedule.ScheduleMachineFactory;
import com.tmall.pokemon.bulbasaur.task.constant.TaskConstant;
import com.tmall.pokemon.bulbasaur.task.constant.TaskStatusEnum;
import com.tmall.pokemon.bulbasaur.task.dto.TaskQuery;
import com.tmall.pokemon.bulbasaur.task.model.TaskBizInfo;
import com.tmall.pokemon.bulbasaur.task.model.User;
import com.tmall.pokemon.bulbasaur.task.service.TaskAccessor;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;

import javax.annotation.Resource;

import com.alibaba.fastjson.JSON;

/**
 * User:  yunche.ch ... (ว ˙o˙)ง
 * Date: 14-12-22
 * Time: 下午4:20
 */

@RunWith(JUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/taskMachineTest.xml"})
public class TaskAccessorTest {

    @Resource
    private TaskAccessor taskAccessor;
    @Autowired
    ScheduleMachineFactory scheduleMachineFactory;
    private AtomicLong count = new AtomicLong(0);

    public static final long userId = 00001L;
    public static final String userName = "测试人员";
    public static User user;
    public static final String DEFAULT_DEAL_RESULT = "ok";
    public static final String DEFAULT_MEMO = "我是测试，谢谢";

    static {
        user = new User();
        user.setId(userId);
        user.setName(userName);

    }

    private String getBizId() {
        return String.valueOf(System.currentTimeMillis()) + count.getAndAdd(1L);
    }

    @Test
    public void testSingleCreateUntilComplate() {
        String definationName = "singleTask";
        String bizId = getBizId();
        System.out.println("bizId:" + bizId);

        ScheduleMachine m = scheduleMachineFactory.newInstance(bizId, definationName);
        m.addContext("goto", 2);
        m.addContext("_i", 3);
        m.addContext(TaskConstant.BULBASAUR_INNER_CONTEXT_KEY_CREATOR_ID, 00001L);
        m.addContext(TaskConstant.BULBASAUR_INNER_CONTEXT_KEY_CREATOR_NAME, "测试人员创建的");

        TaskBizInfo<User> taskBizInfo = new TaskBizInfo(user);
        m.addContext(TaskConstant.BULBASAUR_INNER_CONTEXT_KEY_BIZ_INFO, taskBizInfo);
        m.run();

        TaskQuery taskQuery = new TaskQuery();
        taskQuery.setUserId(userId);
        taskQuery.setTaskStatusEnum(TaskStatusEnum.STATUS_CREATED);
        taskQuery.setDefinitionName(definationName);
        QueryResult<TaskDO> queryResult = taskAccessor.queryTasks(taskQuery);
        Collection<TaskDO> taskDOs = queryResult.getDataList();
        for (TaskDO taskDO : taskDOs) {

            User ext = JSON.parseObject(taskDO.getBizInfo(), User.class);

            Assert.assertEquals(ext, user);

            // 是否可以申领
            InvokeResult<Void> invokeResult = taskAccessor.hasTaskTakenPermission(taskDO.getId(), user);
            Assert.assertTrue(invokeResult != null && invokeResult.isSuccess());

            // 尝试直接结束
            invokeResult = taskAccessor.completeTask(taskDO.getId(), user, DEFAULT_DEAL_RESULT, DEFAULT_MEMO);
            Assert.assertTrue(!invokeResult.isSuccess());//false 就对的

            invokeResult = taskAccessor.takenTask(taskDO.getId(), user);
            Assert.assertTrue(invokeResult != null && invokeResult.isSuccess());
            invokeResult = taskAccessor.completeTask(taskDO.getId(), user, DEFAULT_DEAL_RESULT, DEFAULT_MEMO);
            Assert.assertTrue(invokeResult != null && invokeResult.isSuccess());

        }

    }

    @Test
    public void testMultipleCreateUntilComplete() {
        String definationName = "multipleTask";
        String bizId = getBizId();
        System.out.println("bizId:" + bizId);

        ScheduleMachine m = scheduleMachineFactory.newInstance(bizId, definationName);
        m.addContext("goto", 2);
        m.addContext("_i", 3);
        m.run();

        TaskQuery taskQuery = new TaskQuery();
        taskQuery.setTaskStatusEnum(TaskStatusEnum.STATUS_CREATED);
        taskQuery.setDefinitionName(definationName);
        QueryResult<TaskDO> queryResult = taskAccessor.queryTasksByUser(taskQuery, userId);
        Collection<TaskDO> taskDOs = queryResult.getDataList();
        Assert.assertTrue(taskDOs != null && !taskDOs.isEmpty());
        for (TaskDO taskDO : taskDOs) {

            // 是否可以申领
            InvokeResult<Void> invokeResult = taskAccessor.hasTaskTakenPermission(taskDO.getId(), user);
            Assert.assertTrue(invokeResult != null && invokeResult.isSuccess());

            // 尝试直接结束
            invokeResult = taskAccessor.completeTask(taskDO.getId(), user, DEFAULT_DEAL_RESULT, DEFAULT_MEMO);
            Assert.assertTrue(!invokeResult.isSuccess());//false 就对的

            invokeResult = taskAccessor.takenTask(taskDO.getId(), user);
            Assert.assertTrue(invokeResult != null && invokeResult.isSuccess());
            invokeResult = taskAccessor.completeTask(taskDO.getId(), user, DEFAULT_DEAL_RESULT, DEFAULT_MEMO);
            Assert.assertTrue(invokeResult != null && invokeResult.isSuccess());

        }

    }

    @Test
    public void testQueryTasks() throws Exception {

        TaskQuery taskQuery = new TaskQuery();
        taskQuery.setUserId(userId);
        taskQuery.setDealResult("ok1");
        QueryResult<TaskDO> taskDOQueryResult = taskAccessor.queryTasks(taskQuery);

        Assert.assertTrue(taskDOQueryResult != null
            && taskDOQueryResult.getDataList() != null
            && !taskDOQueryResult.getDataList().isEmpty());

    }

    @Test
    public void testQueryTasksByUser() throws Exception {

        Long userId = 00001L;
        String definationName = "multipleTask";
        TaskQuery taskQuery = new TaskQuery();
        taskQuery.setTaskStatusEnum(TaskStatusEnum.STATUS_CREATED);
        taskQuery.setDefinitionName(definationName);
        QueryResult<TaskDO> taskDOQueryResult = taskAccessor.queryTasksByUser(taskQuery, userId);

        Assert.assertTrue(taskDOQueryResult != null
            && taskDOQueryResult.getDataList() != null
            && !taskDOQueryResult.getDataList().isEmpty());

        System.out.println("=========" + taskDOQueryResult.getTotal());

    }
}


<!DOCTYPE html>
<html>
<head>
    <title>Hover</title>
</head>
<body>
<input type="button" id="input1" value="input1" style="position: absolute"/>
<input type="button" id="input2" value="input2" style="margin-left: 100px; margin-top: 100px; "/>
<input type="button" id="out-of-visible-area" style="position: absolute; left: -100px; top: -100px;">

<script>
    let eventLog = '';

    document.getElementById('input1').addEventListener('mouseover', function () {
        eventLog = 'input1 mouseover';
    });

    document.getElementById('input1').addEventListener('mouseout', function () {
        eventLog += ' input1 mouseout';
    });

    document.getElementById('input2').addEventListener('mouseover', function () {
        if (eventLog === 'input1 mouseover input1 mouseout')
            throw new Error('Hover on inputs raised');
    });

    document.getElementById('input2').addEventListener('mouseout', function () {
        eventLog += ' input2 mouseout';
    });
</script>
</body>
</html>


' Copyright (c) Microsoft.  All Rights Reserved.  Licensed under the Apache License, Version 2.0.  See License.txt in the project root for license information.

Imports System.Threading
Imports Microsoft.CodeAnalysis.Text
Imports Microsoft.VisualStudio.Text
Imports Microsoft.VisualStudio.Text.Editor
Imports Microsoft.VisualStudio.Text.Operations

Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.EndConstructGeneration
    Friend Class ReplaceSpanResult
        Inherits AbstractEndConstructResult

        Private ReadOnly _snapshotSpan As SnapshotSpan
        Private ReadOnly _replacementText As String
        Private ReadOnly _newCaretPosition As Integer?

        Sub New(snapshotSpan As SnapshotSpan, replacementText As String, newCaretPosition As Integer?)
            ThrowIfNull(replacementText)

            _snapshotSpan = snapshotSpan
            _replacementText = replacementText
            _newCaretPosition = newCaretPosition
        End Sub

        Public Overrides Sub Apply(textView As ITextView,
                                   subjectBuffer As ITextBuffer,
                                   caretPosition As Integer,
                                   smartIndentationService As ISmartIndentationService,
                                   undoHistoryRegistry As ITextUndoHistoryRegistry,
                                   editorOperationsFactoryService As IEditorOperationsFactoryService)

            Dim current = subjectBuffer.CurrentSnapshot
            Dim document = current.GetOpenDocumentInCurrentContextWithChanges()
            If document Is Nothing Then
                Return
            End If

            Dim oldSolution = document.Project.Solution.Workspace.CurrentSolution
            Dim newSolution = oldSolution.UpdateDocument(
                document.Id, SpecializedCollections.SingletonEnumerable(
                    New TextChange(_snapshotSpan.TranslateTo(current, SpanTrackingMode.EdgeExclusive).Span.ToTextSpan(), _replacementText)), CancellationToken.None)

            oldSolution.Workspace.TryApplyChanges(newSolution)

            Dim startPoint = _snapshotSpan.Start.TranslateTo(subjectBuffer.CurrentSnapshot, PointTrackingMode.Negative)
            If _newCaretPosition IsNot Nothing Then
                textView.TryMoveCaretToAndEnsureVisible(startPoint + _newCaretPosition.Value)
            Else
                SetIndentForFirstBlankLine(textView, subjectBuffer, smartIndentationService, startPoint.GetContainingLine())
            End If
        End Sub
    End Class
End Namespace


using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc.Rendering;
using Plato.Categories.Models;

namespace Plato.Discuss.Categories.ViewModels
{
    public class EditChannelViewModel
    {

        public bool IsNewChannel { get; set; }

        public int Id { get; set; }

        [Required]
        public int ParentId { get; set; }

        public IEnumerable<SelectListItem> AvailableChannels { get; set; }

        [Required]
        [StringLength(255)]
        [DataType(DataType.Text)]
        public string Name { get; set; }

        [StringLength(500)]
        [DataType(DataType.Text)]
        public string Description { get; set; }

        [StringLength(50)]
        public string ForeColor { get; set; }

        [StringLength(50)]
        public string BackColor { get; set; }

        public string IconPrefix { get; set; }

        [StringLength(255)]
        public string IconCss { get; set; }

        public DefaultIcons ChannelIcons { get; set; }

    }
}


Sitemap

/apps.html

/blog.html

/contribute.html

/documentation.html

/index.html

/index_zh.html

/wiki.html

/apis/embeddingapidocs/index.html

/apis/embeddingapidocs/reference/classes.html

/apis/embeddingapidocs/reference/hierarchy.html

/apis/embeddingapidocs/reference/index.html

/apis/embeddingapidocs/reference/packages.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs/reference/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs/reference/org/xwalk/core/package-descr.html

/apis/embeddingapidocs/reference/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v2/allclasses-frame.html

/apis/embeddingapidocs_v2/allclasses-noframe.html

/apis/embeddingapidocs_v2/constant-values.html

/apis/embeddingapidocs_v2/deprecated-list.html

/apis/embeddingapidocs_v2/help-doc.html

/apis/embeddingapidocs_v2/index-all.html

/apis/embeddingapidocs_v2/index.html

/apis/embeddingapidocs_v2/overview-tree.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkUIClient.LoadStatus.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs_v2/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs_v2/org/xwalk/core/package-frame.html

/apis/embeddingapidocs_v2/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v2/org/xwalk/core/package-tree.html

/apis/embeddingapidocs_v2/reference/classes.html

/apis/embeddingapidocs_v2/reference/hierarchy.html

/apis/embeddingapidocs_v2/reference/index.html

/apis/embeddingapidocs_v2/reference/packages.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkExtension.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkUIClient.LoadStatus.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/package-descr.html

/apis/embeddingapidocs_v2/reference/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v3/allclasses-frame.html

/apis/embeddingapidocs_v3/allclasses-noframe.html

/apis/embeddingapidocs_v3/constant-values.html

/apis/embeddingapidocs_v3/deprecated-list.html

/apis/embeddingapidocs_v3/help-doc.html

/apis/embeddingapidocs_v3/index-all.html

/apis/embeddingapidocs_v3/index.html

/apis/embeddingapidocs_v3/overview-tree.html

/apis/embeddingapidocs_v3/org/xwalk/core/JavascriptInterface.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkExtension.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkUIClient.LoadStatus.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs_v3/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs_v3/org/xwalk/core/package-frame.html

/apis/embeddingapidocs_v3/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v3/org/xwalk/core/package-tree.html

/apis/embeddingapidocs_v4/allclasses-frame.html

/apis/embeddingapidocs_v4/allclasses-noframe.html

/apis/embeddingapidocs_v4/constant-values.html

/apis/embeddingapidocs_v4/deprecated-list.html

/apis/embeddingapidocs_v4/help-doc.html

/apis/embeddingapidocs_v4/index-all.html

/apis/embeddingapidocs_v4/index.html

/apis/embeddingapidocs_v4/overview-tree.html

/apis/embeddingapidocs_v4/org/xwalk/core/JavascriptInterface.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkExtension.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkUIClient.InitiateBy.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkUIClient.LoadStatus.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs_v4/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs_v4/org/xwalk/core/package-frame.html

/apis/embeddingapidocs_v4/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v4/org/xwalk/core/package-tree.html

/apis/embeddingapidocs_v5/allclasses-frame.html

/apis/embeddingapidocs_v5/allclasses-noframe.html

/apis/embeddingapidocs_v5/constant-values.html

/apis/embeddingapidocs_v5/deprecated-list.html

/apis/embeddingapidocs_v5/help-doc.html

/apis/embeddingapidocs_v5/index-all.html

/apis/embeddingapidocs_v5/index.html

/apis/embeddingapidocs_v5/overview-tree.html

/apis/embeddingapidocs_v5/org/xwalk/core/JavascriptInterface.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkActivity.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkApplication.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkDownloadListener.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkExtension.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkInitializer.XWalkInitListener.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkInitializer.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkUIClient.ConsoleMessageType.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkUIClient.InitiateBy.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkUIClient.LoadStatus.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkUpdater.XWalkUpdateListener.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkUpdater.html

/apis/embeddingapidocs_v5/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs_v5/org/xwalk/core/package-frame.html

/apis/embeddingapidocs_v5/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v5/org/xwalk/core/package-tree.html

/apis/embeddingapidocs_v6/allclasses-frame.html

/apis/embeddingapidocs_v6/allclasses-noframe.html

/apis/embeddingapidocs_v6/constant-values.html

/apis/embeddingapidocs_v6/deprecated-list.html

/apis/embeddingapidocs_v6/help-doc.html

/apis/embeddingapidocs_v6/index-all.html

/apis/embeddingapidocs_v6/index.html

/apis/embeddingapidocs_v6/overview-tree.html

/apis/embeddingapidocs_v6/org/xwalk/core/ClientCertRequest.html

/apis/embeddingapidocs_v6/org/xwalk/core/JavascriptInterface.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkActivity.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkCookieManager.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkDownloadListener.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkExtension.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkGetBitmapCallback.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkHttpAuthHandler.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkInitializer.XWalkInitListener.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkInitializer.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkNativeExtensionLoader.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkSettings.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUIClient.ConsoleMessageType.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUIClient.InitiateBy.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUIClient.LoadStatus.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUpdater.XWalkBackgroundUpdateListener.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUpdater.XWalkUpdateListener.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkUpdater.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkWebResourceRequest.html

/apis/embeddingapidocs_v6/org/xwalk/core/XWalkWebResourceResponse.html

/apis/embeddingapidocs_v6/org/xwalk/core/package-frame.html

/apis/embeddingapidocs_v6/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v6/org/xwalk/core/package-tree.html

/apis/embeddingapidocs_v7/allclasses-frame.html

/apis/embeddingapidocs_v7/allclasses-noframe.html

/apis/embeddingapidocs_v7/constant-values.html

/apis/embeddingapidocs_v7/deprecated-list.html

/apis/embeddingapidocs_v7/help-doc.html

/apis/embeddingapidocs_v7/index-all.html

/apis/embeddingapidocs_v7/index.html

/apis/embeddingapidocs_v7/overview-tree.html

/apis/embeddingapidocs_v7/org/xwalk/core/ClientCertRequest.html

/apis/embeddingapidocs_v7/org/xwalk/core/JavascriptInterface.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkActivity.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkCookieManager.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkDialogManager.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkDownloadListener.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkExtension.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkExternalExtensionManager.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkFindListener.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkGetBitmapCallback.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkHttpAuthHandler.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkInitializer.XWalkInitListener.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkInitializer.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkJavascriptResult.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkNativeExtensionLoader.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkNavigationHistory.Direction.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkNavigationHistory.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkNavigationItem.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkPreferences.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkResourceClient.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkSettings.LayoutAlgorithm.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkSettings.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUIClient.ConsoleMessageType.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUIClient.InitiateBy.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUIClient.JavascriptMessageType.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUIClient.LoadStatus.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUIClient.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUpdater.XWalkBackgroundUpdateListener.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUpdater.XWalkUpdateListener.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkUpdater.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkView.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkWebResourceRequest.html

/apis/embeddingapidocs_v7/org/xwalk/core/XWalkWebResourceResponse.html

/apis/embeddingapidocs_v7/org/xwalk/core/package-frame.html

/apis/embeddingapidocs_v7/org/xwalk/core/package-summary.html

/apis/embeddingapidocs_v7/org/xwalk/core/package-tree.html

/assets/logos/index.html

/blog/android-64bit.html

/blog/announce-linux-dt.html

/blog/announcing-web-testing-service.html

/blog/chinese-web-release.html

/blog/copu2015-award.html

/blog/crosswalk-10-beta.html

/blog/crosswalk-10-stable.html

/blog/crosswalk-101-new-html5-application-runtime.html

/blog/crosswalk-11-beta.html

/blog/crosswalk-12-beta.html

/blog/crosswalk-14-beta.html

/blog/crosswalk-15-beta.html

/blog/crosswalk-16.html

/blog/crosswalk-2015-summary.html

/blog/crosswalk-9-stable.html

/blog/crosswalk-app-tools-07.html

/blog/crosswalk-app-tools-alpha.html

/blog/crosswalk-cordova-update-351.html

/blog/crosswalk-download-mode.html

/blog/crosswalk-final-release.html

/blog/crosswalk-game-mode.html

/blog/crosswalk-lite-10.html

/blog/crosswalk-realsense-webapi.html

/blog/crosswalk-shared-mode.html

/blog/crosswalk-windows.html

/blog/deprecate-40.html

/blog/index.html

/blog/index_zh.html

/blog/intel-xdk-develop-once-deploy-everywhere.html

/blog/ios-release.html

/blog/monaca-crosswalk.html

/blog/using-custom-crosswalk-in-cordova-plugin.html

/blog/using-the-crosswalk-for-android-build-option.html

/blog/webcl-removal.html

/blog/what-is-crosswalk.html

/contribute/building_crosswalk.html

/contribute/building_crosswalk_zh.html

/contribute/channels_viewer.html

/contribute/channels_viewer_zh.html

/contribute/coding_style.html

/contribute/coding_style_zh.html

/contribute/contributing-code.html

/contribute/contributing-code_zh.html

/contribute/contributing_tests.html

/contribute/contributing_tests_zh.html

/contribute/downstream-chromium.html

/contribute/downstream-chromium_zh.html

/contribute/index.html

/contribute/index_zh.html

/contribute/report_bugs.html

/contribute/report_bugs_zh.html

/contribute/reviewer_policy.html

/contribute/reviewer_policy_zh.html

/contribute/visual_studio.html

/contribute/visual_studio_zh.html

/contribute/building_crosswalk/android_build.html

/contribute/building_crosswalk/linux_build.html

/contribute/building_crosswalk/prerequisites.html

/contribute/building_crosswalk/running_tests.html

/contribute/building_crosswalk/tracking_branches.html

/contribute/building_crosswalk/windows_build.html

/documentation/about.html

/documentation/about_zh.html

/documentation/android.html

/documentation/android_zh.html

/documentation/apis.html

/documentation/apis_zh.html

/documentation/community.html

/documentation/community_zh.html

/documentation/cordova.html

/documentation/cordova_zh.html

/documentation/crosswalk-app-tools.html

/documentation/crosswalk-app-tools_zh.html

/documentation/crosswalk_lite.html

/documentation/crosswalk_lite_zh.html

/documentation/download_mode.html

/documentation/download_mode_zh.html

/documentation/downloads.html

/documentation/downloads_zh.html

/documentation/getting_started.html

/documentation/getting_started_zh.html

/documentation/index.html

/documentation/index_zh.html

/documentation/ios.html

/documentation/ios_zh.html

/documentation/linux.html

/documentation/linux_zh.html

/documentation/manifest.html

/documentation/manifest_zh.html

/documentation/npm-proxy-setup.html

/documentation/npm-proxy-setup_zh.html

/documentation/qa.html

/documentation/qa_zh.html

/documentation/realsense.html

/documentation/release-notes.html

/documentation/samples.html

/documentation/samples_zh.html

/documentation/shared_mode.html

/documentation/shared_mode_zh.html

/documentation/tizen.html

/documentation/tutorials.html

/documentation/windows.html

/documentation/windows_zh.html

/documentation/about/demos.html

/documentation/about/demos_zh.html

/documentation/about/faq.html

/documentation/about/faq_zh.html

/documentation/android/android_64bit.html

/documentation/android/android_64bit_zh.html

/documentation/android/android_extensions.html

/documentation/android/android_extensions_zh.html

/documentation/android/android_remote_debugging.html

/documentation/android/android_remote_debugging_make_apk.html

/documentation/android/android_remote_debugging_zh.html

/documentation/android/android_target_setup.html

/documentation/android/android_target_setup_zh.html

/documentation/android/build_an_application.html

/documentation/android/build_an_application_make_apk.html

/documentation/android/build_an_application_zh.html

/documentation/android/deploy_to_android_store.html

/documentation/android/deploy_to_android_store_zh.html

/documentation/android/embedding_crosswalk.html

/documentation/android/embedding_crosswalk_rvw.html

/documentation/android/embedding_crosswalk_zh.html

/documentation/android/linux_host_setup_make_apk.html

/documentation/android/make_apk_docs.html

/documentation/android/make_apk_docs_zh.html

/documentation/android/run_on_android.html

/documentation/android/run_on_android_make_apk.html

/documentation/android/run_on_android_zh.html

/documentation/android/system_setup.html

/documentation/android/system_setup_zh.html

/documentation/android/windows_host_setup_make_apk.html

/documentation/android/android_extensions/host_and_target_setup.html

/documentation/android/android_extensions/run_on_android.html

/documentation/android/android_extensions/write_a_web_application.html

/documentation/android/android_extensions/write_an_extension.html

/documentation/android/embedding_crosswalk/crosswalk_aar.html

/documentation/android/embedding_crosswalk/extensions.html

/documentation/apis/embedding_api.html

/documentation/apis/embedding_api_zh.html

/documentation/apis/presentation_api_tutorial.html

/documentation/apis/presentation_api_tutorial_zh.html

/documentation/apis/web_apis.html

/documentation/apis/web_apis_zh.html

/documentation/community/awards.html

/documentation/community/awards_zh.html

/documentation/community/branding-guide.html

/documentation/community/branding-guide_zh.html

/documentation/community/conferences.html

/documentation/community/conferences_zh.html

/documentation/community/presentations.html

/documentation/community/presentations_zh.html

/documentation/community/testimonials.html

/documentation/community/testimonials_zh.html

/documentation/community/tools.html

/documentation/community/tools_zh.html

/documentation/community/awards/bestpartner2015.html

/documentation/community/awards/copu2015.html

/documentation/community/conferences/andevcon2015.html

/documentation/community/conferences/fluent2016.html

/documentation/community/conferences/fossasia2015.html

/documentation/community/conferences/mwc2015.html

/documentation/community/conferences/phonegapday2015.html

/documentation/community/conferences/phonegapday2016.html

/documentation/community/conferences/phonegapdayamsterdam2016.html

/documentation/community/conferences/senchacon2015.html

/documentation/community/conferences/tizen2015.html

/documentation/crosswalk_lite/lite_10_disabled_feature_list.html

/documentation/crosswalk_lite/lite_disabled_feature_list.html

/documentation/crosswalk_lite/use_crosswalk_lite.html

/documentation/crosswalk_lite/use_crosswalk_lite_zh.html

/documentation/ios/cordova_plugin_support.html

/documentation/ios/cordova_plugin_support_zh.html

/documentation/ios/embedding_mode_&_native_apis.html

/documentation/ios/embedding_mode_&_native_apis_zh.html

/documentation/ios/extensions.html

/documentation/ios/extensions_zh.html

/documentation/ios/manifest.html

/documentation/ios/manifest_zh.html

/documentation/ios/quick_start_guide.html

/documentation/ios/quick_start_guide_zh.html

/documentation/manifest/content_security_policy.html

/documentation/manifest/content_security_policy_zh.html

/documentation/manifest/display.html

/documentation/manifest/display_zh.html

/documentation/manifest/entry_points.html

/documentation/manifest/entry_points_zh.html

/documentation/manifest/extensions.html

/documentation/manifest/extensions_zh.html

/documentation/manifest/icons.html

/documentation/manifest/icons_zh.html

/documentation/manifest/launch_screen.html

/documentation/manifest/launch_screen_zh.html

/documentation/manifest/orientation.html

/documentation/manifest/orientation_zh.html

/documentation/manifest/other_fields.html

/documentation/manifest/other_fields_zh.html

/documentation/manifest/permissions.html

/documentation/manifest/permissions_zh.html

/documentation/manifest/using_the_manifest.html

/documentation/manifest/using_the_manifest_zh.html

/documentation/manifest/xwalk_hosts.html

/documentation/manifest/xwalk_hosts_zh.html

/documentation/qa/quality_dashboard.html

/documentation/qa/quality_dashboard_zh.html

/documentation/qa/test_suite.html

/documentation/qa/test_suite_zh.html

/documentation/samples/demoexpress.html

/documentation/samples/demoexpress_zh.html

/documentation/samples/hello-world.html

/documentation/samples/hello-world_zh.html

/documentation/samples/simd.html

/documentation/samples/simd_zh.html

/documentation/samples/webgl.html

/documentation/samples/webgl_zh.html

/documentation/tutorials/realsense.html

/documentation/tutorials/screens.html

/documentation/tutorials/security-api.html

/documentation/tutorials/webassembly.html

/documentation/tutorials/webcl.html

/documentation/tutorials/webrtc.html

/documentation/tutorials/webvr.html

/documentation/tutorials/screens/screen_measurements.html

/documentation/windows/build_an_application.html

/documentation/windows/build_an_application_zh.html

/documentation/windows/build_crosswalk_for_windows_zh.html

/documentation/windows/deploy_windows_store.html

/documentation/windows/deploy_windows_store_zh.html

/documentation/windows/extensions.html

/documentation/windows/extensions_zh.html

/documentation/windows/net_extensions.html

/documentation/windows/net_extensions_zh.html

/documentation/windows/run_on_windows.html

/documentation/windows/run_on_windows_zh.html

/documentation/windows/web_inspector_debugging.html

/documentation/windows/web_inspector_debugging_zh.html

/documentation/windows/windows_host_setup.html

/documentation/windows/windows_host_setup_zh.html

/styleguide/index.html

/styleguide/section-1.html

/styleguide/section-2.html

/styleguide/section-3.html

/styleguide/section-4.html

/styleguide/section-5.html


/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Copyright (C) 2011-2020 OpenFOAM Foundation
     \\/     M anipulation  |
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.

Class
    Foam::zone

Description
    Base class for zones

SourceFiles
    zone.C

\*---------------------------------------------------------------------------*/

#ifndef zone_H
#define zone_H

#include "labelList.H"
#include "typeInfo.H"
#include "dictionary.H"
#include "Map.H"
#include "pointFieldFwd.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// Forward declaration of friend functions and operators

class zone;
Ostream& operator<<(Ostream&, const zone&);

/*---------------------------------------------------------------------------*\
                            Class zone Declaration
\*---------------------------------------------------------------------------*/

class zone
:
    public labelList
{

protected:

    // Protected data

        //- Name of zone
        word name_;

        //- Index of zone
        label index_;

        // Demand-driven private data

            //- Map of labels in zone for fast location lookup
            mutable Map<label>* lookupMapPtr_;

    // Protected Member Functions

        //- Construct the look-up map
        void calcLookupMap() const;

public:

    //- Runtime type information
    TypeName("zone");

    // Constructors

        //- Construct from components
        zone
        (
            const word& name,
            const labelUList& addr,
            const label index
        );

        //- Construct from components, moving contents
        zone
        (
            const word& name,
            labelList&& addr,
            const label index
        );

        //- Construct from dictionary
        zone
        (
            const word& name,
            const dictionary&,
            const word& labelsName,
            const label index
        );

        //- Construct given the original zone and resetting the
        //  cell list and zone mesh information
        zone
        (
            const zone&,
            const labelUList& addr,
            const label index
        );

        //- Construct given the original zone, resetting the
        //  cell list and zone mesh information
        zone
        (
            const zone&,
            labelList&& addr,
            const label index
        );

        //- Disallow default bitwise copy construction
        zone(const zone&) = delete;

    //- Destructor
    virtual ~zone();

    // Member Functions

        //- Return name
        const word& name() const
        {
            return name_;
        }

        //- Map storing the local index for every global index.  Used to find
        //  the index of the item in the zone from the known global index. If
        //  the item is not in the zone, returns -1
        label localID(const label globalID) const;

        //- Return the index of this zone in zone list
        label index() const
        {
            return index_;
        }

        //- Return a reference to the look-up map
        const Map<label>& lookupMap() const;

        //- Clear addressing
        virtual void clearAddressing();

        //- Check zone definition. Return true if in error.
        virtual bool checkDefinition(const bool report = false) const = 0;

        //- Check zone definition with max size given. Return true if in error.
        virtual bool checkDefinition
        (
            const label maxSize,
            const bool report = false
        ) const;

        //- Correct patch after moving points
        virtual void movePoints(const pointField&)
        {}

        //- Write
        virtual void write(Ostream&) const;

        //- Write dictionary
        virtual void writeDict(Ostream&) const = 0;

    // Member Operators

        //- Assignment operator
        void operator=(const zone&);

        //- Move assignment operator
        void operator=(zone&&);

        //- Assignment operator to addressing
        void operator=(const labelUList&);

        //- Move assignment of addressing
        void operator=(labelList&&);

    // I-O

        //- Ostream Operator
        friend Ostream& operator<<(Ostream&, const zone&);
};

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //


// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`WebpackConfigHelper getCommon sends proper stuff depending on isDev 1`] = `
Object {
  "context": "/foo/bar",
  "devtool": "source-map",
  "externals": Object {
    "jquery": "jQuery",
  },
  "mode": "production",
  "name": "config1",
  "target": "web",
  "watch": false,
}
`;

exports[`WebpackConfigHelper getCommon sends proper stuff depending on isDev 2`] = `
Object {
  "context": "/foo/bar",
  "devtool": "cheap-module-source-map",
  "externals": Object {
    "jquery": "jQuery",
  },
  "mode": "development",
  "name": "config1",
  "target": "web",
  "watch": true,
}
`;

exports[`WebpackConfigHelper getPlugins has proper plugins for build mode 1`] = `
Array [
  DefinePlugin {
    "definitions": Object {
      "__WPACKIO__": Object {
        "appName": "\\"wpackio\\"",
        "outputPath": "\\"dist\\"",
      },
      "process.env.BABEL_ENV": "\\"production\\"",
      "process.env.NODE_ENV": "\\"production\\"",
    },
  },
  CleanWebpackPlugin {
    "apply": [Function],
    "cleanAfterEveryBuildPatterns": Array [],
    "cleanOnceBeforeBuildPatterns": Array [
      "/foo/bar/dist/config1",
    ],
    "cleanStaleWebpackAssets": true,
    "currentAssets": Array [],
    "dangerouslyAllowCleanPatternsOutsideProject": false,
    "dry": false,
    "handleDone": [Function],
    "handleInitial": [Function],
    "initialClean": false,
    "outputPath": "",
    "protectWebpackAssets": true,
    "removeFiles": [Function],
    "verbose": false,
  },
  MiniCssExtractPlugin {
    "options": Object {
      "chunkFilename": "config1/[name]-[contenthash:8].css",
      "filename": "config1/[name]-[contenthash:8].css",
      "ignoreOrder": false,
      "moduleFilename": [Function],
    },
  },
  Object {},
  BannerPlugin {
    "banner": [Function],
    "options": Object {
      "banner": "
WordPress WebPack Bundler

@author Swashata Ghosh
@version 1.0.0
@link https://wpack.io
@license GPL-3.0

Copyright (c) 2018 Swashata Ghosh

This software is released under the GPL-3.0 License
https://opensource.org/licenses/GPL-3.0

Compiled with the help of https://wpack.io
A zero setup Webpack Bundler Script for WordPress",
      "entryOnly": false,
      "include": /\\\\\\.\\(\\(t\\|j\\)sx\\?\\|s\\?\\(c\\|a\\)ss\\)\\$/,
      "raw": false,
    },
  },
]
`;

exports[`WebpackConfigHelper getPlugins has proper plugins for dev mode 1`] = `
Array [
  TimeFixPlugin {
    "watchOffset": 11000,
  },
  DefinePlugin {
    "definitions": Object {
      "__WPACKIO__": Object {
        "appName": "\\"wpackio\\"",
        "outputPath": "\\"dist\\"",
      },
      "process.env.BABEL_ENV": "\\"development\\"",
      "process.env.NODE_ENV": "\\"development\\"",
    },
  },
  CleanWebpackPlugin {
    "apply": [Function],
    "cleanAfterEveryBuildPatterns": Array [],
    "cleanOnceBeforeBuildPatterns": Array [
      "/foo/bar/dist/config1",
    ],
    "cleanStaleWebpackAssets": true,
    "currentAssets": Array [],
    "dangerouslyAllowCleanPatternsOutsideProject": false,
    "dry": false,
    "handleDone": [Function],
    "handleInitial": [Function],
    "initialClean": false,
    "outputPath": "",
    "protectWebpackAssets": true,
    "removeFiles": [Function],
    "verbose": false,
  },
  MiniCssExtractPlugin {
    "options": Object {
      "chunkFilename": "config1/[name].css",
      "filename": "config1/[name].css",
      "ignoreOrder": false,
      "moduleFilename": [Function],
    },
  },
  Object {},
  HotModuleReplacementPlugin {
    "fullBuildTimeout": 200,
    "multiStep": undefined,
    "options": Object {},
    "requestTimeout": 10000,
  },
  WatchMissingNodeModulesPlugin {
    "nodeModulesPath": "/foo/bar/node_modules",
  },
]
`;


package com.blanke.solebook.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.avos.avoscloud.AVAnalytics;
import com.hannesdorfmann.mosby.mvp.MvpPresenter;
import com.hannesdorfmann.mosby.mvp.lce.MvpLceView;
import com.hannesdorfmann.mosby.mvp.viewstate.lce.MvpLceViewStateActivity;
import com.umeng.analytics.MobclickAgent;
import com.zhy.changeskin.SkinManager;

/**
 * Created by Blanke on 16-1-7.
 */
public abstract class BaseMvpLceViewStateActivity<CV extends View, M, V extends MvpLceView<M>, P extends MvpPresenter<V>> extends MvpLceViewStateActivity<CV, M, V, P> {
    protected void onPause() {
        super.onPause();
        AVAnalytics.onPause(this);
        MobclickAgent.onPause(this);
    }

    protected void onResume() {
        super.onResume();
        AVAnalytics.onResume(this);
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SkinManager.getInstance().register(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        SkinManager.getInstance().unregister(this);
    }
}