text:
package info.dgjones.abora.gold.collection.basic;

import java.io.PrintWriter;

import info.dgjones.abora.gold.java.exception.AboraRuntimeException;
import info.dgjones.abora.gold.x.PrimSpec;
import info.dgjones.abora.gold.xcvr.Rcvr;
import info.dgjones.abora.gold.xcvr.Xmtr;
import info.dgjones.abora.gold.xpp.basic.Heaper;

/**
 * Array object of a fixed size composed of elements of the same type.
 */
public abstract class PrimArray extends Heaper {
	//TODO Implement Collection?

	//////////////////////////////////////////////
	// Constructors

	/**
	 * Construct a new array.
	 *
	 * Restrict public access to constructor; use suitable static
	 * factory method instead.
	 */
	protected PrimArray() {
		super();
	}

	public PrimArray(Rcvr rcvr) {
		super(rcvr);
	}

	/**
	 * Return a new array of the same type as this
	 * initialized with the elements of source specified by
	 * the index range, prepended by destOffset and postpended by
	 * null or 0 elements.
	 *
	 * @param size size of new array.
	 * @param source source of elements to be initialized with in the new array.
	 * @param sourceOffset first index of the source array to be included in the range.
	 * @param count number of elements of source to include in the new array
	 * @param destOffset first index of new array to be initialized with source elements.
	 * @return the new array.
	 */
	protected abstract PrimArray makeNew(int size, PrimArray source, int sourceOffset, int count, int destOffset);

	/**
	 * Return the number of elements the array can hold.
	 */
	public abstract int count();

	/**
	 * A description of the kinds of things which can be stored
	 * in  this array
	 */
	public abstract PrimSpec spec();

	//////////////////////////////////////////////
	// Accessing

	/**
	 * Store a value; may be a Heaper, null, or a PrimValue as appropriate
	 * to PrimArray subclass. An exception will be throw if the value is
	 * not compatible with the elements this can hold.
	 *

	 * It is expected that most PrimArray clients will want to use
	 * less abstract access methods
	 *
	 * @param index index in array the element will be stored at.
	 * @param value heaper to store in this.
	 * @throws ClassCastException if value is not compatible with the elements of this array
	 * @throws IllegalArgumentException if value can not be held by this array
	 */
	public abstract void storeValue(int index, Heaper value);

	/**
	 * Fetch a value; may be a Heaper, null, or a PrimValue as appropriate
	 * to PrimArray subclass.
	 *

	 * It is expected that most PrimArray clients
	 * will want to use less abstract access methods.
	 *
	 * @param index index in array whose element will be returned
	 * @return the heaper at the specified index.
	 */
	public abstract Heaper fetchValue(int index);

	/**
	 * Fetch a value; may be a Heaper or a PrimValue as appropriate
	 * to PrimArray subclass, or throw an exception if value is null.
	 *

	 * It is expected that most PrimArray clients will want to use
	 * less abstract access methods.
	 *
	 * @param index index in array whose element will be returned.
	 * @return the heaper at the specified index.
	 * @throws NotInTableException if a null value was fetched.
	 */
	public Heaper getValue(int index) {
		Heaper result = fetchValue(index);
		if (result == null) {
			throw new AboraRuntimeException(AboraRuntimeException.NOT_IN_TABLE);
		}
		return result;
	}

	//////////////////////////////////////////////
	// Comparing and Hashing

	//TODO made up
	public boolean isEqual(Heaper other) {
		if (other instanceof PrimArray) {
			PrimArray o = (PrimArray) other;
			return contentsEqual(o);
		} else {
			return false;
		}
	}

	/**
	 * Whether the two ranges contain semantically the same
	 * values.   Two non-NULL pointers match iff the Heapers they
	 * point  to are isEqual. Two integers match iff they have the  same  value,
	 * even though they may be represented as different sizes. Two floats
	 * likewise.
	 */
	public abstract boolean contentsEqual(PrimArray other);

	/**
	 * A hash of the entire contents of the array. If two arrays are
	 * contentsEqual, they will have the same contentsHash.
	 */
	public int contentsHash() {
		return elementsHash();
	}

	/**
	 * Whether the two ranges contain the same values, using the criteria
	 * defined in contentsEqual
	 */
	public abstract boolean elementsEqual(int here, PrimArray other, int there, int n);

	public boolean elementsEqual(int here, PrimArray other, int there) {
		return elementsEqual(here, other, there, -1);
	}

	public boolean elementsEqual(int here, PrimArray other) {
		return elementsEqual(here, other, 0);
	}

	/**
	 * A hash of the range of values out of the array. If two ranges are
	 * elementsEqual, they will have the same hash. For data values, additional
	 * zeros on the end make no difference to the hash.
	 */
	public abstract int elementsHash(int count, int start);

	public int elementsHash(int count) {
		return elementsHash(count, 0);
	}

	public int elementsHash() {
		return elementsHash(-1);
	}

	//////////////////////////////////////////////
	// Bulk Storing

	/**
	 * Fill a consequitive range of elements with the supplied value.
	 *
	 * @param value to store within range or 0.0 if null.
	 * @param count number of consequentive elements in range or all
	 * 			elements from start if -1.
	 * @param start index of first element in range.
	 * @throws ClassCastException if other is not compatible with this array
	 * @throws IllegalArgumentException if others elements can not be held by this array
	 */
	//TODO possibly rename to fill(...) to better match Java terminology
	public abstract void storeAll(Heaper value, int count, int start);

	public void storeAll(Heaper value, int count) {
		storeAll(value, count, 0);
	}

	/**
	 * Fill every element of this to value or null or 0 depending on the type of array.
	 */
	public void storeAll(Heaper value) {
		storeAll(value, -1);
	}

	public void storeAll() {
		storeAll(zeroElement());
	}

	/**
	 * Copy the respective elements of other to this over the specified index range.
	 * The other array must be of a compatible type.
	 *
	 * @param to first index of receiver to be included in the receivers range..
	 * @param other other elements to be copied into this.
	 * @param count number of elements from the other array included in range, or -1 for
	 * 			all others elements starting at from. Fail if count is
	 * 			greater than number of available elements.
	 * @param from first index of the other array to be included in the range.
	 * @throws ClassCastException if other is not compatible with this array
	 * @throws IllegalArgumentException if others elements can not be held by this array
	 */
	public void storeMany(int to, PrimArray other, int count, int from) {
		int n;

		if (count < 0) {
			n = other.count() - from;
		} else {
			n = count;
		}
		if (to + n > count() || from + n > other.count()) {
			throw new IndexOutOfBoundsException();
		}
		copyElements(to, other, from, n);
	}

	/**
	 * Copy n elements from the other array into this one. The other  array must
	 * be of a compatible type.
	 */
	public void storeMany(int to, PrimArray other, int count) {
		storeMany(to, other, count, 0);
	}

	/**
	 * Copy n elements from the other array into this one. The other  array must
	 * be of a compatible type.
	 */
	public void storeMany(int to, PrimArray other) {
		storeMany(to, other, -1);
	}

	/**
	 * Return a copy of this including just the elements specified by
	 * the index range prepended by before, and postpended by after
	 * number of null or 0 elements.
	 *

	 * If before == 10, then the the resulting array with be 10 elements
	 * larger and the copied elements would start at index 10.
	 *
	 * @param count number of elements to copy, or -1 for all from and after start
	 * @param start index of first element to copy from
	 * @param before number of leading null or 0 elements to include before the copied
	 * 	elements in the returned array.
	 * @param after number of trailing null or 0 elements to include after the copied
	 * 	elements in the returned array.
	 * @return PrimArray a copy of this.
	 */
	public PrimArray copy(int count, int start, int before, int after) {
		int copyCount;

		if (count < 0) {
			copyCount = count() - start;
		} else {
			copyCount = count;
			if (start + copyCount > count()) {
				throw new IndexOutOfBoundsException();
			}
		}
		return makeNew(copyCount + before + after, this, start, copyCount, before);
	}

	/**
	 * Return a copy of this including just the elements specified by
	 * the index range prepended by before number of null or 0 elements.
	 *

	 * If before == 10, then the the resulting array with be 10 elements
	 * larger and the copied elements would start at index 10.
	 *
	 * @param count number of elements to copy, or -1 for all from and after start
	 * @param start index of first element to copy from
	 * @param before number of leading null or 0 elements in include before the copied
	 * 	elements in the returned array.
	 * @return PrimArray a copy of this.
	 */
	public PrimArray copy(int count, int start, int before) {
		return copy(count, start, before, 0);
	}

	/**
	 * Return a copy of this including just the elements specified by
	 * the index range.
	 *
	 * @param count number of elements to copy, or -1 for all from and after start
	 * @param start index of first element to copy from
	 * @return PrimArray a copy of this
	 */
	public PrimArray copy(int count, int start) {
		return copy(count, start, 0);
	}

	/**
	 * Return a copy of this including just the first count elements.
	 *
	 * @param count
	 * @return PrimArray a copy of this.
	 */
	public PrimArray copy(int count) {
		return copy(count, 0);
	}

	/**
	 * Return a copy of this.
	 *
	 * @return a copy of this.
	 */
	public PrimArray copy() {
		return copy(-1);
	}

	/**
	 * Return a copy of this with after null/0 elements
	 * postpended to the copied elements.
	 *
	 * @param after number of trailing null or 0 elements to include after the copied
	 * 	elements in the returned array.
	 */
	public PrimArray copyGrow(int after) {
		return copy(count(), 0, 0, after);
	}

	/**
	 * Copy the respective elements of other to this over the specified index range.
	 * The other array must be of a compatible type.
	 *
	 * @param to first index of receiver to be included in the receivers range..
	 * @param other other elements to be copied into this.
	 * @param from first index of the other array to be included in the range.
	 * @param count number of elements from the other array included in range, or -1 for
	 * 			all others elements starting at from. Fail if count is
	 * 			greater than number of available elements.
	 */
	protected void copyElements(int to, PrimArray other, int from, int count) {
		int n = count;
		if (n == -1) {
			n = other.count() - from;
		}
		if (n < 0 || to < 0 || from < 0 || from + n > other.count() || to + n > count()) {
			throw new IndexOutOfBoundsException();
		}
		for (int i = 0; i < n; i += 1) {
			storeValue(to + i, other.fetchValue(from + i));
		}
	}

	//////////////////////////////////////////////
	// Searching/Finding

	/**
	 * Return the index of the nth occurrence of the given value at or
	 * after (before if nth is negative) the given index, or -1 if
	 * there is none.
	 *
	 * @param value element that is to be matched
	 * @param start index to start the search. If positive start from that index,
	 * 			if negative start from relatie to end of array
	 * @param nth nth occurrence of the matched value at or after the start if
	 * 			positive, or at or before if negative. A 0 nth immediately fails.
	 * @return index of element matched or -1 if there is none
	 */
	public abstract int indexOf(Heaper value, int start, int n);

	/**
	 * Return the index of the first occurrence of the given value at or
	 * after (before if nth is negative) the given index, or -1 if
	 * there is none.
	 *
	 * @param value element that is to be matched
	 * @param start index to start the search. If positive start from that index,
	 * 			if negative start from relatie to end of array
	 * @return index of element matched or -1 if there is none
	 */
	public int indexOf(Heaper value, int start) {
		return indexOf(value, start, 1);
	}

	/**
	 * Return the index of the first occurrence of the given value,
	 *  or -1 if there is none.
	 *
	 * @param value element that is to be matched
	 * @return index of element matched or -1 if there is none
	 */
	public int indexOf(Heaper value) {
		return indexOf(value, 0);
	}

	/**
	 * Return the index of the nth occurrence of anything but the given value at or
	 * after (before if nth is negative) the given index, or -1 if
	 * there is none.
	 *
	 * @param value anything except this element that is to be matched
	 * @param start index to start the search. If positive start from that index,
	 * 			if negative start from relatie to end of array
	 * @param nth nth occurrence of the matched value at or after the start if
	 * 			positive, or at or before if negative. A 0 nth immediately fails.
	 * @return index of element matched or -1 if there is none
	 */
	public abstract int indexPast(Heaper value, int start, int n);
	//TODO original X++ version had an implementation but it did
	// not appear to match spec, or inherited versions, so removed

	/**
	 * Return the index of the first occurrence of anything but the given value at or
	 * after (before if nth is negative) the given index, or -1 if
	 * there is none.
	 *
	 * @param value anything except this element that is to be matched
	 * @param start index to start the search. If positive start from that index,
	 * 			if negative start from relatie to end of array
	 * @return index of element matched or -1 if there is none
	 */
	public int indexPast(Heaper value, int start) {
		return indexPast(value, start, 1);
	}

	/**
	 * Return the index of the first occurrence of anything but the given value,
	 * or -1 if there is none.
	 *
	 * @param value anything except this element that is to be matched
	 * @return index of element matched or -1 if there is none
	 */
	public int indexPast(Heaper value) {
		return indexPast(value, 0);
	}

	/**
	 * Return the index of the nth occurrence of the given sequence
	 * of values of other at or after (before if nth is negative) the given
	 * index in this, or -1 if there is none. Negative numbers for start are
	 * relative to the end of the array.
	 *
	 * @param other array of elements that is being searched for in this.
	 * @param otherCount number of elements from other that is being
	 * 	searched for, or -1 to include all elements after otherStart.
	 * @param otherStart index of first element of other to start searching for.
	 * @param start index to start the search from. If positive start from that index,
	 * 			if negative start from relative to end of array where -1 is the last valid index.
	 * @param nth nth occurrence of the matched value at or after the start if
	 * 			positive, or at or before if negative. A 0 nth immediately fails.
	 * @return index of match or -1 if failed
	 */
	public int indexOfElements(PrimArray other, int otherCount, int otherStart, int start, int nth) {
		if (count() == 0 || nth == 0) {
			return -1;
		}
		int otherN;
		if (otherCount < 0) {
			otherN = other.count();
		} else {
			if (otherCount > other.count()) {
				throw new IndexOutOfBoundsException();
			}
			otherN = otherCount;
		}
		int result;
		if (start >= 0) {
			result = start;
		} else {
			result = count() + start;
		}
		int n = nth < 0 ? -nth : nth; //TODO = Math.abs(nth);
		boolean forward = nth > 0;
		for (;;) {
			{
				if (forward ? (result > count() - otherN) : result < 0) {
					return -1;
				}
				if (elementsEqual(result, other, otherStart, otherN)) {
					n -= 1;
					if (n == 0) {
						return result;
					}
				}
				if (forward) {
					result += 1;
				} else {
					result -= 1;
				}
			}
		}
	}

	/**
	 * Return the index of the first occurrence of the given sequence
	 * of values of other at or after the given index
	 * index in this, or -1 if there is none. Negative numbers for start are
	 * relative to the end of the array.
	 *
	 * @param other array of elements that is being searched for in this.
	 * @param otherCount number of elements from other that is being
	 * 	searched for, or -1 to include all elements after otherStart.
	 * @param otherStart index of first element of other to start searching for.
	 * @param start index to start the search from. If positive start from that index,
	 * 			if negative start from relative to end of array where -1 is the last valid index.
	 * @return index of match or -1 if failed
	 */
	public int indexOfElements(PrimArray other, int otherCount, int otherStart, int start) {
		return indexOfElements(other, otherCount, otherStart, start, 1);
	}

	/**
	 * Return the index of the first occurrence of the given sequence
	 * of values of other in this, or -1 if there is none.at or after (before if nth is negative) the given
	 *
	 * @param other array of elements that is being searched for in this.
	 * @param otherCount number of elements from other that is being
	 * 	searched for, or -1 to include all elements after otherStart.
	 * @param otherStart index of first element of other to start searching for.
	 * @return index of match or -1 if failed
	 */
	public int indexOfElements(PrimArray other, int otherCount, int otherStart) {
		return indexOfElements(other, otherCount, otherStart, 0);
	}

	/**
	 * Return the index of the first occurrence of the given sequence
	 * of values of other in this, or -1 if there is none.at or after (before if nth is negative) the given
	 *
	 * @param other array of elements that is being searched for in this.
	 * @param otherCount number of elements from other that is being
	 * 	searched for, or -1 to include all elements.
	 * @return index of match or -1 if failed
	 */
	public int indexOfElements(PrimArray other, int otherCount) {
		return indexOfElements(other, otherCount, 0);
	}

	/**
	 * Return the index of the first occurrence of other in this
	 * or -1 if there is none.
	 *
	 * @param other array of elements that is being searched for in this.
	 * @return index of match or -1 if failed
	 */
	public int indexOfElements(PrimArray other) {
		return indexOfElements(other, -1);
	}

	//////////////////////////////////////////////
	// Printing

	public void printOn(PrintWriter oo) {
		if (count() == 0) {
			oo.print("[empty");
		} else {
			String before = "[";
			for (int i = 0; i < count(); i += 1) {
				oo.print(before);
				printElementOn(i, oo);
				before = " ";
			}
		}
		oo.print("]");
	}

	/**
	 * Print a representation of the element at the given index.
	 *
	 * @param index index of element to be printed.
	 * @param oo print stream to write element representation to.
	 */
	protected void printElementOn(int index, PrintWriter oo) {
		Heaper value = fetchValue(index);
		if (value != null) {
			value.printOn(oo);
		} else {
			oo.print("null");
		}
	}

	//////////////////////////////////////////////
	// Helper methods

	public void zeroElements(int from, int count) {
		Heaper zeroElement = zeroElement();
		storeAll(zeroElement, count, from);
	}

	public void zeroElements(int from) {
		zeroElements(from, -1);
	}

	public void zeroElements() {
		zeroElements(0);
	}

	/**
	 * Return a suitable immutable zero element for this type of array; either 0 or null.
	 *
	 * @return zero element for this type of array
	 */
	protected abstract Heaper zeroElement();

	public void sendSelfTo(Xmtr xmtr) {
		super.sendSelfTo(xmtr);
//		System.out.println("Ignor sendSelfTo() for: "+this);
//		throw new UnsupportedOperationException();
	}

}


text:
public class CustomImplementation implements Parcelable {
  private int intAttribute;
  private float floatAttribute;

  public UserMinimumPreferences(int intAttr, float floatAttr) {
    super();
    this.intAttribute = intAttr;
    this.floatAttribute = floatAttr;
  }

  public CustomImplementation(Parcel in) {
    readFromParcel(in);
  }

  public static Parcelable.Creator<CustomImplementation> getCreator() {
    return CREATOR;
  }

  // Writing in the Parcelable object
  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeInt(intAttribute);
    dest.writeFloat(floatAttribute);
  }

  // Reading from the Parcelable object
  private void readFromParcel(Parcel in) {
    intAttribute = in.readInt();
    floatAttribute = in.readFloat();
  }

redpajama_set_name: RedPajamaGithub


text:
package disparity.rpg.items.armor;

import disparity.rpg.items.Armor;
import disparity.rpg.items.Quality;

public class Chestplate extends Armor{

	/**
	 * Chestplate constructor
	 *
	 * Chestplate have a base AC bonus of 3
	 */
	public Chestplate(Quality quality){
		super("Chestplate", quality, 3);
	}

	/**
	 * Empty Constructor for reading
	 * Beings from JSON files
	 */
	public Chestplate() {
	}
}


text:
export const COMPONENT = 'error-boundary-alert';

export const ERROR = `${COMPONENT}__error`;
export const HEADING = `${COMPONENT}__heading`;
export const MESSAGE = `${COMPONENT}__message`;
export const SUMMARY = `${COMPONENT}__summary`;


text:
## Links

* **Google Hangouts Video**: http://www.youtube.com/watch?v=I9nDOSGfwZg
* **GitHub Issue**: https://github.com/iojs/readable-stream/issues/106
* **Original Minutes Google Doc**: https://docs.google.com/document/d/17aTgLnjMXIrfjgNaTUnHQO7m3xgzHR2VXBTmi03Qii4/

## Agenda

Extracted from https://github.com/iojs/readable-stream/labels/wg-agenda prior to meeting.

* adopt a charter [#105](https://github.com/iojs/readable-stream/issues/105)
* release and versioning strategy [#101](https://github.com/iojs/readable-stream/issues/101)
* simpler stream creation [#102](https://github.com/iojs/readable-stream/issues/102)
* proposal: deprecate implicit flowing of streams [#99](https://github.com/iojs/readable-stream/issues/99)

## Minutes

### adopt a charter

* group: +1's all around

### What versioning scheme should be adopted?
* group: +1's 3.0.0
* domenic+group: pulling in patches from other sources where appropriate
* mikeal: version independently, suggesting versions for io.js
* mikeal+domenic: work with TC to notify in advance of changes
simpler stream creation

### streamline creation of streams
* sam: streamline creation of streams
* domenic: nice simple solution posted
  but, we lose the opportunity to change the model
  may not be backwards incompatible (double check keys)

  **action item:** domenic will check

### remove implicit flowing of streams on('data')
* add isFlowing / isPaused
* mikeal: worrying that we're documenting polyfill methods – confuses users
* domenic: more reflective API is probably good, with warning labels for users
* new section for mad scientists (reflective stream access)
* calvin: name the "third state"
* mikeal: maybe borrow the name from whatwg?
* domenic: we're missing the "third state"
* consensus: kind of difficult to name the third state
* mikeal: figure out differences in states / compat
* mathias: always flow on data – eliminates third state
  * explore what it breaks

**action items:**
* ask isaac for ability to list packages by what public io.js APIs they use (esp. Stream)
* ask rod/build for infrastructure
* **chris**: explore the "flow on data" approach
* add isPaused/isFlowing
* add new docs section
* move isPaused to that section


text:
uv.DonutGraph = function (graphdef, config) {
  var self = this;
  uv.Graph.call(self, graphdef, config).setDefaults().init();

  self.radius = Math.min(self.height(), self.width()) * 2 / 5;
  self.center = {
    x : self.width() / 2,
    y : self.height() / 2
  };

  self.category = graphdef.categories[0];

  var data = uv.util.getCategoryData(self.graphdef, [self.category]),
    arcfunc = d3.svg.arc().innerRadius(self.radius * self.config.donut.factor).outerRadius(self.radius),
    layout = d3.layout.pie();

  self.chart.data(data);
  self.arcs = self.chart.selectAll('g.arc')
          .data(layout).enter()
          .append('g').classed(uv.constants.classes.arc + uv.util.formatClassName(self.category), true)
          .attr('transform', 'translate(' + self.center.x + ',' + self.center.y + ')');

  self.arcs.append('path')
      .attr('d', arcfunc)
      .style('fill', function (d, i) { return uv.util.getColorBand(self.config, i); })
      .style('stroke', self.config.donut.strokecolor)
      .style('stroke-width', self.config.donut.strokewidth)
    .on('mouseover', function(d,i){
      var f = uv.effects.donut.mouseover(self.center, arcfunc, self.config);
      f.apply(this, arguments);
      if(typeof self.config.graph.hoverCallback === "function") {
        self.config.graph.hoverCallback.apply(null, [true,[d,i],d3.mouse(this),this]);
      }
    })
    .on('mouseout', function(d,i){
      var f = uv.effects.donut.mouseout(self.center, self.config);
      f.apply(this, arguments);
      if(typeof self.config.graph.hoverCallback === "function") {
        self.config.graph.hoverCallback.apply(null, [false,[d,i],d3.mouse(this),this]);
      }
    })

  if (typeof self.config.graph.clickCallback === "function") {
    self.arcs.on('click', function (d) {
      self.config.graph.clickCallback.apply(null, [d]);
    });
  }

  self.arcs.append('text')
      .attr('transform', function (d) { return 'translate(' + arcfunc.centroid(d) + ')'; })
      .attr('dy', '.35em')
      .attr('text-anchor', 'middle')
      .style('fill', self.config.label.showlabel ? self.config.donut.fontfill : 'none')
      .style('font-family', self.config.donut.fontfamily)
      .style('font-size', self.config.donut.fontsize)
      .style('font-weight', self.config.donut.fontweight)
      .style('font-variant', self.config.donut.fontvariant)
      .text(function (d) { return uv.util.getLabelValue(self, d); });

  self.arcs.append('svg:title')
    .text(function (d, i) { return uv.util.getTooltipText(self, self.category, self.labels[i], d);});

};

uv.DonutGraph.prototype = uv.util.inherits(uv.Graph);

uv.DonutGraph.prototype.setDefaults = function () {
  var self = this;
  self.graphdef.stepup = 'normal';
  self.config.legend.legendtype = 'labels';
  return this;
};


text:
package com.google.cloud.tools.eclipse.appengine.deploy.ui.internal;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.when;

import java.io.File;
import java.io.IOException;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

@RunWith(MockitoJUnitRunner.class)
public class DeployArtifactValidatorTest {

  @Rule public TemporaryFolder tempFolder = new TemporaryFolder();

  @Mock private IObservableValue<String> deployArtifactPath;

  private IPath basePath;
  private DeployArtifactValidator pathValidator;

  @Before
  public void setUp() throws IOException {
    basePath = new Path(tempFolder.newFolder().toString());
    when(deployArtifactPath.getValueType()).thenReturn(String.class);
    pathValidator = new DeployArtifactValidator(basePath, deployArtifactPath);
    assertTrue(basePath.isAbsolute());
  }

  @Test
  public void testConstructor_nonAbsoluteBasePath() {
    try {
      when(deployArtifactPath.getValue()).thenReturn("some.jar");
      new DeployArtifactValidator(new Path("non/absolute/base/path"), deployArtifactPath);
      fail();
    } catch (IllegalArgumentException ex) {
      assertEquals("basePath is not absolute.", ex.getMessage());
    }
  }

  @Test
  public void testValidate_emptyField() {
    when(deployArtifactPath.getValue()).thenReturn("");

    IStatus result = pathValidator.validate();
    assertEquals(IStatus.ERROR, result.getSeverity());
    assertEquals("Missing WAR or JAR path.", result.getMessage());
  }

  @Test
  public void testValidate_relativePathAndNoArtifact() {
    when(deployArtifactPath.getValue()).thenReturn("relative/path/some.jar");

    IStatus result = pathValidator.validate();
    assertEquals(IStatus.ERROR, result.getSeverity());
    assertEquals("File does not exist: "
        + new Path(basePath + "/relative/path/some.jar").toOSString(), result.getMessage());
  }

  @Test
  public void testValidate_absolutePathAndNoArtifact() {
    String absolutePath = basePath + "/sub/directory/some.jar";
    when(deployArtifactPath.getValue()).thenReturn(absolutePath);

    IStatus result = pathValidator.validate();
    assertEquals(IStatus.ERROR, result.getSeverity());
    assertEquals("File does not exist: " + new Path(absolutePath).toOSString(),
        result.getMessage());
  }

  @Test
  public void testValidate_relativePathAndInvalidExtension() {
    when(deployArtifactPath.getValue()).thenReturn("relative/path/python.py");

    IStatus result = pathValidator.validate();
    assertEquals(IStatus.ERROR, result.getSeverity());
    assertEquals("File extension is not \"war\" or \"jar\".", result.getMessage());
  }

  @Test
  public void testValidate_absolutePathInvalidExtension() {
    String absolutePath = basePath + "/sub/directory/python.py";
    when(deployArtifactPath.getValue()).thenReturn(absolutePath);

    IStatus result = pathValidator.validate();
    assertEquals(IStatus.ERROR, result.getSeverity());
    assertEquals("File extension is not \"war\" or \"jar\".", result.getMessage());
  }

  @Test
  public void testValidate_relativePathNotFile() {
    basePath.append("some.war").toFile().mkdir();
    when(deployArtifactPath.getValue()).thenReturn("some.war");

    IStatus result = pathValidator.validate();
    assertEquals(IStatus.ERROR, result.getSeverity());
    assertEquals("Path is a directory: " + new Path(basePath + "/some.war").toOSString(),
        result.getMessage());
  }

  @Test
  public void testValidate_absolutePathNotFile() {
    basePath.append("some.war").toFile().mkdir();

    String absolutePath = basePath + "/some.war";
    when(deployArtifactPath.getValue()).thenReturn(absolutePath);

    IStatus result = pathValidator.validate();
    assertEquals(IStatus.ERROR, result.getSeverity());
    assertEquals("Path is a directory: " + new Path(basePath + "/some.war").toOSString(),
        result.getMessage());
  }

  @Test
  public void testValidate_relativePathWithJar() throws IOException {
    assertTrue(basePath.append("/some/directory/").toFile().mkdirs());
    assertTrue(basePath.append("/some/directory/some.jar").toFile().createNewFile());

    when(deployArtifactPath.getValue()).thenReturn("some/directory/some.jar");
    IStatus result = pathValidator.validate();
    assertTrue(result.isOK());
  }

  @Test
  public void testValidate_absolutePathWithJar() throws IOException {
    File absolutePath = tempFolder.newFolder("another", "folder");
    File jar = new File(absolutePath + "/some.jar");
    assertTrue(jar.createNewFile());

    when(deployArtifactPath.getValue()).thenReturn(jar.toString());
    IStatus result = pathValidator.validate();
    assertTrue(result.isOK());
  }
}


text:
from flask import Flask, g, redirect, render_template, request, session
from flask import flash, url_for
from flask_github import GitHub
import json
import os
import requests
from sqlalchemy import create_engine, Column, Integer, String, Boolean
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

app = Flask(__name__)

if 'SENTRY_DSN' in os.environ:
    from raven.contrib.flask import Sentry
    sentry = Sentry(app)

app.config['GITHUB_CLIENT_ID'] = os.environ['AELITA_GITHUB_CLIENT_ID']
app.config['GITHUB_CLIENT_SECRET'] = os.environ['AELITA_GITHUB_CLIENT_SECRET']
app.config['BOT_USERNAME'] = os.environ['AELITA_BOT_USERNAME']
app.config['BOT_BASEURL'] = os.environ['AELITA_BOT_BASEURL']
app.config['BOT_DBURI'] = os.environ['AELITA_BOT_DBURI']
app.config['BOT_ACCESS_TOKEN'] = os.environ['AELITA_BOT_ACCESS_TOKEN']
app.config['BOT_NOTICE_SECRET'] = os.environ['AELITA_BOT_NOTICE_SECRET']
app.config['BOT_STATUS_SECRET'] = os.environ['AELITA_BOT_STATUS_SECRET']
app.secret_key = os.environ['AELITA_VIEW_SECRET']
github = GitHub(app)
engine = create_engine(app.config['BOT_DBURI'])
db_session = scoped_session(
    sessionmaker(
        autocommit=False,
        autoflush=False,
        bind=engine,
    )
)

Base = declarative_base()
Base.query = db_session.query_property()

class User(Base):
    __tablename__ = 'signup_users'

    user_id = Column(Integer, primary_key=True)
    username = Column(String(200))
    github_access_token = Column(String(200))
    invite_count = Column(Integer, default=3)

    def __init__(self, github_access_token):
        self.github_access_token = github_access_token

class Invited(Base):
    __tablename__ = 'signup_invited'

    username = Column(String(200), primary_key=True)

    def __init__(self, username):
        self.username = username

class Pipeline(Base):
    __tablename__ = 'twelvef_config_pipeline'

    pipeline_id = Column(Integer, primary_key=True)
    name = Column(String(200))

    def __init__(self, pipeline_id, name):
        self.pipeline_id = pipeline_id
        self.name = name

class GithubProjects(Base):
    __tablename__ = 'twelvef_github_projects'

    pipeline_id = Column(Integer, primary_key=True)
    try_pipeline_id = Column(Integer, nullable=True)
    owner = Column(String(200))
    repo = Column(String(200))

    def __init__(self, pipeline_id, try_pipeline_id, owner, repo):
        self.pipeline_id = pipeline_id
        self.try_pipeline_id = try_pipeline_id
        self.owner = owner
        self.repo = repo

class GithubStatusPipelines(Base):
    __tablename__ = 'twelvef_github_status_pipelines'

    ci_id = Column(Integer, primary_key=True)
    owner = Column(String(200))
    repo = Column(String(200))
    context = Column(String(200))

    def __init__(self, ci_id, owner, repo, context):
        self.ci_id = ci_id
        self.owner = owner
        self.repo = repo
        self.context = context

class PipelineCi(Base):
    __tablename__ = 'twelvef_config_pipeline_ci'

    pipeline_id = Column(Integer, primary_key=True)
    ci_id = Column(Integer)

    def __init__(self, pipeline_id, ci_id):
        self.ci_id = ci_id
        self.pipeline_id = pipeline_id

class GithubGitPipelines(Base):
    __tablename__ = 'twelvef_github_git_pipelines'

    pipeline_id = Column(Integer, primary_key=True)
    owner = Column(String(200))
    repo = Column(String(200))
    master_branch = Column(String(200))
    staging_branch = Column(String(200))
    push_to_master = Column(Boolean)

    def __init__(self, pipeline_id, owner, repo):
        self.pipeline_id = pipeline_id
        self.owner = owner
        self.repo = repo
        self.master_branch = "master"
        self.staging_branch = "staging"
        self.push_to_master = True

Base.metadata.create_all(bind=engine)

@app.before_request
def before_request():
    g.user = None

@app.teardown_appcontext
def shutdown_session(exception=None):
    db_session.remove()
    g.user = None

def get_user():
    if g.user is None and 'user_id' in session:
        g.user = User.query.get(session['user_id'])
    return g.user

@github.access_token_getter
def token_getter():
    user = get_user()
    if user is not None:
        return user.github_access_token

@app.route('/')
def index():
    if 'user_id' not in session:
        return render_template('index.html')
    else:
        return redirect(url_for('manage'))

@app.route('/login', methods=['POST'])
def login():
    return github.authorize(scope="user,repo")

@app.route('/logout', methods=['POST'])
def logout():
    session.pop('user_id', None)
    return redirect(url_for('index'))

@app.route('/github-callback')
@github.authorized_handler
def authorized(oauth_token):
    if oauth_token is None:
        flash("Authorization failed.")
        return redirect(url_for('index'))
    g.user = User(oauth_token)
    username = github.get('user')['login']
    g.user.username = username
    user = User.query.filter_by(username=username).first()
    if user is None:
        invite = Invited.query.filter_by(username=username).first()
        if invite is None:
            flash("This service is invite-only")
            return redirect(url_for('index'))
        user = db_session.merge(g.user)
        g.user = user
        db_session.add(user)
        db_session.commit()
    elif user.github_access_token != oauth_token:
        user.github_access_token = oauth_token
        user = db_session.merge(user)
        db_session.commit()
    session['user_id'] = user.user_id
    return redirect(url_for('manage'))

@app.route('/manage', methods=['GET', 'POST'])
def manage():
    user = get_user()
    if user is None:
        flash("Please log in")
        return logout()
    all_repos = github.get('user/repos?visibility=public', all_pages=True)
    repo_defs = []
    owner_set = {}
    edit = None
    default_context = 'continuous-integration/travis-ci/push'
    filter_owner = request.args.get('owner')
    if filter_owner is None and request.method == "GET" and \
            request.args.get("edit") is None:
        filter_owner = user.username
    elif filter_owner == "-":
        filter_owner = None
    for repo in all_repos:
        if not repo['permissions']['admin']:
            continue
        owner_set[repo['owner']['login']] = repo['owner']
        if filter_owner is not None and filter_owner != repo['owner']['login']:
            continue
        on_repo = GithubProjects.query \
            .filter_by(owner=repo['owner']['login'],repo=repo['name']) \
            .first()
        repo_def = {
            "owner": repo['owner']['login'],
            "repo": repo['name'],
            "name": repo['full_name'],
            "id": repo['id'],
            "present": on_repo is not None,
        }
        if request.method == 'POST':
            if 'add' in request.form and \
                    int(request.form['add']) == repo['id'] and \
                    on_repo is None:
                return add_repo(repo, default_context)
            elif 'remove' in request.form and \
                    int(request.form['remove']) == repo['id'] and \
                    on_repo is not None:
                return remove_repo(repo, on_repo)
            elif 'edit' in request.form and \
                    int(request.form['edit']) == repo['id'] and \
                    on_repo is not None:
                return edit_repo(on_repo)
        repo_defs.append(repo_def)
        if on_repo is not None:
            if request.args.get('edit') and \
                    request.args.get('edit') == str(repo['id']):
                edit = repo_def
                cis = PipelineCi.query.filter_by(pipeline_id=on_repo.pipeline_id)
                contexts = ""
                for ci in cis:
                    on_status = GithubStatusPipelines.query \
                        .filter_by(ci_id=ci.ci_id) \
                        .first()
                    if contexts != "": contexts = contexts + ","
                    contexts = contexts + on_status.context
                on_git = GithubGitPipelines.query \
                    .filter_by(pipeline_id=on_repo.pipeline_id) \
                    .first()
                edit['contexts'] = contexts
                edit['master_branch'] = on_git.master_branch
                edit['staging_branch'] = on_git.staging_branch
    # Order: <me> <other users> <orgs>
    def owner_key(item):
        if item['login'] == user.username:
            return "0"
        elif item['type'] == 'User':
            return "0" + item['login']
        else:
            return "1" + item['login']
    if len(owner_set) > 1:
        owner_defs = sorted(
            (item[1] for item in owner_set.items()),
            key=owner_key
        )
    return render_template(
        'manage.html',
        username=user.username,
        repo_defs=repo_defs,
        owner_defs=owner_defs,
        filter_owner=filter_owner,
        edit=edit,
        invite_count=user.invite_count,
        base_url=app.config['BOT_BASEURL'],
    )

def add_repo(repo, context):
    user = get_user()
    # Add repository to our database
    pipeline = Pipeline(None, repo['full_name'])
    db_session.add(pipeline)
    status = GithubStatusPipelines(
        None,
        repo['owner']['login'],
        repo['name'],
        context
    )
    db_session.add(status)
    db_session.flush()
    pipeline_id = pipeline.pipeline_id
    ci_id = status.ci_id
    ci = PipelineCi(pipeline_id, ci_id)
    db_session.add(ci)
    on_repo = GithubProjects(
        pipeline_id,
        None,
        repo['owner']['login'],
        repo['name']
    )
    db_session.add(on_repo)
    git = GithubGitPipelines(
        pipeline_id,
        repo['owner']['login'],
        repo['name']
    )
    db_session.add(git)
    db_session.commit()
    # Add our account as a collaborator on Github
    headers = {
        "Content-Type": "application/vnd.github.swamp-thing-preview+json",
    }
    invite = github.request(
        'PUT',
        'repos/' + repo['full_name'] + '/collaborators/' + \
            app.config['BOT_USERNAME'],
        headers=headers,
    )
    headers = {
        "Authorization": "token " + app.config['BOT_ACCESS_TOKEN'],
        "Content-Type": "application/vnd.github.swamp-thing-preview+json",
    }
    requests.request(
        'PATCH',
        invite.url,
        headers=headers,
    )
    # Add our user as a member of the organization, if we aren't already
    if repo['owner']['type'] == 'Organization':
        add_me_to_org(repo['owner']['login'])
    # Add our webhooks
    github.post(
        'repos/' + repo['full_name'] + '/hooks',
        {
            "name": "web",
            "active": True,
            "config": {
                "url": app.config['BOT_BASEURL'] + '/github-notice',
                "content_type": "json",
                "secret": app.config['BOT_NOTICE_SECRET']
            },
            "events": [ "issue_comment", "pull_request", "team_add" ]
        }
    )
    github.post(
        'repos/' + repo['full_name'] + '/hooks',
        {
            "name": "web",
            "active": True,
            "config": {
                "url": app.config['BOT_BASEURL'] + '/github-status',
                "content_type": "json",
                "secret": app.config['BOT_STATUS_SECRET']
            },
            "events": [ "status" ]
        }
    )
    flash("Added successfully")
    return redirect(url_for('manage'))

def remove_repo(repo, on_repo):
    user = get_user()
    # Remove from our database
    pipeline_id = on_repo.pipeline_id
    db_session.delete(on_repo)
    pipeline = Pipeline.query.filter_by(pipeline_id=pipeline_id).first()
    if not pipeline is None: db_session.delete(pipeline)
    cis = PipelineCi.query.filter_by(pipeline_id=pipeline_id)
    for ci in cis:
        status = GithubStatusPipelines.query \
                .filter_by(ci_id=ci.ci_id) \
                .first();
        if not status is None: db_session.delete(status)
        db_session.delete(ci)
    git = GithubGitPipelines.query \
            .filter_by(pipeline_id=pipeline_id) \
            .first();
    if not git is None: db_session.delete(git)
    db_session.commit()
    # Remove our collaboratorship
    github.raw_request(
        'DELETE',
        'repos/' + repo['full_name'] + '/collaborators/' + \
            app.config['BOT_USERNAME']
    )
    # Remove our webhooks
    hooks = github.get(
        'repos/' + repo['full_name'] + '/hooks'
    )
    my_urls = {
        app.config['BOT_BASEURL'] + '/github-notice',
        app.config['BOT_BASEURL'] + '/github-status',
    }
    for webhook in hooks:
        if webhook['name'] == 'web' and webhook['config']['url'] in my_urls:
            github.request(
                'DELETE',
                'repos/' + repo['full_name'] + '/hooks/' + str(webhook['id'])
            )
    flash("Deleted successfully")
    return redirect(url_for('manage'))

def edit_repo(project):
    user = get_user()
    pipeline_id = project.pipeline_id
    cis = PipelineCi.query.filter_by(pipeline_id=pipeline_id)
    for ci in cis:
        db_session.delete(ci)
        status = GithubStatusPipelines.query \
                .filter_by(ci_id=ci.ci_id) \
                .first();
        db_session.delete(status)
    for context in request.form['contexts'].replace(" ","").split(","):
        status = GithubStatusPipelines(None, project.owner, project.repo, context)
        db_session.add(status)
        db_session.flush()
        ci = PipelineCi(pipeline_id, status.ci_id)
        db_session.add(ci)
    git = GithubGitPipelines.query \
            .filter_by(pipeline_id=pipeline_id) \
            .first();
    git.master_branch = request.form['master_branch']
    git.staging_branch = request.form['staging_branch']
    db_session.commit()
    flash("Saved successfully")
    return redirect(url_for('manage'))

def add_me_to_org(login):
    invite = github.request(
        'PUT',
        'orgs/' + login + '/memberships/' + \
            app.config['BOT_USERNAME'],
    )
    if invite['state'] != "active":
        headers = {
            "Authorization": "token " + app.config['BOT_ACCESS_TOKEN'],
            "Content-Type": "application/json",
        }
        requests.request(
            'PATCH',
            "https://api.github.com/user/memberships/orgs/" + login,
            data=json.dumps({
                "state": "active"
            }),
            headers=headers
        ).raise_for_status()

@app.route('/invite', methods=['POST'])
def invite():
    user = get_user()
    if user is None:
        flash("Please log in")
        return redirect(url_for('index'))
    if user.invite_count <= 0:
        flash("You're out of invites")
        return redirect(url_for('manage'))
    invite = Invited.query.filter_by(username=request.form['username'])
    if invite.first() is not None:
        flash("This person is already invited")
        return redirect(url_for('manage'))
    invite = Invited(request.form['username'])
    db_session.add(invite)
    user.invite_count = user.invite_count - 1
    db_session.commit()
    flash("Invitation recorded; now let them know!")
    return redirect(url_for('manage'))


text:
title: Inheriting RadGrid
page_title: Inheriting RadGrid | RadGrid for ASP.NET AJAX Documentation
description: Inheriting RadGrid
slug: grid/inheritance/inheriting-radgrid
tags: inheriting,radgrid
published: True
position: 0
---

# Inheriting RadGrid

##

Let's say you have an assembly called **InheritedGrid.dll** and the grid name is **InheritedGrid**. Furthermore, you have a **TagPrefix** assembly attribute with value of **myRadG**. By this means VS designer will not have any problem recognizing the tag prefix when you drag and drop this control from the toolbox to the designer surface. Merely add the following line in the AssemblyInfo file in your application:

**[assembly: TagPrefix("MyBaseNamespace.MyControls","myRadG")]**

When you create applications with the inherited control version, you should have both of the following Register directives in the aspx of the page:

**<%@ Register TagPrefix="radG" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI"%>**
**<%@ Register TagPrefix="myRadG" Namespace="MyBaseNamespace.MyControls" Assembly="InheritedGrid"%>**

The first one states that you will reference classes declared in the **Telerik.Web.UI**assembly. The second one is your assembly, where the inherited controls are.

Then you can add instances of your custom grid control on the page:

**<mytelerik: InheritedGrid ... >**

**</mytelerik: InheritedGrid>**

But the **GridTableView**, **GridBoundColumn** etc. classes are defined in the **Telerik.Web.UI** assembly. That is why the declaration in your grid body should have the following syntax:

````ASP.NET
<mytelerik:InheritedGrid ... >
    <MasterTableView>
        <Columns>
            <telerik:GridBoundColumn ...>
            </telerik: GridBoundColumn>
        </Columns>
        <DetailTables>
            <telerik:GridTableView ...>
            </telerik:GridTableView>
        </DetailTables>
    <MasterTableView>
</mytelerik:InheritedGrid>
````

This should be enough for the VS designer to register the tag prefixes the right way. Then the Telerik RadGrid Property Builder will serialize correctly the design time markup.

If you would like to inherit the **GridTableView** object for your grid, here are some basic rules that you need to follow:

````ASP.NET
<%@ Register Namespace="MyNamespace" TagPrefix="my" %>
 ...
        <my:MyGrid ID="MyGrid1" runat="server" OnNeedDataSource="MyGrid1_NeedDataSource">
            <MasterTableView>
                <DetailTables>
                    <my:MyGridTableView />
                </DetailTables>
            </MasterTableView>
        </my:MyGrid>
````
````C#
namespace MyNamespace
{
    public class MyGrid : RadGrid
    {
            public override GridTableView CreateTableView()
            {
                return new MyGridTableView(this);
            }
    }

    public class MyGridTableView : GridTableView
    {
            public MyGridTableView()
            {
                //
            }

            public MyGridTableView(RadGrid owner) : base(owner)
            {
                //
            }
    }
}

````
````VB
Namespace MyNamespace
 Public Class MyGrid  Inherits RadGrid
            Public Overloads Overrides Function CreateTableView() As GridTableView
                Return New MyGridTableView(Me)
            End Function
        End Class

 Public Class MyGridTableView  Inherits GridTableView
            Public Sub New()
                '
            End Sub

  Public Sub New(ByVal owner As RadGrid)   MyBase.New(owner)
                '
            End Sub
        End Class
    End Namespace
````

Basically, you need to override the **CreateTableView()** method of the RadGrid class and return an instance of your custom **GridTableView**.

As the inheritance of a control is an ASP.NET feature, these rules are applicable to inherit and use ASP.NET server control.

>note Note that we do not support issues with inherited versions of RadGrid and the purpose of this topic is to provide basic instructions how to inherit your custom grid control from RadGrid.
>


text:
<?php

require_once('include/sqAES.php');
require_once('include/javascrypt.php');

Header('Content-type: text/plain');

echo "What the browser POSTED:\n";
print_r($_POST);

javascrypt::decryptform();

echo "Unencrypted POST:\n";
print_r($_POST);

?>


text:
#ifndef IEEE80211_RATE_H
#define IEEE80211_RATE_H

#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <net/mac80211.h>
#include "ieee80211_i.h"
#include "sta_info.h"
#include "driver-ops.h"

struct rate_control_ref {
	struct ieee80211_local *local;
	const struct rate_control_ops *ops;
	void *priv;
};

void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,
			   struct sta_info *sta,
			   struct ieee80211_tx_rate_control *txrc);

static inline void rate_control_tx_status(struct ieee80211_local *local,
					  struct ieee80211_supported_band *sband,
					  struct sta_info *sta,
					  struct sk_buff *skb)
{
	struct rate_control_ref *ref = local->rate_ctrl;
	struct ieee80211_sta *ista = &sta->sta;
	void *priv_sta = sta->rate_ctrl_priv;
	struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);

	if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
		return;

	spin_lock_bh(&sta->rate_ctrl_lock);
	if (ref->ops->tx_status)
		ref->ops->tx_status(ref->priv, sband, ista, priv_sta, skb);
	else
		ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info);
	spin_unlock_bh(&sta->rate_ctrl_lock);
}

static inline void
rate_control_tx_status_noskb(struct ieee80211_local *local,
			     struct ieee80211_supported_band *sband,
			     struct sta_info *sta,
			     struct ieee80211_tx_info *info)
{
	struct rate_control_ref *ref = local->rate_ctrl;
	struct ieee80211_sta *ista = &sta->sta;
	void *priv_sta = sta->rate_ctrl_priv;

	if (!ref || !test_sta_flag(sta, WLAN_STA_RATE_CONTROL))
		return;

	if (WARN_ON_ONCE(!ref->ops->tx_status_noskb))
		return;

	spin_lock_bh(&sta->rate_ctrl_lock);
	ref->ops->tx_status_noskb(ref->priv, sband, ista, priv_sta, info);
	spin_unlock_bh(&sta->rate_ctrl_lock);
}

void rate_control_rate_init(struct sta_info *sta);
void rate_control_rate_update(struct ieee80211_local *local,
				    struct ieee80211_supported_band *sband,
				    struct sta_info *sta, u32 changed);

static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
					   struct sta_info *sta, gfp_t gfp)
{
	spin_lock_init(&sta->rate_ctrl_lock);
	return ref->ops->alloc_sta(ref->priv, &sta->sta, gfp);
}

static inline void rate_control_free_sta(struct sta_info *sta)
{
	struct rate_control_ref *ref = sta->rate_ctrl;
	struct ieee80211_sta *ista = &sta->sta;
	void *priv_sta = sta->rate_ctrl_priv;

	ref->ops->free_sta(ref->priv, ista, priv_sta);
}

static inline void rate_control_add_sta_debugfs(struct sta_info *sta)
{
#ifdef CONFIG_MAC80211_DEBUGFS
	struct rate_control_ref *ref = sta->rate_ctrl;
	if (ref && sta->debugfs_dir && ref->ops->add_sta_debugfs)
		ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv,
					  sta->debugfs_dir);
#endif
}

static inline void rate_control_remove_sta_debugfs(struct sta_info *sta)
{
#ifdef CONFIG_MAC80211_DEBUGFS
	struct rate_control_ref *ref = sta->rate_ctrl;
	if (ref && ref->ops->remove_sta_debugfs)
		ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv);
#endif
}

/* Get a reference to the rate control algorithm. If `name' is NULL, get the
 * first available algorithm. */
int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
				 const char *name);
void rate_control_deinitialize(struct ieee80211_local *local);

/* Rate control algorithms */
#ifdef CONFIG_MAC80211_RC_MINSTREL
int rc80211_minstrel_init(void);
void rc80211_minstrel_exit(void);
#else
static inline int rc80211_minstrel_init(void)
{
	return 0;
}
static inline void rc80211_minstrel_exit(void)
{
}
#endif

#ifdef CONFIG_MAC80211_RC_MINSTREL_HT
int rc80211_minstrel_ht_init(void);
void rc80211_minstrel_ht_exit(void);
#else
static inline int rc80211_minstrel_ht_init(void)
{
	return 0;
}
static inline void rc80211_minstrel_ht_exit(void)
{
}
#endif

#endif /* IEEE80211_RATE_H */