code
stringlengths 3
1.01M
| repo_name
stringlengths 5
116
| path
stringlengths 3
311
| language
stringclasses 30
values | license
stringclasses 15
values | size
int64 3
1.01M
|
|---|---|---|---|---|---|
/*
* TNTConcept Easy Enterprise Management by Autentia Real Bussiness Solution S.L.
* Copyright (C) 2007 Autentia Real Bussiness Solution S.L.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Autentia Real Bussiness Solution S.L.
* Tlf: +34 91 675 33 06, +34 655 99 11 72
* Fax: +34 91 656 65 04
* info@autentia.com
*/
package com.autentia.intra.dao.hibernate;
import com.autentia.intra.businessobject.OfferRejectReason;
import com.autentia.intra.dao.DataAccException;
import com.autentia.intra.dao.IDataAccessObject;
import com.autentia.intra.dao.SearchCriteria;
import com.autentia.intra.dao.SortCriteria;
import com.autentia.intra.util.SpringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.List;
public class OfferRejectReasonDAO extends HibernateManagerBase implements IDataAccessObject<OfferRejectReason> {
/* OfferRejectReason - generated by stajanov (do not edit/delete) */
/**
* Logger
*/
private static final Log log = LogFactory.getLog(OfferRejectReasonDAO.class);
/**
* Get default OfferRejectReasonDAO as defined in Spring's configuration file.
*
* @return the default singleton OfferRejectReasonDAO
*/
public static OfferRejectReasonDAO getDefault() {
return (OfferRejectReasonDAO) SpringUtils.getSpringBean("daoOfferRejectReason");
}
/**
* Constructor
*
* @deprecated do not construct DAOs alone: use Spring's declared beans
*/
public OfferRejectReasonDAO() {
super(false);
}
/**
* Retrieve a OfferRejectReason object from database given its id
*
* @param id primary key of OfferRejectReason object
* @return the OfferRejectReason object identified by the id
* @throws DataAccException on error
*/
public OfferRejectReason getById(int id) throws DataAccException {
return super.getByPk(OfferRejectReason.class, id);
}
/**
* Get all OfferRejectReason objects from database sorted by the given criteria
*
* @param crit the sorting criteria
* @return a list with all existing OfferRejectReason objects
* @throws DataAccException on error
*/
public List<OfferRejectReason> search(SortCriteria crit) throws DataAccException {
return super.list(OfferRejectReason.class, crit);
}
/**
* Get specified OfferRejectReason objects from database sorted by the given criteria
*
* @param search search criteria
* @param sort the sorting criteria
* @return a list with OfferRejectReason objects matching the search criteria
* @throws DataAccException on error
*/
public List<OfferRejectReason> search(SearchCriteria search, SortCriteria sort) throws DataAccException {
return super.search(OfferRejectReason.class, search, sort);
}
/**
* Insert a new OfferRejectReason object in database
*
* @param dao the OfferRejectReason object to insert
* @throws DataAccException on error
*/
public void insert(OfferRejectReason dao) throws DataAccException {
super.insert(dao);
}
/**
* Update an existing OfferRejectReason object in database
*
* @param dao the OfferRejectReason object to update
* @throws DataAccException on error
*/
public void update(OfferRejectReason dao) throws DataAccException {
super.update(dao, dao.getId());
}
/**
* Delete an existing OfferRejectReason object in database
*
* @param dao the OfferRejectReason object to update
* @throws DataAccException on error
*/
public void delete(OfferRejectReason dao) throws DataAccException {
super.delete(dao, dao.getId());
}
/* OfferRejectReason - generated by stajanov (do not edit/delete) */
}
|
terrex/tntconcept-materials-testing
|
src/main/java/com/autentia/intra/dao/hibernate/OfferRejectReasonDAO.java
|
Java
|
gpl-2.0
| 4,553
|
/*
* common.c
*
* Copyright (c) 1999 Pekka Riikonen, priikone@poseidon.pspt.fi.
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "signal.h"
#include "common.h"
/*
* Generates Portable Bitmap picture file (type P5 PGM).
*/
void generate_pgm(int o_fp, int o_fh, int o_fv, double o_tone,
double o_carr, int o_res_x, int o_res_y, int o_square)
{
int i, x, y;
double p, R;
Signal ns;
double *signal;
ns.o_fp = o_fp;
ns.o_fh = o_fh;
ns.o_fv = o_fv;
ns.o_tone = o_tone;
ns.o_carr = o_carr;
ns.o_res_x = o_res_x;
ns.o_res_y = o_res_y;
ns.o_square = o_square;
signal = (double *)NULL;
signal = generate_am_signal(&ns);
fprintf(stdout, "P5\n");
fprintf(stdout, "%d %d 255\n", o_res_x, o_res_y);
srand((unsigned int)time(0));
i = 0;
for (y = 0; y < o_res_y; y++) {
for (x = 0; x < o_res_x; x++) {
R = 1+(double) (1.0*rand() / (RAND_MAX+1.0)) - 1;
p = ((double)127.5 + signal[i++]) + R;
if (p < 0)
p = 0;
if (p > 255)
p = 255;
putchar((int)p);
}
}
fflush(stdout);
if (signal)
free(signal);
}
|
priikone/tempest-AM
|
common.c
|
C
|
gpl-2.0
| 1,676
|
/* global Ext */
/* @class Ext.ux.ManagedIFrame
* Version: 1.2
* Author: Doug Hendricks. doug[always-At]theactivegroup.com
* Copyright 2007-2008, Active Group, Inc. All rights reserved.
*
************************************************************************************
* This file is distributed on an AS IS BASIS WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
************************************************************************************
License: ux.ManagedIFrame and ux.ManagedIFramePanel 1.2 are licensed under the terms of
the Open Source LGPL 3.0 license: http://www.gnu.org/licenses/lgpl.html
Commercial use is prohibited without a Commercial License. See http://licensing.theactivegroup.com.
Donations are welcomed: http://donate.theactivegroup.com
* <p> An Ext.Element harness for iframe elements.
Adds Ext.UpdateManager(Updater) support and a compatible 'update' method for
writing content directly into an iFrames' document structure.
Signals various DOM/document states as the frames content changes with 'domready',
'documentloaded', and 'exception' events. The domready event is only raised when
a proper security context exists for the frame's DOM to permit modification.
(ie, Updates via Updater or documents retrieved from same-domain servers).
Frame sand-box permits eval/script-tag writes of javascript source.
(See execScript, writeScript, and loadFunction methods for more info.)
* Usage:<br>
* <pre><code>
* // Harnessed from an existing Iframe from markup:
* var i = new Ext.ux.ManagedIFrame("myIframe");
* // Replace the iFrames document structure with the response from the requested URL.
* i.load("http://myserver.com/index.php", "param1=1&param2=2");
* // Notes: this is not the same as setting the Iframes src property !
* // Content loaded in this fashion does not share the same document namespaces as it's parent --
* // meaning, there (by default) will be no Ext namespace defined in it since the document is
* // overwritten after each call to the update method, and no styleSheets.
* </code></pre>
* <br>
* @cfg {Boolean/Object} autoCreate True to auto generate the IFRAME element, or a {@link Ext.DomHelper} config of the IFRAME to create
* @cfg {String} html Any markup to be applied to the IFRAME's document content when rendered.
* @cfg {Object} loadMask An {@link Ext.LoadMask} config or true to mask the iframe while using the update or setSrc methods (defaults to false).
* @cfg {Object} src The src attribute to be assigned to the Iframe after initialization (overrides the autoCreate config src attribute)
* @constructor
* @param {Mixed} el, Config object The iframe element or it's id to harness or a valid config object.
* Release: 1.2 (8/22/2008) FF3 Compatibility Fixes, loadMask tweaks
1.1 (4/13/2008) Adds Ext.Element, CSS Selectors (query,select) fly, and CSS
interface support (same-domain only)
Adds blur,focus,unload events (same-domain only)
*/
(function(){
var EV = Ext.lib.Event;
Ext.ux.ManagedIFrame = function(){
var args=Array.prototype.slice.call(arguments, 0)
,el = Ext.get(args[0])
,config = args[0];
if(el && el.dom && el.dom.tagName == 'IFRAME'){
config = args[1] || {};
}else{
config = args[0] || args[1] || {};
el = config.autoCreate?
Ext.get(Ext.DomHelper.append(config.autoCreate.parent||document.body,
Ext.apply({tag:'iframe', src:(Ext.isIE&&Ext.isSecure)?Ext.SSL_SECURE_URL:''},config.autoCreate))):null;
}
if(!el || el.dom.tagName != 'IFRAME') return el;
el.dom.name || (el.dom.name = el.dom.id); //make sure there is a valid frame name
el.dom.mifId = el.dom.id; //create an un-protected reference for browsers which prevent access to 'id'(FF3).
this.addEvents({
/**
* @event focus
* Fires when the frame gets focus.
* @param {Ext.ux.ManagedIFrame} this
* @param {Ext.Event}
* Note: This event is only available when overwriting the iframe document using the update method and to pages
* retrieved from a "same domain".
* Returning false from the eventHandler [MAY] NOT cancel the event, as this event is NOT ALWAYS cancellable in all browsers.
*/
"focus" : true,
/**
* @event blur
* * Fires when the frame is blurred (loses focus).
* @param {Ext.ux.ManagedIFrame} this
* @param {Ext.Event}
* Note: This event is only available when overwriting the iframe document using the update method and to pages
* retrieved from a "same domain".
* Returning false from the eventHandler [MAY] NOT cancel the event, as this event is NOT ALWAYS cancellable in all browsers.
*/
"blur" : true,
/**
* @event unload
* * Fires when(if) the frames window object raises the unload event
* @param {Ext.ux.ManagedIFrame} this
* @param {Ext.Event}
* Note: This event is only available when overwriting the iframe document using the update method and to pages
* retrieved from a "same domain".
* Note: Opera does not raise this event.
*/
"unload" : true,
/**
* @event domready
* Fires ONLY when an iFrame's Document(DOM) has reach a state where the DOM may be manipulated (ie same domain policy)
* @param {Ext.ux.ManagedIFrame} this
* Note: This event is only available when overwriting the iframe document using the update method and to pages
* retrieved from a "same domain".
* Returning false from the eventHandler stops further event (documentloaded) processing.
*/
"domready" : true,
/**
* @event documentloaded
* Fires when the iFrame has reached a loaded/complete state.
* @param {Ext.ux.ManagedIFrame} this
*/
"documentloaded" : true,
/**
* @event exception
* Fires when the iFrame raises an error
* @param {Ext.ux.ManagedIFrame} this
* @param {Object/string} exception
*/
"exception" : true,
/**
* @event message
* Fires upon receipt of a message generated by window.sendMessage method of the embedded Iframe.window object
* @param {Ext.ux.ManagedIFrame} this
* @param {object} message (members: type: {string} literal "message",
* data {Mixed} [the message payload],
* domain [the document domain from which the message originated ],
* uri {string} the document URI of the message sender
* source (Object) the window context of the message sender
* tag {string} optional reference tag sent by the message sender
*/
"message" : true
/**
* Alternate event handler syntax for message:tag filtering
* @event message:tag
* Fires upon receipt of a message generated by window.sendMessage method
* which includes a specific tag value of the embedded Iframe.window object
* @param {Ext.ux.ManagedIFrame} this
* @param {object} message (members: type: {string} literal "message",
* data {Mixed} [the message payload],
* domain [the document domain from which the message originated ],
* uri {string} the document URI of the message sender
* source (Object) the window context of the message sender
* tag {string} optional reference tag sent by the message sender
*/
//"message:tagName" is supported for X-frame messaging
});
if(config.listeners){
this.listeners=config.listeners;
Ext.ux.ManagedIFrame.superclass.constructor.call(this);
}
Ext.apply(el,this); // apply this class interface ( pseudo Decorator )
el.addClass('x-managed-iframe');
if(config.style){
el.applyStyles(config.style);
}
el._maskEl = el.parent('.x-managed-iframe-mask')||el.parent().addClass('x-managed-iframe-mask');
Ext.apply(el,{
disableMessaging : config.disableMessaging===true
,loadMask : Ext.apply({msg:'Loading..'
,msgCls:'x-mask-loading'
,maskEl: el._maskEl
,hideOnReady:true
,disabled:!config.loadMask},config.loadMask)
//Hook the Iframes loaded state handler
,_eventName : Ext.isIE?'onreadystatechange':'onload'
,_windowContext : null
,eventsFollowFrameLinks : typeof config.eventsFollowFrameLinks=='undefined'?
true : config.eventsFollowFrameLinks
});
el.dom[el._eventName] = el.loadHandler.createDelegate(el);
var um = el.updateManager=new Ext.UpdateManager(el,true);
um.showLoadIndicator= config.showLoadIndicator || false;
if(config.src){
el.setSrc(config.src);
}else{
var content = config.html || config.content || false;
if(content){
el.update.defer(10,el,[content]); //allow frame to quiesce
}
}
return Ext.ux.ManagedIFrame.Manager.register(el);
};
var MIM = Ext.ux.ManagedIFrame.Manager = function(){
var frames = {};
//private DOMFrameContentLoaded handler for browsers that support it.
var readyHandler = function(e, target){
//use the unprotected DOM Id reference first
try{
var id =target?target.mifId:null, frame;
if((frame = this.getFrameById(id || target.id)) && frame._frameAction){
frame.loadHandler({type:'domready'});
}
}catch(rhEx){}
};
var implementation= {
shimCls : 'x-frame-shim',
register :function(frame){
frame.manager = this;
frames[frame.id] = frames[frame.dom.name] = {ref:frame, elCache:{}};
return frame;
},
deRegister :function(frame){
frame._unHook();
delete frames[frame.id];
delete frames[frame.dom.name];
},
hideShims : function(){
if(!this.shimApplied)return;
Ext.select('.'+this.shimCls,true).removeClass(this.shimCls+'-on');
this.shimApplied = false;
},
/* Mask ALL ManagedIframes (eg. when a region-layout.splitter is on the move.)*/
showShims : function(){
if(!this.shimApplied){
this.shimApplied = true;
//Activate the shimCls globally
Ext.select('.'+this.shimCls,true).addClass(this.shimCls+'-on');
}
},
getFrameById : function(id){
return typeof id == 'string'?(frames[id]?frames[id].ref||null:null):null;
},
getFrameByName : function(name){
return this.getFrameById(name);
},
//retrieve the internal frameCache object
getFrameHash : function(frame){
return frame.id?frames[frame.id]:null;
},
//to be called under the scope of the managing MIF
eventProxy : function(e){
if(!e)return;
e = Ext.EventObject.setEvent(e);
var be=e.browserEvent||e;
//same-domain unloads should clear ElCache for use with the next document rendering
if(e.type == 'unload'){ this._unHook(); }
if(!be['eventPhase'] || (be['eventPhase'] == (be['AT_TARGET']||2))){
return this.fireEvent(e.type, e);
}
},
_flyweights : {},
destroy : function(){
if(this._domreadySignature ){
Ext.EventManager.un.apply(Ext.EventManager,this._domreadySignature);
}
},
//safe removal of embedded frame elements
removeNode : Ext.isIE ?
function(frame, n){
frame = MIM.getFrameHash(frame);
if(frame && n && n.tagName != 'BODY'){
d = frame.scratchDiv || (frame.scratchDiv = frame.getDocument().createElement('div'));
d.appendChild(n);
d.innerHTML = '';
}
}
: function(frame, n){
if(n && n.parentNode && n.tagName != 'BODY'){
n.parentNode.removeChild(n);
}
}
};
if(document.addEventListener){ //for Gecko and Opera and any who might support it later
Ext.EventManager.on.apply(Ext.EventManager,implementation._domreadySignature=[window,"DOMFrameContentLoaded", readyHandler , implementation]);
}
Ext.EventManager.on(window,'beforeunload', implementation.destroy, implementation);
return implementation;
}();
MIM.showDragMask = MIM.showShims;
MIM.hideDragMask = MIM.hideShims;
//Provide an Ext.Element interface to frame document elements
MIM.El =function(frame, el, forceNew){
var frameObj;
frame = (frameObj = MIM.getFrameHash(frame))?frameObj.ref:null ;
if(!frame ){ return null; }
var elCache = frameObj.elCache || (frameObj.elCache = {});
var dom = frame.getDom(el);
if(!dom){ // invalid id/element
return null;
}
var id = dom.id;
if(forceNew !== true && id && elCache[id]){ // element object already exists
return elCache[id];
}
/**
* The DOM element
* @type HTMLElement
*/
this.dom = dom;
/**
* The DOM element ID
* @type String
*/
this.id = id || Ext.id(dom);
};
MIM.El.get =function(frame, el){
var ex, elm, id, doc;
if(!frame || !el ){ return null; }
var frameObj;
frame = (frameObj = MIM.getFrameHash(frame))?frameObj.ref:null ;
if(!frame ){ return null;}
var elCache = frameObj.elCache || (frameObj.elCache = {} );
if(!(doc = frame.getDocument())){ return null; }
if(typeof el == "string"){ // element id
if(!(elm = frame.getDom(el))){
return null;
}
if(ex = elCache[el]){
ex.dom = elm;
}else{
ex = elCache[el] = new MIM.El(frame, elm);
}
return ex;
}else if(el.tagName){ // dom element
if(!(id = el.id)){
id = Ext.id(el);
}
if(ex = elCache[id]){
ex.dom = el;
}else{
ex = elCache[id] = new MIM.El(frame, el);
}
return ex;
}else if(el instanceof MIM.El){
if(el != frameObj.docEl){
el.dom = frame.getDom(el.id) || el.dom; // refresh dom element in case no longer valid,
// catch case where it hasn't been appended
elCache[el.id] = el; // in case it was created directly with Element(), let's cache it
}
return el;
}else if(el.isComposite){
return el;
}else if(Ext.isArray(el)){
return frame.select(el);
}else if(el == doc){
// create a bogus element object representing the document object
if(!frameObj.docEl){
var f = function(){};
f.prototype = MIM.El.prototype;
frameObj.docEl = new f();
frameObj.docEl.dom = doc;
}
return frameObj.docEl;
}
return null;
};
Ext.apply(MIM.El.prototype,Ext.Element.prototype);
Ext.extend(Ext.ux.ManagedIFrame , Ext.util.Observable,
{
src : null ,
resetUrl :Ext.isIE&&Ext.isSecure?Ext.SSL_SECURE_URL: 'about:blank' ,
/**
* Sets the embedded Iframe src property.
* @param {String/Function} url (Optional) A string or reference to a Function that returns a URI string when called
* @param {Boolean} discardUrl (Optional) If not passed as <tt>false</tt> the URL of this action becomes the default SRC attribute for
* this iframe, and will be subsequently used in future setSrc calls (emulates autoRefresh by calling setSrc without params).
* Note: invoke the function with no arguments to refresh the iframe based on the current src value.
*/
setSrc : function(url, discardUrl, callback){
var src = url || this.src || this.resetUrl;
this._windowContext = null;
this._unHook();
this._frameAction = this.frameInit= this._domReady =false;
if(Ext.isOpera){ this.reset(); }
this._callBack = callback || false;
this.showMask();
(function(){
var s = typeof src == 'function'?src()||'':src;
try{
this._frameAction = true; //signal listening now
this.dom.src = s;
this.frameInit= true; //control initial event chatter
this.checkDOM();
}catch(ex){ this.fireEvent('exception', this, ex); }
}).defer(100,this);
if(discardUrl !== true){ this.src = src; }
return this;
},
reset : function(src, callback){
this.dom.src = src || this.resetUrl;
if(typeof callback == 'function'){ callback.defer(100);}
return this;
},
//Private: script removal RegeXp
scriptRE : /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/gi
,
/*
* Write(replacing) string content into the IFrames document structure
* @param {String} content The new content
* @param {Boolean} loadScripts (optional) true to also render and process embedded scripts
* @param {Function} callback (optional) Callback when update is complete.
*/
update : function(content,loadScripts,callback){
loadScripts = loadScripts || this.getUpdateManager().loadScripts || false;
content = Ext.DomHelper.markup(content||'');
content = loadScripts===true ? content:content.replace(this.scriptRE , "");
var doc;
if(doc = this.getDocument()){
this._frameAction = !!content.length;
this._windowContext = this.src = null;
this._callBack = callback || false;
this._unHook();
this.showMask();
doc.open();
doc.write(content);
doc.close();
this.frameInit= true; //control initial event chatter
if(this._frameAction){
this.checkDOM();
} else {
this.hideMask(true);
if(this._callBack)this._callBack();
}
}else{
this.hideMask(true);
if(this._callBack)this._callBack();
}
return this;
},
/* Enables/disables x-frame messaging interface */
disableMessaging : true,
//Private, frame messaging interface (for same-domain-policy frames only)
_XFrameMessaging : function(){
//each tag gets a hash queue ($ = no tag ).
var tagStack = {'$' : [] };
var isEmpty = function(v, allowBlank){
return v === null || v === undefined || (!allowBlank ? v === '' : false);
};
window.sendMessage = function(message, tag, origin ){
var MIF;
if(MIF = arguments.callee.manager){
if(message._fromHost){
var fn, result;
//only raise matching-tag handlers
var compTag= message.tag || tag || null;
var mstack = !isEmpty(compTag)? tagStack[compTag.toLowerCase()]||[] : tagStack["$"];
for(var i=0,l=mstack.length;i<l;i++){
if(fn = mstack[i]){
result = fn.apply(fn.__scope,arguments)===false?false:result;
if(fn.__single){mstack[i] = null;}
if(result === false){break;}
}
}
return result;
}else{
message =
{type :isEmpty(tag)?'message':'message:'+tag.toLowerCase().replace(/^\s+|\s+$/g,'')
,data :message
,domain :origin || document.domain
,uri :document.documentURI
,source :window
,tag :isEmpty(tag)?null:tag.toLowerCase()
};
try{
return MIF.disableMessaging !== true
? MIF.fireEvent.call(MIF,message.type,MIF, message)
: null;
}catch(ex){} //trap for message:tag handlers not yet defined
return null;
}
}
};
window.onhostmessage = function(fn,scope,single,tag){
if(typeof fn == 'function' ){
if(!isEmpty(fn.__index)){
throw "onhostmessage: duplicate handler definition" + (tag?" for tag:"+tag:'');
}
var k = isEmpty(tag)? "$":tag.toLowerCase();
tagStack[k] || ( tagStack[k] = [] );
Ext.apply(fn,{
__tag : k
,__single : single || false
,__scope : scope || window
,__index : tagStack[k].length
});
tagStack[k].push(fn);
} else
{throw "onhostmessage: function required";}
};
window.unhostmessage = function(fn){
if(typeof fn == 'function' && typeof fn.__index != 'undefined'){
var k = fn.__tag || "$";
tagStack[k][fn.__index]=null;
}
};
}
,get :function(el){
return MIM.El.get(this, el);
}
,fly : function(el, named){
named = named || '_global';
el = this.getDom(el);
if(!el){
return null;
}
if(!MIM._flyweights[named]){
MIM._flyweights[named] = new Ext.Element.Flyweight();
}
MIM._flyweights[named].dom = el;
return MIM._flyweights[named];
}
,getDom : function(el){
var d;
if(!el || !(d = this.getDocument())){
return null;
}
return el.dom ? el.dom : (typeof el == 'string' ? d.getElementById(el) : el);
}
/**
* Creates a {@link Ext.CompositeElement} for child nodes based on the passed CSS selector (the selector should not contain an id).
* @param {String} selector The CSS selector
* @param {Boolean} unique (optional) True to create a unique Ext.Element for each child (defaults to false, which creates a single shared flyweight object)
* @return {CompositeElement/CompositeElementLite} The composite element
*/
,select : function(selector, unique){
var d;
return (d = this.getDocument())?Ext.Element.select(selector, unique, d):null;
}
/**
* Selects frame document child nodes based on the passed CSS selector (the selector should not contain an id).
* @param {String} selector The CSS selector
* @return {Array} An array of the matched nodes
*/
,query : function(selector){
var d;
return (d = this.getDocument())?Ext.DomQuery.select(selector, d):null;
}
/**
* Returns the current HTML document object as an {@link Ext.Element}.
* @return Ext.Element The document
*/
,getDoc : function(){
return this.get(this.getDocument());
}
/**
* Removes a DOM Element from the embedded documents
* @param {Element, String} node The node id or node Element to remove
*/
,removeNode : function(node){
MIM.removeNode(this,this.getDom(node));
}
//Private : clear all event listeners and Element cache
,_unHook : function(){
var elcache, h = MIM.getFrameHash(this)||{};
if( this._hooked && h && (elcache = h.elCache)){
for (var id in elcache){
var el = elcache[id];
delete elcache[id];
if(el.removeAllListeners)el.removeAllListeners();
}
if(h.docEl){
h.docEl.removeAllListeners();
h.docEl=null;
delete h.docEl;
}
}
this._hooked = this._domReady = this._domFired = false;
}
//Private execScript sandbox and messaging interface
,_renderHook : function(){
this._windowContext = this.CSS = null;
this._hooked = false;
try{
if(this.writeScript('(function(){(window.hostMIF = parent.Ext.get("'+
this.dom.id+
'"))._windowContext='+
(Ext.isIE?'window':'{eval:function(s){return eval(s);}}')+
';})();')
){
this._frameProxy || (this._frameProxy = MIM.eventProxy.createDelegate(this));
var w= this.getWindow();
EV.doAdd(w, 'focus', this._frameProxy);
EV.doAdd(w, 'blur', this._frameProxy);
EV.doAdd(w, 'unload', this._frameProxy );
if(this.disableMessaging !== true){
this.loadFunction({name:'XMessage',fn:this._XFrameMessaging},false,true);
var sm;
if(sm = w.sendMessage){
sm.manager = this;
}
}
this.CSS = new CSSInterface(this.getDocument());
}
}catch(ex){}
return this.domWritable();
},
/* dispatch a message to the embedded frame-window context */
sendMessage : function (message,tag,origin){
var win;
if(this.disableMessaging !== true && (win = this.getWindow())){
//support frame-to-frame messaging relay
tag || (tag= message.tag || '');
tag = tag.toLowerCase();
message = Ext.applyIf(message.data?message:{data:message},
{type :Ext.isEmpty(tag)?'message':'message:'+tag
,domain :origin || document.domain
,uri : document.documentURI
,source : window
,tag :tag || null
,_fromHost: this
});
return win.sendMessage?win.sendMessage.call(null,message,tag,origin): null;
}
return null;
},
_windowContext : null,
/*
Return the Iframes document object
*/
getDocument:function(){
var win=this.getWindow(), doc=null;
try{
doc = (Ext.isIE && win?win.document : null ) ||
this.dom.contentDocument ||
window.frames[this.id].document ||
null;
}catch(gdEx){
return false; //signifies probable access restriction
}
return doc;
},
//Attempt to retrieve the frames current document.body
getBody : function(){
var d;
return (d = this.getDocument())?d.body:null;
},
//Attempt to retrieve the frames current URI
getDocumentURI : function(){
var URI, d;
try{
URI = this.src && (d = this.getDocument()) ? d.location.href:null;
}catch(ex){} //will fail on NON-same-origin domains
return URI || this.src; //fallback to last known
},
/*
Return the Iframes window object
*/
getWindow:function(){
var dom= this.dom, win=null;
try{
win = dom.contentWindow||window.frames[dom.name]||null;
}catch(gwEx){}
return win;
},
/*
Print the contents of the Iframes (if we own the document)
*/
print:function(){
try{
var win = this.getWindow();
if(Ext.isIE){win.focus();}
win.print();
} catch(ex){
throw 'print exception: ' + (ex.description || ex.message || ex);
}
},
//private
destroy:function(){
this.removeAllListeners();
if(this.dom){
//unHook the Iframes loaded state handlers
this.dom[this._eventName]=null;
Ext.ux.ManagedIFrame.Manager.deRegister(this);
this._windowContext = null;
//IE Iframe cleanup
if(Ext.isIE && this.dom.src){
this.dom.src = 'javascript:false';
}
this._maskEl = null;
this.remove();
}
if(this.loadMask){ Ext.apply(this.loadMask,{masker :null ,maskEl : null});}
}
/* Returns the general DOM modification capability of the frame. */
,domWritable : function(){
return !!this._windowContext;
}
/*
* eval a javascript code block(string) within the context of the Iframes window object.
* @param {String} block A valid ('eval'able) script source block.
* @param {Boolean} useDOM - if true inserts the fn into a dynamic script tag,
* false does a simple eval on the function definition. (useful for debugging)
* <p> Note: will only work after a successful iframe.(Updater) update
* or after same-domain document has been hooked, otherwise an exception is raised.
*/
,execScript: function(block, useDOM){
try{
if(this.domWritable()){
if(useDOM){
this.writeScript(block);
}else{
return this._windowContext.eval(block);
}
}else{ throw 'execScript:non-secure context' }
}catch(ex){
this.fireEvent('exception', this, ex);
return false;
}
return true;
}
/*
* write a <script> block into the iframe's document
* @param {String} block A valid (executable) script source block.
* @param {object} attributes Additional Script tag attributes to apply to the script Element (for other language specs [vbscript, Javascript] etc.)
* <p> Note: writeScript will only work after a successful iframe.(Updater) update
* or after same-domain document has been hooked, otherwise an exception is raised.
*/
,writeScript : function(block, attributes) {
attributes = Ext.apply({},attributes||{},{type :"text/javascript",text:block});
try{
var head,script, doc= this.getDocument();
if(doc && typeof doc.getElementsByTagName != 'undefined'){
if(!(head = doc.getElementsByTagName("head")[0] )){
//some browsers (Webkit, Safari) do not auto-create
//head elements during document.write
head =doc.createElement("head");
doc.getElementsByTagName("html")[0].appendChild(head);
}
if(head && (script = doc.createElement("script"))){
for(var attrib in attributes){
if(attributes.hasOwnProperty(attrib) && attrib in script){
script[attrib] = attributes[attrib];
}
}
return !!head.appendChild(script);
}
}
}catch(ex){
//console.warn('writeScript Exception ', ex);
this.fireEvent('exception', this, ex);}
return false;
}
/*
* Eval a function definition into the iframe window context.
* args:
* @param {String/Object} name of the function or
function map object: {name:'encodeHTML',fn:Ext.util.Format.htmlEncode}
* @param {Boolean} useDOM - if true inserts the fn into a dynamic script tag,
false does a simple eval on the function definition,
* examples:
* var trim = function(s){
* return s.replace( /^\s+|\s+$/g,'');
* };
* iframe.loadFunction('trim');
* iframe.loadFunction({name:'myTrim',fn:String.prototype.trim || trim});
*/
,loadFunction : function(fn, useDOM, invokeIt){
var name = fn.name || fn;
var fn = fn.fn || window[fn];
this.execScript(name + '=' + fn, useDOM); //fn.toString coercion
if(invokeIt){
this.execScript(name+'()') ; //no args only
}
}
//Private
,showMask: function(msg,msgCls,forced){
var lmask;
if((lmask = this.loadMask) && (!lmask.disabled|| forced)){
if(lmask._vis)return;
lmask.masker || (lmask.masker = Ext.get(lmask.maskEl||this.dom.parentNode||this.wrap({tag:'div',style:{position:'relative'}})));
lmask._vis = true;
lmask.masker.mask.defer(lmask.delay||5,lmask.masker,[msg||lmask.msg , msgCls||lmask.msgCls] );
}
}
//Private
,hideMask: function(forced){
var tlm;
if((tlm = this.loadMask) && !tlm.disabled && tlm.masker ){
if(!forced && (tlm.hideOnReady!==true && this._domReady)){return;}
tlm._vis = false;
tlm.masker.unmask.defer(tlm.delay||5,tlm.masker);
}
}
/* Private
Evaluate the Iframes readyState/load event to determine its 'load' state,
and raise the 'domready/documentloaded' event when applicable.
*/
,loadHandler : function(e,target){
if(!this.frameInit || (!this._frameAction && !this.eventsFollowFrameLinks)){return;}
target || (target={});
var rstatus = (e && typeof e.type !== 'undefined'?e.type:this.dom.readyState );
switch(rstatus){
case 'loading': //IE
case 'interactive': //IE
break;
case 'domready': //MIF
if(this._domReady)return;
this._domReady = true;
if( this._hooked = this._renderHook() ){ //Only raise if sandBox injection succeeded (same domain)
this._domFired = true;
this.fireEvent("domready",this);
}
case 'domfail': //MIF
this._domReady = true;
this.hideMask();
break;
case 'load': //Gecko, Opera
case 'complete': //IE
if(!this._domReady ){ // one last try for slow DOMS.
this.loadHandler({type:'domready',id:this.id});
}
this.hideMask(true);
if(this._frameAction || this.eventsFollowFrameLinks ){
//not going to wait for the event chain, as it's not cancellable anyhow.
this.fireEvent.defer(50,this,["documentloaded",this]);
}
this._frameAction = this._frameInit = false;
if(this.eventsFollowFrameLinks){ //reset for link tracking
this._domFired = this._domReady = false;
}
if(this._callBack){
this._callBack(this);
}
break;
default:
}
this.frameState = rstatus;
}
/* Private
Poll the Iframes document structure to determine DOM ready state,
and raise the 'domready' event when applicable.
*/
,checkDOM : function(win){
if(Ext.isOpera || Ext.isGecko || !this._frameAction )return;
//initialise the counter
var n = 0
,win = win||this.getWindow()
,manager = this
,domReady = false
,max = 300;
var poll = function(){ //DOM polling for IE and others
try{
var doc = manager.getDocument(),body=null;
if(doc ===false){throw "Document Access Denied"; }
if(!manager._domReady){
domReady = !!(doc && doc.getElementsByTagName);
domReady = domReady && (body = doc.getElementsByTagName('body')[0]) && !!body.innerHTML.length;
}
}catch(ex){
n = max; //likely same-origin policy violation, so DOM is ready
}
//if the timer has reached 100 (timeout after 3 seconds)
//in practice, shouldn't take longer than 7 iterations [in kde 3
//in second place was IE6, which takes 2 or 3 iterations roughly 5% of the time]
if(!manager._frameAction || manager._domReady)return;
if((++n < max) && !domReady )
{
//try again
setTimeout(arguments.callee, 10);
return;
}
manager.loadHandler ({type:domReady?'domready':'domfail'});
};
setTimeout(poll,40);
}
});
/* Stylesheet Frame interface object */
var styleCamelRe = /(-[a-z])/gi;
var styleCamelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
var CSSInterface = function(hostDocument){
var doc;
if(hostDocument){
doc = hostDocument;
return {
rules : null,
/**
* Creates a stylesheet from a text blob of rules.
* These rules will be wrapped in a STYLE tag and appended to the HEAD of the document.
* @param {String} cssText The text containing the css rules
* @param {String} id An id to add to the stylesheet for later removal
* @return {StyleSheet}
*/
createStyleSheet : function(cssText, id){
var ss;
if(!doc)return;
var head = doc.getElementsByTagName("head")[0];
var rules = doc.createElement("style");
rules.setAttribute("type", "text/css");
if(id){
rules.setAttribute("id", id);
}
if(Ext.isIE){
head.appendChild(rules);
ss = rules.styleSheet;
ss.cssText = cssText;
}else{
try{
rules.appendChild(doc.createTextNode(cssText));
}catch(e){
rules.cssText = cssText;
}
head.appendChild(rules);
ss = rules.styleSheet ? rules.styleSheet : (rules.sheet || doc.styleSheets[doc.styleSheets.length-1]);
}
this.cacheStyleSheet(ss);
return ss;
},
/**
* Removes a style or link tag by id
* @param {String} id The id of the tag
*/
removeStyleSheet : function(id){
if(!doc)return;
var existing = doc.getElementById(id);
if(existing){
existing.parentNode.removeChild(existing);
}
},
/**
* Dynamically swaps an existing stylesheet reference for a new one
* @param {String} id The id of an existing link tag to remove
* @param {String} url The href of the new stylesheet to include
*/
swapStyleSheet : function(id, url){
this.removeStyleSheet(id);
if(!doc)return;
var ss = doc.createElement("link");
ss.setAttribute("rel", "stylesheet");
ss.setAttribute("type", "text/css");
ss.setAttribute("id", id);
ss.setAttribute("href", url);
doc.getElementsByTagName("head")[0].appendChild(ss);
},
/**
* Refresh the rule cache if you have dynamically added stylesheets
* @return {Object} An object (hash) of rules indexed by selector
*/
refreshCache : function(){
return this.getRules(true);
},
// private
cacheStyleSheet : function(ss){
if(this.rules){
this.rules = {};
}
try{// try catch for cross domain access issue
var ssRules = ss.cssRules || ss.rules;
for(var j = ssRules.length-1; j >= 0; --j){
this.rules[ssRules[j].selectorText] = ssRules[j];
}
}catch(e){}
},
/**
* Gets all css rules for the document
* @param {Boolean} refreshCache true to refresh the internal cache
* @return {Object} An object (hash) of rules indexed by selector
*/
getRules : function(refreshCache){
if(this.rules == null || refreshCache){
this.rules = {};
if(doc){
var ds = doc.styleSheets;
for(var i =0, len = ds.length; i < len; i++){
try{
this.cacheStyleSheet(ds[i]);
}catch(e){}
}
}
}
return this.rules;
},
/**
* Gets an an individual CSS rule by selector(s)
* @param {String/Array} selector The CSS selector or an array of selectors to try. The first selector that is found is returned.
* @param {Boolean} refreshCache true to refresh the internal cache if you have recently updated any rules or added styles dynamically
* @return {CSSRule} The CSS rule or null if one is not found
*/
getRule : function(selector, refreshCache){
var rs = this.getRules(refreshCache);
if(!Ext.isArray(selector)){
return rs[selector];
}
for(var i = 0; i < selector.length; i++){
if(rs[selector[i]]){
return rs[selector[i]];
}
}
return null;
},
/**
* Updates a rule property
* @param {String/Array} selector If it's an array it tries each selector until it finds one. Stops immediately once one is found.
* @param {String} property The css property
* @param {String} value The new value for the property
* @return {Boolean} true If a rule was found and updated
*/
updateRule : function(selector, property, value){
if(!Ext.isArray(selector)){
var rule = this.getRule(selector);
if(rule){
rule.style[property.replace(styleCamelRe, styleCamelFn)] = value;
return true;
}
}else{
for(var i = 0; i < selector.length; i++){
if(this.updateRule(selector[i], property, value)){
return true;
}
}
}
return false;
}
};}
};
/*
* @class Ext.ux.ManagedIFramePanel
* Version: 1.2 (8/22/2008)
* Author: Doug Hendricks - doug[always-At]theactivegroup.com
*
*
*/
Ext.ux.ManagedIframePanel = Ext.extend(Ext.Panel, {
/**
* Cached Iframe.src url to use for refreshes. Overwritten every time setSrc() is called unless "discardUrl" param is set to true.
* @type String/Function (which will return a string URL when invoked)
*/
defaultSrc :null,
bodyStyle :{height:'100%',width:'100%', position:'relative'},
/**
* @cfg {String/Object} frameStyle
* Custom CSS styles to be applied to the ux.ManagedIframe element in the format expected by {@link Ext.Element#applyStyles}
* (defaults to CSS Rule {overflow:'auto'}).
*/
frameStyle : {overflow:'auto'},
frameConfig : null,
hideMode : !Ext.isIE?'nosize':'display',
shimCls : Ext.ux.ManagedIFrame.Manager.shimCls,
shimUrl : null,
loadMask : false,
stateful : false,
animCollapse: Ext.isIE && Ext.enableFx,
autoScroll : false,
closable : true, /* set True by default in the event a site times-out while loadMasked */
ctype : "Ext.ux.ManagedIframePanel",
showLoadIndicator : false,
/**
*@cfg {String/Object} unsupportedText Text (or Ext.DOMHelper config) to display within the rendered iframe tag to indicate the frame is not supported
*/
unsupportedText : 'Inline frames are NOT enabled\/supported by your browser.'
,initComponent : function(){
this.bodyCfg ||
(this.bodyCfg =
{ cls :'x-managed-iframe-mask' //shared masking DIV for hosting loadMask/dragMask
,children:[
//Ext.apply(
Ext.apply({
tag :'iframe',
frameborder : 0,
cls : 'x-managed-iframe',
style : this.frameStyle || null,
html :this.unsupportedText||null
},this.frameConfig?this.frameConfig.autoCreate||{}:false
, Ext.isIE && Ext.isSecure?{src:Ext.SSL_SECURE_URL}:false
)
//the shimming agent
,{tag:'img', src:this.shimUrl||Ext.BLANK_IMAGE_URL , cls: this.shimCls , galleryimg:"no"}
]
});
this.autoScroll = false; //Force off as the Iframe manages this
this.items = null;
//setup stateful events if not defined
if(this.stateful !== false){
this.stateEvents || (this.stateEvents = ['documentloaded']);
}
Ext.ux.ManagedIframePanel.superclass.initComponent.call(this);
this.monitorResize || (this.monitorResize = this.fitToParent);
this.addEvents({documentloaded:true, domready:true,message:true,exception:true});
//apply the addListener patch for 'message:tagging'
this.addListener = this.on;
},
doLayout : function(){
//only resize (to Parent) if the panel is NOT in a layout.
//parentNode should have {style:overflow:hidden;} applied.
if(this.fitToParent && !this.ownerCt){
var pos = this.getPosition(), size = (Ext.get(this.fitToParent)|| this.getEl().parent()).getViewSize();
this.setSize(size.width - pos[0], size.height - pos[1]);
}
Ext.ux.ManagedIframePanel.superclass.doLayout.apply(this,arguments);
},
// private
beforeDestroy : function(){
if(this.rendered){
if(this.tools){
for(var k in this.tools){
Ext.destroy(this.tools[k]);
}
}
if(this.header && this.headerAsText){
var s;
if( s=this.header.child('span')) s.remove();
this.header.update('');
}
Ext.each(['iframe','shim','header','topToolbar','bottomToolbar','footer','loadMask','body','bwrap'],
function(elName){
if(this[elName]){
if(typeof this[elName].destroy == 'function'){
this[elName].destroy();
} else { Ext.destroy(this[elName]); }
this[elName] = null;
delete this[elName];
}
},this);
}
Ext.ux.ManagedIframePanel.superclass.beforeDestroy.call(this);
},
onDestroy : function(){
//Yes, Panel.super (Component), since we're doing Panel cleanup beforeDestroy instead.
Ext.Panel.superclass.onDestroy.call(this);
},
// private
onRender : function(ct, position){
Ext.ux.ManagedIframePanel.superclass.onRender.call(this, ct, position);
if(this.iframe = this.body.child('iframe.x-managed-iframe')){
this.iframe.ownerCt = this;
// Set the Visibility Mode for el, bwrap for collapse/expands/hide/show
var El = Ext.Element;
var mode = El[this.hideMode.toUpperCase()] || 'x-hide-nosize';
Ext.each(
[this[this.collapseEl],this.floating? null: this.getActionEl(),this.iframe]
,function(el){
if(el)el.setVisibilityMode(mode);
},this);
if(this.loadMask){
this.loadMask = Ext.apply({disabled :false
,maskEl :this.body
,hideOnReady :true}
,this.loadMask);
}
if(this.iframe = new Ext.ux.ManagedIFrame(this.iframe, {
loadMask :this.loadMask
,showLoadIndicator :this.showLoadIndicator
,disableMessaging :this.disableMessaging
,style :this.frameStyle
})){
this.loadMask = this.iframe.loadMask;
this.relayEvents(this.iframe, ["blur", "focus", "unload", "documentloaded","domready","exception","message"].concat(this._msgTagHandlers ||[]));
delete this._msgTagHandlers;
}
this.getUpdater().showLoadIndicator = this.showLoadIndicator || false;
// Enable auto-dragMask if the panel participates in (nested?) border layout.
// Setup event handlers on the SplitBars to enable the frame dragMask when needed
var ownerCt = this.ownerCt;
while(ownerCt){
ownerCt.on('afterlayout',function(container,layout){
var MIM = Ext.ux.ManagedIFrame.Manager,st=false;
Ext.each(['north','south','east','west'],function(region){
var reg;
if((reg = layout[region]) && reg.splitEl){
st = true;
if(!reg.split._splitTrapped){
reg.split.on('beforeresize',MIM.showShims,MIM);
reg.split._splitTrapped = true;
}
}
},this);
if(st && !this._splitTrapped ){
this.on('resize',MIM.hideShims,MIM);
this._splitTrapped = true;
}
},this,{single:true}); //and discard
ownerCt = ownerCt.ownerCt; //nested layouts?
}
}
this.shim = Ext.get(this.body.child('.'+this.shimCls));
},
/* Toggles the built-in MIF shim */
toggleShim : function(){
if(this.shim && this.shimCls)this.shim.toggleClass(this.shimCls+'-on');
},
// private
afterRender : function(container){
var html = this.html;
delete this.html;
Ext.ux.ManagedIframePanel.superclass.afterRender.call(this);
if(this.iframe){
if(this.defaultSrc){
this.setSrc();
}
else if(html){
this.iframe.update(typeof html == 'object' ? Ext.DomHelper.markup(html) : html);
}
}
}
,sendMessage :function (){
if(this.iframe){
this.iframe.sendMessage.apply(this.iframe,arguments);
}
}
//relay all defined 'message:tag' event handlers
,on : function(name){
var tagRE=/^message\:/i, n = null;
if(typeof name == 'object'){
for (var na in name){
if(!this.filterOptRe.test(na) && tagRE.test(na)){
n || (n=[]);
n.push(na.toLowerCase());
}
}
} else if(tagRE.test(name)){
n=[name.toLowerCase()];
}
if(this.getFrame() && n){
this.relayEvents(this.iframe,n);
}else{
this._msgTagHandlers || (this._msgTagHandlers =[]);
if(n)this._msgTagHandlers = this._msgTagHandlers.concat(n); //queued for onRender when iframe is available
}
Ext.ux.ManagedIframePanel.superclass.on.apply(this, arguments);
},
/**
* Sets the embedded Iframe src property.
* @param {String/Function} url (Optional) A string or reference to a Function that returns a URI string when called
* @param {Boolean} discardUrl (Optional) If not passed as <tt>false</tt> the URL of this action becomes the default URL for
* this panel, and will be subsequently used in future setSrc calls.
* Note: invoke the function with no arguments to refresh the iframe based on the current defaultSrc value.
*/
setSrc : function(url, discardUrl,callback){
url = url || this.defaultSrc || false;
if(!url)return this;
if(url.url){
callback = url.callback || false;
discardUrl = url.discardUrl || false;
url = url.url || false;
}
var src = url || (Ext.isIE&&Ext.isSecure?Ext.SSL_SECURE_URL:'');
if(this.rendered && this.iframe){
this.iframe.setSrc(src,discardUrl,callback);
}
return this;
},
//Make it state-aware
getState: function(){
var URI = this.iframe?this.iframe.getDocumentURI()||null:null;
return Ext.apply(Ext.ux.ManagedIframePanel.superclass.getState.call(this) || {},
URI?{defaultSrc : typeof URI == 'function'?URI():URI}:null );
},
/**
* Get the {@link Ext.Updater} for this panel's iframe/or body. Enables you to perform Ajax-based document replacement of this panel's iframe document.
* @return {Ext.Updater} The Updater
*/
getUpdater : function(){
return this.rendered?(this.iframe||this.body).getUpdater():null;
},
/**
* Get the embedded iframe Ext.Element for this panel
* @return {Ext.Element} The Panels ux.ManagedIFrame instance.
*/
getFrame : function(){
return this.rendered?this.iframe:null
},
/**
* Get the embedded iframe's window object
* @return {Object} or Null if unavailable
*/
getFrameWindow : function(){
return this.rendered && this.iframe?this.iframe.getWindow():null;
},
/**
* Get the embedded iframe's document object
* @return {Element} or null if unavailable
*/
getFrameDocument : function(){
return this.rendered && this.iframe?this.iframe.getDocument():null;
},
/**
* Get the embedded iframe's document as an Ext.Element.
* @return {Ext.Element object} or null if unavailable
*/
getFrameDoc : function(){
return this.rendered && this.iframe?this.iframe.getDoc():null;
},
/**
* Get the embedded iframe's document.body Element.
* @return {Element object} or null if unavailable
*/
getFrameBody : function(){
return this.rendered && this.iframe?this.iframe.getBody():null;
},
/**
* Loads this panel's iframe immediately with content returned from an XHR call.
* @param {Object/String/Function} config A config object containing any of the following options:
<pre><code>
panel.load({
url: "your-url.php",
params: {param1: "foo", param2: "bar"}, // or a URL encoded string
callback: yourFunction,
scope: yourObject, // optional scope for the callback
discardUrl: false,
nocache: false,
text: "Loading...",
timeout: 30,
scripts: false,
renderer:{render:function(el, response, updater, callback){....}} //optional custom renderer
});
</code></pre>
* The only required property is url. The optional properties nocache, text and scripts
* are shorthand for disableCaching, indicatorText and loadScripts and are used to set their
* associated property on this panel Updater instance.
* @return {Ext.Panel} this
*/
load : function(loadCfg){
var um;
if(um = this.getUpdater()){
if (loadCfg && loadCfg.renderer) {
um.setRenderer(loadCfg.renderer);
delete loadCfg.renderer;
}
um.update.apply(um, arguments);
}
return this;
}
// private
,doAutoLoad : function(){
this.load(
typeof this.autoLoad == 'object' ?
this.autoLoad : {url: this.autoLoad});
}
});
Ext.reg('iframepanel', Ext.ux.ManagedIframePanel);
Ext.ux.ManagedIframePortlet = Ext.extend(Ext.ux.ManagedIframePanel, {
anchor: '100%',
frame:true,
collapseEl:'bwrap',
collapsible:true,
draggable:true,
cls:'x-portlet'
});
Ext.reg('iframeportlet', Ext.ux.ManagedIframePortlet);
/* override adds a third visibility feature to Ext.Element:
* Now an elements' visibility may be handled by application of a custom (hiding) CSS className.
* The class is removed to make the Element visible again
*/
Ext.apply(Ext.Element.prototype, {
setVisible : function(visible, animate){
if(!animate || !Ext.lib.Anim){
if(this.visibilityMode == Ext.Element.DISPLAY){
this.setDisplayed(visible);
}else if(this.visibilityMode == Ext.Element.VISIBILITY){
this.fixDisplay();
this.dom.style.visibility = visible ? "visible" : "hidden";
}else {
this[visible?'removeClass':'addClass'](String(this.visibilityMode));
}
}else{
// closure for composites
var dom = this.dom;
var visMode = this.visibilityMode;
if(visible){
this.setOpacity(.01);
this.setVisible(true);
}
this.anim({opacity: { to: (visible?1:0) }},
this.preanim(arguments, 1),
null, .35, 'easeIn', function(){
if(!visible){
if(visMode == Ext.Element.DISPLAY){
dom.style.display = "none";
}else if(visMode == Ext.Element.VISIBILITY){
dom.style.visibility = "hidden";
}else {
Ext.get(dom).addClass(String(visMode));
}
Ext.get(dom).setOpacity(1);
}
});
}
return this;
},
/**
* Checks whether the element is currently visible using both visibility and display properties.
* @param {Boolean} deep (optional) True to walk the dom and see if parent elements are hidden (defaults to false)
* @return {Boolean} True if the element is currently visible, else false
*/
isVisible : function(deep) {
var vis = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none" || this.hasClass(this.visibilityMode));
if(deep !== true || !vis){
return vis;
}
var p = this.dom.parentNode;
while(p && p.tagName.toLowerCase() != "body"){
if(!Ext.fly(p, '_isVisible').isVisible()){
return false;
}
p = p.parentNode;
}
return true;
}
});
Ext.onReady( function(){
//Generate CSS Rules but allow for overrides.
var CSS = Ext.util.CSS, rules=[];
CSS.getRule('.x-managed-iframe') || ( rules.push('.x-managed-iframe {height:100%;width:100%;overflow:auto;}'));
CSS.getRule('.x-managed-iframe-mask')||(rules.push('.x-managed-iframe-mask{width:100%;height:100%;position:relative;}'));
if(!CSS.getRule('.x-frame-shim')){
rules.push('.x-frame-shim {z-index:8500;position:absolute;top:0px;left:0px;background:transparent!important;overflow:hidden;display:none;}');
rules.push('.x-frame-shim-on{width:100%;height:100%;display:block;zoom:1;}');
rules.push('.ext-ie6 .x-frame-shim{margin-left:5px;margin-top:3px;}');
}
CSS.getRule('.x-hide-nosize') || (rules.push('.x-hide-nosize,.x-hide-nosize *{height:0px!important;width:0px!important;border:none;}'));
if(!!rules.length){
CSS.createStyleSheet(rules.join(' '));
}
});
})();
//@ sourceURL=<miframe.js>
|
open-steam/MokodeskApp
|
src/OpenSteam/MokodeskBundle/Resources/lib/js/ux/miframe.js
|
JavaScript
|
gpl-2.0
| 62,010
|
<a name="o_vncpassword"/>
<h3>
<a name="o_vnc">安装程序选项:vnc</a>
</h3>
<p>
To enable the VNC installation, specify the
parameters vnc and vncpassword:
<ul>
<li><em>vnc=1 vncpassword=example</em></li>
</ul>
</p>
<p>
The VNC server will be started and you may control YaST2 over any VNC
client from a remote system.
</p>
|
mdamt/gfxboot-blankon
|
themes/BlankOn/help-install/zh_CN/main::opt::o_vnc.html
|
HTML
|
gpl-2.0
| 335
|
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.text.*;
import java.text.spi.*;
import java.util.*;
import java.util.spi.*;
import java.util.stream.IntStream;
import sun.util.locale.provider.LocaleProviderAdapter;
public class LocaleProviders {
private static final boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows");
private static final boolean IS_MAC = System.getProperty("os.name").startsWith("Mac");
public static void main(String[] args) {
String methodName = args[0];
switch (methodName) {
case "getPlatformLocale":
if (args[1].equals("format")) {
getPlatformLocale(Locale.Category.FORMAT);
} else {
getPlatformLocale(Locale.Category.DISPLAY);
}
break;
case "adapterTest":
adapterTest(args[1], args[2], (args.length >= 4 ? args[3] : ""));
break;
case "bug7198834Test":
bug7198834Test();
break;
case "tzNameTest":
tzNameTest(args[1]);
break;
case "bug8001440Test":
bug8001440Test();
break;
case "bug8010666Test":
bug8010666Test();
break;
case "bug8013086Test":
bug8013086Test(args[1], args[2]);
break;
case "bug8013903Test":
bug8013903Test();
break;
case "bug8027289Test":
bug8027289Test(args[1]);
break;
case "bug8220227Test":
bug8220227Test();
break;
case "bug8228465Test":
bug8228465Test();
break;
case "bug8232871Test":
bug8232871Test();
break;
case "bug8232860Test":
bug8232860Test();
break;
default:
throw new RuntimeException("Test method '"+methodName+"' not found.");
}
}
static void getPlatformLocale(Locale.Category cat) {
Locale defloc = Locale.getDefault(cat);
System.out.printf("%s,%s\n", defloc.getLanguage(), defloc.getCountry());
}
static void adapterTest(String expected, String lang, String ctry) {
Locale testLocale = new Locale(lang, ctry);
LocaleProviderAdapter ldaExpected =
LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected));
if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) {
System.out.println("test locale: "+testLocale+" is not supported by the expected provider: "+ldaExpected+". Ignoring the test.");
return;
}
String preference = System.getProperty("java.locale.providers", "");
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, testLocale);
LocaleProviderAdapter.Type type = lda.getAdapterType();
System.out.printf("testLocale: %s, got: %s, expected: %s\n", testLocale, type, expected);
if (!type.toString().equals(expected)) {
throw new RuntimeException("Returned locale data adapter is not correct.");
}
}
static void bug7198834Test() {
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US);
LocaleProviderAdapter.Type type = lda.getAdapterType();
if (type == LocaleProviderAdapter.Type.HOST && IS_WINDOWS) {
DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
String date = df.format(new Date());
if (date.charAt(date.length()-1) == ' ') {
throw new RuntimeException("Windows Host Locale Provider returns a trailing space.");
}
} else {
System.out.println("Windows HOST locale adapter not found. Ignoring this test.");
}
}
static void tzNameTest(String id) {
TimeZone tz = TimeZone.getTimeZone(id);
String tzName = tz.getDisplayName(false, TimeZone.SHORT, Locale.US);
if (tzName.startsWith("GMT")) {
throw new RuntimeException("JRE's localized time zone name for "+id+" could not be retrieved. Returned name was: "+tzName);
}
}
static void bug8001440Test() {
Locale locale = Locale.forLanguageTag("th-TH-u-nu-hoge");
NumberFormat nf = NumberFormat.getInstance(locale);
String nu = nf.format(1234560);
}
// This test assumes Windows localized language/country display names.
static void bug8010666Test() {
if (IS_WINDOWS) {
NumberFormat nf = NumberFormat.getInstance(Locale.US);
try {
double ver = nf.parse(System.getProperty("os.version"))
.doubleValue();
System.out.printf("Windows version: %.1f\n", ver);
if (ver >= 6.0) {
LocaleProviderAdapter lda =
LocaleProviderAdapter.getAdapter(
LocaleNameProvider.class, Locale.ENGLISH);
LocaleProviderAdapter.Type type = lda.getAdapterType();
if (type == LocaleProviderAdapter.Type.HOST) {
LocaleNameProvider lnp = lda.getLocaleNameProvider();
Locale mkmk = Locale.forLanguageTag("mk-MK");
String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
String hostResult =
lnp.getDisplayLanguage(mkmk.getLanguage(),
Locale.ENGLISH);
System.out.printf(" Display language name for" +
" (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
hostResult, result);
if (result == null ||
hostResult != null &&
!result.equals(hostResult)) {
throw new RuntimeException("Display language name" +
" mismatch for \"mk\". Returned name was" +
" \"" + result + "\", result(HOST): \"" +
hostResult + "\"");
}
result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
hostResult =
lnp.getDisplayLanguage(Locale.US.getLanguage(),
Locale.ENGLISH);
System.out.printf(" Display language name for" +
" (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
hostResult, result);
if (result == null ||
hostResult != null &&
!result.equals(hostResult)) {
throw new RuntimeException("Display language name" +
" mismatch for \"en\". Returned name was" +
" \"" + result + "\", result(HOST): \"" +
hostResult + "\"");
}
if (ver >= 6.1) {
result = Locale.US.getDisplayCountry(Locale.ENGLISH);
hostResult = lnp.getDisplayCountry(
Locale.US.getCountry(), Locale.ENGLISH);
System.out.printf(" Display country name for" +
" (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
hostResult, result);
if (result == null ||
hostResult != null &&
!result.equals(hostResult)) {
throw new RuntimeException("Display country name" +
" mismatch for \"US\". Returned name was" +
" \"" + result + "\", result(HOST): \"" +
hostResult + "\"");
}
}
} else {
throw new RuntimeException("Windows Host" +
" LocaleProviderAdapter was not selected for" +
" English locale.");
}
}
} catch (ParseException pe) {
throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
}
}
}
static void bug8013086Test(String lang, String ctry) {
try {
// Throws a NullPointerException if the test fails.
System.out.println(new SimpleDateFormat("z", new Locale(lang, ctry)).parse("UTC"));
} catch (ParseException pe) {
// ParseException is fine in this test, as it's not "UTC"
}
}
static void bug8013903Test() {
if (IS_WINDOWS) {
Date sampleDate = new Date(0x10000000000L);
String hostResult = "\u5e73\u6210 16.11.03 (Wed) AM 11:53:47";
String jreResult = "\u5e73\u6210 16.11.03 (\u6c34) \u5348\u524d 11:53:47";
Locale l = new Locale("ja", "JP", "JP");
SimpleDateFormat sdf = new SimpleDateFormat("GGGG yyyy.MMM.dd '('E')' a hh:mm:ss", l);
sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
String result = sdf.format(sampleDate);
System.out.println(result);
if (LocaleProviderAdapter.getAdapterPreference()
.contains(LocaleProviderAdapter.Type.JRE)) {
if (!jreResult.equals(result)) {
throw new RuntimeException("Format failed. result: \"" +
result + "\", expected: \"" + jreResult);
}
} else {
// Windows display names. Subject to change if Windows changes its format.
if (!hostResult.equals(result)) {
throw new RuntimeException("Format failed. result: \"" +
result + "\", expected: \"" + hostResult);
}
}
}
}
static void bug8027289Test(String expectedCodePoint) {
if (IS_WINDOWS) {
char[] expectedSymbol = Character.toChars(Integer.valueOf(expectedCodePoint, 16));
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA);
char formatted = nf.format(7000).charAt(0);
System.out.println("returned: " + formatted + ", expected: " + expectedSymbol[0]);
if (formatted != expectedSymbol[0]) {
throw new RuntimeException(
"Unexpected Chinese currency symbol. returned: "
+ formatted + ", expected: " + expectedSymbol[0]);
}
}
}
static void bug8220227Test() {
if (IS_WINDOWS) {
Locale l = new Locale("xx","XX");
String country = l.getDisplayCountry();
if (country.endsWith("(XX)")) {
throw new RuntimeException(
"Unexpected Region name: " + country);
}
}
}
static void bug8228465Test() {
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US);
LocaleProviderAdapter.Type type = lda.getAdapterType();
if (type == LocaleProviderAdapter.Type.HOST && IS_WINDOWS) {
var names = new GregorianCalendar()
.getDisplayNames(Calendar.ERA, Calendar.SHORT_FORMAT, Locale.US);
if (!names.keySet().contains("AD") ||
names.get("AD").intValue() != 1) {
throw new RuntimeException(
"Short Era name for 'AD' is missing or incorrect");
} else {
System.out.println("bug8228465Test succeeded.");
}
}
}
static void bug8232871Test() {
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US);
LocaleProviderAdapter.Type type = lda.getAdapterType();
var lang = Locale.getDefault().getLanguage();
var cal = Calendar.getInstance();
var calType = cal.getCalendarType();
var expected = "\u4ee4\u548c1\u5e745\u67081\u65e5 \u6c34\u66dc\u65e5 \u5348\u524d0:00:00 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593";
if (type == LocaleProviderAdapter.Type.HOST &&
IS_MAC &&
lang.equals("ja") &&
calType.equals("japanese")) {
cal.set(1, 4, 1, 0, 0, 0);
cal.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL,
Locale.JAPAN);
df.setCalendar(cal);
var result = df.format(cal.getTime());
if (result.equals(expected)) {
System.out.println("bug8232871Test succeeded.");
} else {
throw new RuntimeException(
"Japanese calendar names mismatch. result: " +
result +
", expected: " +
expected);
}
} else {
System.out.println("Test ignored. Either :-\n" +
"OS is not macOS, or\n" +
"provider is not HOST: " + type + ", or\n" +
"Language is not Japanese: " + lang + ", or\n" +
"native calendar is not JapaneseCalendar: " + calType);
}
}
static void bug8232860Test() {
var inputList = List.of(123, 123.4);
var nfExpectedList = List.of("123", "123.4");
var ifExpectedList = List.of("123", "123");
var type = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US)
.getAdapterType();
if (type == LocaleProviderAdapter.Type.HOST && (IS_WINDOWS || IS_MAC)) {
final var numf = NumberFormat.getNumberInstance(Locale.US);
final var intf = NumberFormat.getIntegerInstance(Locale.US);
IntStream.range(0, inputList.size())
.forEach(i -> {
var input = inputList.get(i);
var nfExpected = nfExpectedList.get(i);
var result = numf.format(input);
if (!result.equals(nfExpected)) {
throw new RuntimeException("Incorrect number format. " +
"input: " + input + ", expected: " +
nfExpected + ", result: " + result);
}
var ifExpected = ifExpectedList.get(i);
result = intf.format(input);
if (!result.equals(ifExpected)) {
throw new RuntimeException("Incorrect integer format. " +
"input: " + input + ", expected: " +
ifExpected + ", result: " + result);
}
});
System.out.println("bug8232860Test succeeded.");
} else {
System.out.println("Test ignored. Either :-\n" +
"OS is neither macOS/Windows, or\n" +
"provider is not HOST: " + type);
}
}
}
|
md-5/jdk10
|
test/jdk/java/util/Locale/LocaleProviders.java
|
Java
|
gpl-2.0
| 16,740
|
namespace Datalogger
{
partial class signup
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(signup));
this.up_panel = new System.Windows.Forms.Panel();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.title = new System.Windows.Forms.Button();
this.exit = new System.Windows.Forms.Button();
this.downpanel = new System.Windows.Forms.Panel();
this.firstname = new System.Windows.Forms.TextBox();
this.password = new System.Windows.Forms.TextBox();
this.username = new System.Windows.Forms.TextBox();
this.confirm_password = new System.Windows.Forms.TextBox();
this.fname = new System.Windows.Forms.Label();
this.lname = new System.Windows.Forms.Label();
this.Gender = new System.Windows.Forms.Label();
this.lastname = new System.Windows.Forms.TextBox();
this.M = new System.Windows.Forms.RadioButton();
this.F = new System.Windows.Forms.RadioButton();
this.uname = new System.Windows.Forms.Label();
this.pwd = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.mail = new System.Windows.Forms.Label();
this.mailid = new System.Windows.Forms.TextBox();
this.dob = new System.Windows.Forms.DateTimePicker();
this.label1 = new System.Windows.Forms.Label();
this.signup_database = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.reqlev = new System.Windows.Forms.Label();
this.up_panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// up_panel
//
this.up_panel.BackColor = System.Drawing.SystemColors.GrayText;
this.up_panel.Controls.Add(this.pictureBox3);
this.up_panel.Controls.Add(this.title);
this.up_panel.Controls.Add(this.exit);
this.up_panel.Dock = System.Windows.Forms.DockStyle.Top;
this.up_panel.Location = new System.Drawing.Point(0, 0);
this.up_panel.Name = "up_panel";
this.up_panel.Size = new System.Drawing.Size(548, 29);
this.up_panel.TabIndex = 9;
this.up_panel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panelmain_MouseDown);
this.up_panel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.panelmain_MouseMove);
this.up_panel.MouseUp += new System.Windows.Forms.MouseEventHandler(this.panelmain_MouseUp);
//
// pictureBox3
//
this.pictureBox3.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox3.Image")));
this.pictureBox3.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.pictureBox3.Location = new System.Drawing.Point(2, 1);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(29, 27);
this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.pictureBox3.TabIndex = 13;
this.pictureBox3.TabStop = false;
//
// title
//
this.title.FlatAppearance.BorderSize = 0;
this.title.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.title.Font = new System.Drawing.Font("Tempus Sans ITC", 12F, System.Drawing.FontStyle.Bold);
this.title.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
this.title.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.title.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.title.Location = new System.Drawing.Point(27, 0);
this.title.Name = "title";
this.title.Size = new System.Drawing.Size(116, 29);
this.title.TabIndex = 5;
this.title.Text = "SIGN UP";
this.title.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.title.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
this.title.UseVisualStyleBackColor = false;
//
// exit
//
this.exit.BackColor = System.Drawing.Color.Gray;
this.exit.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.exit.ForeColor = System.Drawing.SystemColors.ControlText;
this.exit.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.exit.Location = new System.Drawing.Point(517, 0);
this.exit.Name = "exit";
this.exit.Size = new System.Drawing.Size(30, 30);
this.exit.TabIndex = 7;
this.exit.Text = "X";
this.exit.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText;
this.exit.UseVisualStyleBackColor = false;
this.exit.Click += new System.EventHandler(this.exit_Click);
this.exit.MouseLeave += new System.EventHandler(this.exit_MouseLeave);
this.exit.MouseHover += new System.EventHandler(this.exit_MouseHover);
//
// downpanel
//
this.downpanel.BackColor = System.Drawing.SystemColors.GrayText;
this.downpanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.downpanel.Location = new System.Drawing.Point(0, 311);
this.downpanel.Name = "downpanel";
this.downpanel.Size = new System.Drawing.Size(548, 29);
this.downpanel.TabIndex = 10;
//
// firstname
//
this.firstname.Location = new System.Drawing.Point(127, 23);
this.firstname.Name = "firstname";
this.firstname.Size = new System.Drawing.Size(178, 20);
this.firstname.TabIndex = 12;
//
// password
//
this.password.Location = new System.Drawing.Point(127, 108);
this.password.Name = "password";
this.password.Size = new System.Drawing.Size(178, 20);
this.password.TabIndex = 13;
//
// username
//
this.username.Location = new System.Drawing.Point(127, 79);
this.username.Name = "username";
this.username.Size = new System.Drawing.Size(178, 20);
this.username.TabIndex = 15;
//
// confirm_password
//
this.confirm_password.Location = new System.Drawing.Point(127, 138);
this.confirm_password.Name = "confirm_password";
this.confirm_password.Size = new System.Drawing.Size(178, 20);
this.confirm_password.TabIndex = 16;
//
// fname
//
this.fname.AutoSize = true;
this.fname.Location = new System.Drawing.Point(44, 23);
this.fname.Name = "fname";
this.fname.Size = new System.Drawing.Size(60, 13);
this.fname.TabIndex = 17;
this.fname.Text = "First Name:";
//
// lname
//
this.lname.AutoSize = true;
this.lname.Location = new System.Drawing.Point(311, 23);
this.lname.Name = "lname";
this.lname.Size = new System.Drawing.Size(61, 13);
this.lname.TabIndex = 18;
this.lname.Text = "Last Name:";
//
// Gender
//
this.Gender.AutoSize = true;
this.Gender.Location = new System.Drawing.Point(59, 56);
this.Gender.Name = "Gender";
this.Gender.Size = new System.Drawing.Size(45, 13);
this.Gender.TabIndex = 19;
this.Gender.Text = "Gender:";
//
// lastname
//
this.lastname.Location = new System.Drawing.Point(373, 23);
this.lastname.Name = "lastname";
this.lastname.Size = new System.Drawing.Size(146, 20);
this.lastname.TabIndex = 20;
this.lastname.TextChanged += new System.EventHandler(this.lastname_TextChanged);
//
// M
//
this.M.AutoSize = true;
this.M.Location = new System.Drawing.Point(127, 56);
this.M.Name = "M";
this.M.Size = new System.Drawing.Size(47, 17);
this.M.TabIndex = 21;
this.M.TabStop = true;
this.M.Text = "male";
this.M.UseVisualStyleBackColor = true;
this.M.CheckedChanged += new System.EventHandler(this.M_CheckedChanged);
//
// F
//
this.F.AutoSize = true;
this.F.Location = new System.Drawing.Point(180, 56);
this.F.Name = "F";
this.F.Size = new System.Drawing.Size(56, 17);
this.F.TabIndex = 22;
this.F.TabStop = true;
this.F.Text = "female";
this.F.UseVisualStyleBackColor = true;
this.F.CheckedChanged += new System.EventHandler(this.F_CheckedChanged);
//
// uname
//
this.uname.AutoSize = true;
this.uname.ForeColor = System.Drawing.Color.DarkRed;
this.uname.Location = new System.Drawing.Point(46, 79);
this.uname.Name = "uname";
this.uname.Size = new System.Drawing.Size(62, 13);
this.uname.TabIndex = 23;
this.uname.Text = "Username:*";
//
// pwd
//
this.pwd.AutoSize = true;
this.pwd.ForeColor = System.Drawing.Color.DarkRed;
this.pwd.Location = new System.Drawing.Point(48, 108);
this.pwd.Name = "pwd";
this.pwd.Size = new System.Drawing.Size(60, 13);
this.pwd.TabIndex = 24;
this.pwd.Text = "Password:*";
this.pwd.Click += new System.EventHandler(this.pwd_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.ForeColor = System.Drawing.Color.DarkRed;
this.label3.Location = new System.Drawing.Point(10, 138);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(98, 13);
this.label3.TabIndex = 25;
this.label3.Text = "Confirm Password:*";
//
// mail
//
this.mail.AutoSize = true;
this.mail.ForeColor = System.Drawing.Color.DarkRed;
this.mail.Location = new System.Drawing.Point(69, 173);
this.mail.Name = "mail";
this.mail.Size = new System.Drawing.Size(39, 13);
this.mail.TabIndex = 27;
this.mail.Text = "Email:*";
//
// mailid
//
this.mailid.Location = new System.Drawing.Point(127, 168);
this.mailid.Name = "mailid";
this.mailid.Size = new System.Drawing.Size(178, 20);
this.mailid.TabIndex = 26;
//
// dob
//
this.dob.Location = new System.Drawing.Point(127, 199);
this.dob.Name = "dob";
this.dob.Size = new System.Drawing.Size(178, 20);
this.dob.TabIndex = 29;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(71, 199);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(33, 13);
this.label1.TabIndex = 30;
this.label1.Text = "DOB:";
//
// signup_database
//
this.signup_database.Location = new System.Drawing.Point(465, 282);
this.signup_database.Name = "signup_database";
this.signup_database.Size = new System.Drawing.Size(75, 23);
this.signup_database.TabIndex = 31;
this.signup_database.Text = "Sign Me UP";
this.signup_database.UseVisualStyleBackColor = true;
this.signup_database.Click += new System.EventHandler(this.signup_database_Click);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.password);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.firstname);
this.groupBox1.Controls.Add(this.dob);
this.groupBox1.Controls.Add(this.username);
this.groupBox1.Controls.Add(this.mail);
this.groupBox1.Controls.Add(this.confirm_password);
this.groupBox1.Controls.Add(this.mailid);
this.groupBox1.Controls.Add(this.fname);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.lname);
this.groupBox1.Controls.Add(this.pwd);
this.groupBox1.Controls.Add(this.Gender);
this.groupBox1.Controls.Add(this.uname);
this.groupBox1.Controls.Add(this.lastname);
this.groupBox1.Controls.Add(this.F);
this.groupBox1.Controls.Add(this.M);
this.groupBox1.Location = new System.Drawing.Point(12, 36);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(528, 235);
this.groupBox1.TabIndex = 32;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "--------Sign Up------------------------------------------------------------------" +
"--------------------------------------------------------------------------------" +
"-";
//
// reqlev
//
this.reqlev.AutoSize = true;
this.reqlev.Font = new System.Drawing.Font("Bradley Hand ITC", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.reqlev.Location = new System.Drawing.Point(9, 282);
this.reqlev.Name = "reqlev";
this.reqlev.Size = new System.Drawing.Size(198, 19);
this.reqlev.TabIndex = 33;
this.reqlev.Text = "Note: * are required fields";
//
// signup
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(548, 340);
this.Controls.Add(this.reqlev);
this.Controls.Add(this.signup_database);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.downpanel);
this.Controls.Add(this.up_panel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "signup";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "signup";
this.up_panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel up_panel;
private System.Windows.Forms.Button title;
private System.Windows.Forms.Button exit;
private System.Windows.Forms.Panel downpanel;
private System.Windows.Forms.TextBox firstname;
private System.Windows.Forms.TextBox password;
private System.Windows.Forms.TextBox username;
private System.Windows.Forms.TextBox confirm_password;
private System.Windows.Forms.Label fname;
private System.Windows.Forms.Label lname;
private System.Windows.Forms.Label Gender;
private System.Windows.Forms.TextBox lastname;
private System.Windows.Forms.RadioButton M;
private System.Windows.Forms.RadioButton F;
private System.Windows.Forms.Label uname;
private System.Windows.Forms.Label pwd;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label mail;
private System.Windows.Forms.TextBox mailid;
private System.Windows.Forms.DateTimePicker dob;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button signup_database;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.Label reqlev;
}
}
|
rabirajkhadka/datalogging
|
Datalogger/signup.Designer.cs
|
C#
|
gpl-2.0
| 17,834
|
package com.rht.rht2.model.e;
import javax.annotation.Generated;
/**
* PlaceassetTO is a Querydsl bean type
*
* @author Rob
* @version $Revision: 1.0 $
*/
@Generated("com.mysema.query.codegen.BeanSerializer")
public class PlaceassetTO {
private String placeAssetAddress1;
private String placeAssetAddress2;
private String placeAssetArea;
private Integer placeAssetAssetId;
private Integer placeAssetId;
private String placeAssetLocationName;
private String placeAssetNumberName;
private String placeAssetParish;
private String placeAssetTown;
/**
* Method getPlaceAssetAddress1.
*
* @return String */
public String getPlaceAssetAddress1() {
return placeAssetAddress1;
}
/**
* Method getPlaceAssetAddress2.
*
* @return String */
public String getPlaceAssetAddress2() {
return placeAssetAddress2;
}
/**
* Method getPlaceAssetArea.
*
* @return String */
public String getPlaceAssetArea() {
return placeAssetArea;
}
/**
* Method getPlaceAssetAssetId.
*
* @return Integer */
public Integer getPlaceAssetAssetId() {
return placeAssetAssetId;
}
/**
* Method getPlaceAssetId.
*
* @return Integer */
public Integer getPlaceAssetId() {
return placeAssetId;
}
/**
* Method getPlaceAssetLocationName.
*
* @return String */
public String getPlaceAssetLocationName() {
return placeAssetLocationName;
}
/**
* Method getPlaceAssetNumberName.
*
* @return String */
public String getPlaceAssetNumberName() {
return placeAssetNumberName;
}
/**
* Method getPlaceAssetParish.
*
* @return String */
public String getPlaceAssetParish() {
return placeAssetParish;
}
/**
* Method getPlaceAssetTown.
*
* @return String */
public String getPlaceAssetTown() {
return placeAssetTown;
}
/**
* Method setPlaceAssetAddress1.
*
* @param placeAssetAddress1
* String
*/
public void setPlaceAssetAddress1(String placeAssetAddress1) {
this.placeAssetAddress1 = placeAssetAddress1;
}
/**
* Method setPlaceAssetAddress2.
*
* @param placeAssetAddress2
* String
*/
public void setPlaceAssetAddress2(String placeAssetAddress2) {
this.placeAssetAddress2 = placeAssetAddress2;
}
/**
* Method setPlaceAssetArea.
*
* @param placeAssetArea
* String
*/
public void setPlaceAssetArea(String placeAssetArea) {
this.placeAssetArea = placeAssetArea;
}
/**
* Method setPlaceAssetAssetId.
*
* @param placeAssetAssetId
* Integer
*/
public void setPlaceAssetAssetId(Integer placeAssetAssetId) {
this.placeAssetAssetId = placeAssetAssetId;
}
/**
* Method setPlaceAssetId.
*
* @param placeAssetId
* Integer
*/
public void setPlaceAssetId(Integer placeAssetId) {
this.placeAssetId = placeAssetId;
}
/**
* Method setPlaceAssetLocationName.
*
* @param placeAssetLocationName
* String
*/
public void setPlaceAssetLocationName(String placeAssetLocationName) {
this.placeAssetLocationName = placeAssetLocationName;
}
/**
* Method setPlaceAssetNumberName.
*
* @param placeAssetNumberName
* String
*/
public void setPlaceAssetNumberName(String placeAssetNumberName) {
this.placeAssetNumberName = placeAssetNumberName;
}
/**
* Method setPlaceAssetParish.
*
* @param placeAssetParish
* String
*/
public void setPlaceAssetParish(String placeAssetParish) {
this.placeAssetParish = placeAssetParish;
}
/**
* Method setPlaceAssetTown.
*
* @param placeAssetTown
* String
*/
public void setPlaceAssetTown(String placeAssetTown) {
this.placeAssetTown = placeAssetTown;
}
}
|
RushenHeritageTrust/Phase2
|
Projects/RHT2-ejb/src/com/rht/rht2/model/e/PlaceassetTO.java
|
Java
|
gpl-2.0
| 3,712
|
<?php
class UserTest extends PHPUnit_Framework_TestCase
{
protected $user;
public function __construct()
{
$this->user = new User(true);
}
public function testGetAllUserAbosPublicationCategory(){
$expect = array(
1 => array(204 => 1),
3 => array(199 => 1)
);
$actual = $this->user->getAllUserAbosPublicationCategory();
$this->assertEquals($expect,$actual);
}
public function testGetAllUserAbos(){
$expect = array(
1 => array(
204 => array( 'keywords' => array('Tribunal Fédéral'),'ispub' => 1),
180 => array( 'keywords' => '', 'ispub' => 0),
192 => array( 'keywords' => '', 'ispub' => 0),
174 => array( 'keywords' => '', 'ispub' => 0),
247 => array( 'keywords' => array('Bohnet') , 'ispub' => 0)
),
3 => array(
198 => array( 'keywords' => '', 'ispub' => 0),
199 => array( 'keywords' => '', 'ispub' => 1),
203 => array( 'keywords' => '', 'ispub' => 0),
195 => array( 'keywords' => '', 'ispub' => 0),
247 => array( 'keywords' => array('miete'),'ispub' => 0)
)
);
$actual = $this->user->getUserAbos('all');
$this->assertEquals($expect,$actual);
}
}
|
DesignPond/plugin_arrets
|
tests/UserTest.php
|
PHP
|
gpl-2.0
| 1,184
|
<?php
class AE_text {
/**
* Field Constructor.
*
* @param array $field
* - id
* - name
* - placeholder
* - readonly
* - class
* - title
* @param $value
* @param $parent
* @since AEFramework 1.0.0
*/
function __construct( $field = array(), $value ='', $parent ) {
//parent::__construct( $parent->sections, $parent->args );
$this->parent = $parent;
$this->field = $field;
$this->value = $value;
}
/**
* Field Render Function.
*
* Takes the vars and outputs the HTML for the field in the settings
*
* @since AEFramework 1.0.0
*/
function render() {
$readonly = isset($this->field['readonly']) ? ' readonly="readonly"' : '';
$placeholder = ( isset($this->field['placeholder']) && $this->field['placeholder'] ) ? ' placeholder="' . esc_attr($this->field['placeholder']) . '" ' : '';
$default = isset($this->field['default']) ? $this->field['default'] : '';
$value = $this->value ? stripslashes(esc_attr($this->value)) : $default;
if( isset( $this->field['label']) && $this->field['label'] !== '') {
echo '<label for="'. $this->field['id'] .'">'. $this->field['label'] .'</label>';
}
echo '<input type="text" id="' . $this->field['id'] . '" name="' . $this->field['name'] .'" '. $placeholder . 'value="' . $value . '" class="regular-text ' . $this->field['class'] . '"'.$readonly.' /><br />';
}//render
}
|
rinodung/wp-question
|
wp-content/themes/qaengine-v1.5.1/includes/aecore/fields/field-text.php
|
PHP
|
gpl-2.0
| 1,545
|
# PROXMARK3 - HID CORPORATE 1000 BRUTEFORCER (STAND-ALONE MODE)
This version of Proxmark3 firmware adds one extra stand-alone mode to proxmark3 firmware.
The new stand-alone mode allows to execute a bruteforce on HID Corporate 1000 readers, by reading a specific badge
and bruteforcing the Card Number (incrementing and decrementing it), mainteining the same Facility Code of the
original badge.
Based on an idea of Brad Antoniewicz of McAfee® Foundstone® Professional Services (ProxBrute), tha stand-alone mode has been
rewritten in order to overcome some limitations of ProxBrute firmware, that does not consider parity bits.
Created by:
- Federico Dotta - Security Expert at @ Mediaservice.net
- Maurizio Agazzini - Senior Security Advisor at @ Mediaservice.net
Installation:
- Download sources and compile it OR
- Download the release from the "Releases" section
Stand-alone mode diagram:

**Use at your own risk. The authors are not responsable to any damagings, malfunctioning or issues caused by the code or by the use of the code.**
# INTRODUCTION:
The proxmark3 is a powerful general purpose RFID tool, the size of a deck
of cards, designed to snoop, listen and emulate everything from
Low Frequency (125kHz) to High Frequency (13.56MHz) tags.
This repository contains enough software, logic (for the FPGA), and design
documentation for the hardware that you could, at least in theory,
do something useful with a proxmark3.
# RESOURCES:
* This repository!
https://github.com/Proxmark/proxmark3
* The Wiki
https://github.com/Proxmark/proxmark3/wiki
* The GitHub page
http://proxmark.github.io/proxmark3/
* The Forum
http://www.proxmark.org/forum
* The IRC chanel
irc.freenode.org #proxmark3
-or-
http://webchat.freenode.net/?channels=#proxmark3
# DEVELOPMENT:
The tools required to build or run the project will vary depending on
your operating system. Please refer to the Wiki for details.
* https://github.com/Proxmark/proxmark3/wiki
# OBTAINING HARDWARE:
The Proxmark 3 is available for purchase (assembled and tested) from the
following locations:
* http://proxmark3.com/
* http://www.xfpga.com/
Most of the ultra-low-volume contract assemblers could put
something like this together with a reasonable yield. A run of around
a dozen units is probably cost-effective. The BOM includes (possibly-
outdated) component pricing, and everything is available from Digikey
and the usual distributors.
If you've never assembled a modern circuit board by hand, then this is
not a good place to start. Some of the components (e.g. the crystals)
must not be assembled with a soldering iron, and require hot air.
The schematics are included; the component values given are not
necessarily correct for all situations, but it should be possible to do
nearly anything you would want with appropriate population options.
The printed circuit board artwork is also available, as Gerbers and an
Excellon drill file.
# LICENSING:
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Jonathan Westhues
user jwesthues, at host cq.cx
May 2007, Cambridge MA
|
federicodotta/proxmark3
|
README.md
|
Markdown
|
gpl-2.0
| 3,902
|
/**
* SyntaxHighlighter
* http://alexgorbatchev.com/SyntaxHighlighter
*
* SyntaxHighlighter is donationware. If you are using it, please donate.
* http://alexgorbatchev.com/SyntaxHighlighter/donate.html
*
* @version
* 3.0.83 (Tue, 27 Dec 2011 09:58:26 GMT)
*
* @copyright
* Copyright (C) 2004-2010 Alex Gorbatchev.
*
* @license
* Dual licensed under the MIT and GPL licenses.
*/
.syntaxhighlighter{background-color:white !important;}
.syntaxhighlighter .line.alt1{background-color:white !important;}
.syntaxhighlighter .line.alt2{background-color:white !important;}
.syntaxhighlighter .line.highlighted.alt1,.syntaxhighlighter .line.highlighted.alt2{background-color:#c3defe !important;}
.syntaxhighlighter .line.highlighted.number{color:white !important;}
.syntaxhighlighter table caption{color:black !important;}
.syntaxhighlighter .gutter{color:#787878 !important;}
.syntaxhighlighter .gutter .line{border-right:3px solid #d4d0c8 !important;}
.syntaxhighlighter .gutter .line.highlighted{background-color:#d4d0c8 !important;color:white !important;}
.syntaxhighlighter.printing .line .content{border:none !important;}
.syntaxhighlighter.collapsed{overflow:visible !important;}
.syntaxhighlighter.collapsed .toolbar{color:#3f5fbf !important;background:white !important;border:1px solid #d4d0c8 !important;}
.syntaxhighlighter.collapsed .toolbar a{color:#3f5fbf !important;}
.syntaxhighlighter.collapsed .toolbar a:hover{color:#aa7700 !important;}
.syntaxhighlighter .toolbar{color:#a0a0a0 !important;background:#d4d0c8 !important;border:none !important;}
.syntaxhighlighter .toolbar a{color:#a0a0a0 !important;}
.syntaxhighlighter .toolbar a:hover{color:red !important;}
.syntaxhighlighter .plain,.syntaxhighlighter .plain a{color:black !important;}
.syntaxhighlighter .comments,.syntaxhighlighter .comments a{color:#3f5fbf !important;}
.syntaxhighlighter .string,.syntaxhighlighter .string a{color:#2a00ff !important;}
.syntaxhighlighter .keyword{color:#7f0055 !important;}
.syntaxhighlighter .preprocessor{color:#646464 !important;}
.syntaxhighlighter .variable{color:#aa7700 !important;}
.syntaxhighlighter .value{color:#009900 !important;}
.syntaxhighlighter .functions{color:#ff1493 !important;}
.syntaxhighlighter .constants{color:#0066cc !important;}
.syntaxhighlighter .script{font-weight:bold !important;color:#7f0055 !important;background-color:none !important;}
.syntaxhighlighter .color1,.syntaxhighlighter .color1 a{color:gray !important;}
.syntaxhighlighter .color2,.syntaxhighlighter .color2 a{color:#ff1493 !important;}
.syntaxhighlighter .color3,.syntaxhighlighter .color3 a{color:red !important;}
.syntaxhighlighter .keyword{font-weight:bold !important;}
.syntaxhighlighter .xml .keyword{color:#3f7f7f !important;font-weight:normal !important;}
.syntaxhighlighter .xml .color1,.syntaxhighlighter .xml .color1 a{color:#7f007f !important;}
.syntaxhighlighter .xml .string{font-style:italic !important;color:#2a00ff !important;}
|
magnusstahre/bonsai-osx
|
html/lib/syntaxhighlighter/styles/shThemeEclipse.css
|
CSS
|
gpl-2.0
| 2,961
|
// $Id$
// $Locker$
// Author. Roar Thronæs.
// Modified Linux source file, 2001-2004.
#ifndef _I386_PGALLOC_H
#define _I386_PGALLOC_H
#include <linux/config.h>
#include <asm/processor.h>
#include <asm/fixmap.h>
#include <linux/threads.h>
#define pgd_quicklist (current_cpu_data.pgd_quick)
#define pmd_quicklist (current_cpu_data.pmd_quick)
#define pte_quicklist (current_cpu_data.pte_quick)
#define pgtable_cache_size (current_cpu_data.pgtable_cache_sz)
#define pmd_populate_kernel(mm, pmd, pte) \
set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
#define pmd_populate(mm, pmd, pte) \
set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte)))
/*
* Allocate and free page tables.
*/
extern pte_t *pte_alloc_one_kernel(struct mm_struct *, unsigned long);
//extern struct page *pte_alloc_one(struct mm_struct *, unsigned long);
static inline void pte_free_kernel(pte_t *pte)
{
free_page((unsigned long)pte);
}
static inline void pte_free(struct page *pte)
{
__free_page(pte);
}
#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte))
#if defined (CONFIG_X86_PAE)
/*
* We can't include <linux/slab.h> here, thus these uglinesses.
*/
struct kmem_cache_s;
extern struct kmem_cache_s *pae_pgd_cachep;
extern void *kmem_cache_alloc(struct kmem_cache_s *, int);
extern void kmem_cache_free(struct kmem_cache_s *, void *);
static inline pgd_t *get_pgd_slow(void)
{
int i;
pgd_t *pgd = kmem_cache_alloc(pae_pgd_cachep, GFP_KERNEL);
if (pgd)
{
for (i = 0; i < USER_PTRS_PER_PGD; i++)
{
unsigned long pmd = __get_free_page(GFP_KERNEL);
if (!pmd)
goto out_oom;
clear_page(pmd);
set_pgd(pgd + i, __pgd(1 + __pa(pmd)));
}
memcpy(pgd + USER_PTRS_PER_PGD,
swapper_pg_dir + USER_PTRS_PER_PGD,
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
}
return pgd;
out_oom:
for (i--; i >= 0; i--)
free_page((unsigned long)__va(pgd_val(pgd[i])-1));
kmem_cache_free(pae_pgd_cachep, pgd);
return NULL;
}
#else
static inline pgd_t *get_pgd_slow(void)
{
pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL);
if (pgd)
{
memset(pgd, 0, USER_PTRS_PER_PGD * sizeof(pgd_t));
memcpy(pgd + USER_PTRS_PER_PGD,
swapper_pg_dir + USER_PTRS_PER_PGD,
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
}
return pgd;
}
#endif /* CONFIG_X86_PAE */
static inline pgd_t *get_pgd_fast(void)
{
unsigned long *ret;
if ((ret = pgd_quicklist) != NULL)
{
pgd_quicklist = (unsigned long *)(*ret);
ret[0] = 0;
pgtable_cache_size--;
}
else
ret = (unsigned long *)get_pgd_slow();
return (pgd_t *)ret;
}
static inline void free_pgd_fast(pgd_t *pgd)
{
*(unsigned long *)pgd = (unsigned long) pgd_quicklist;
pgd_quicklist = (unsigned long *) pgd;
pgtable_cache_size++;
}
static inline void free_pgd_slow(pgd_t *pgd)
{
#if defined(CONFIG_X86_PAE)
int i;
for (i = 0; i < USER_PTRS_PER_PGD; i++)
free_page((unsigned long)__va(pgd_val(pgd[i])-1));
kmem_cache_free(pae_pgd_cachep, pgd);
#else
free_page((unsigned long)pgd);
#endif
}
static inline pte_t *pte_alloc_one(struct mm_struct *mm, unsigned long address)
{
pte_t *pte;
pte = (pte_t *) __get_free_page(GFP_KERNEL);
if (pte)
clear_page(pte);
return pte;
}
static inline pte_t *pte_alloc_one_fast(struct mm_struct *mm,
unsigned long address)
{
unsigned long *ret;
if ((ret = (unsigned long *)pte_quicklist) != NULL)
{
pte_quicklist = (unsigned long *)(*ret);
ret[0] = ret[1];
pgtable_cache_size--;
}
return (pte_t *)ret;
}
static inline void pte_free_fast(pte_t *pte)
{
*(unsigned long *)pte = (unsigned long) pte_quicklist;
pte_quicklist = (unsigned long *) pte;
pgtable_cache_size++;
}
static __inline__ void pte_free_slow(pte_t *pte)
{
free_page((unsigned long)pte);
}
#define pte_free(pte) pte_free_slow(pte)
#define pgd_free(pgd) free_pgd_slow(pgd)
#define pgd_alloc(mm) get_pgd_fast()
/*
* allocating and freeing a pmd is trivial: the 1-entry pmd is
* inside the pgd, so has no extra memory associated with it.
* (In the PAE case we free the pmds as part of the pgd.)
*/
#define pmd_alloc_one_fast(mm, addr) ({ BUG(); ((pmd_t *)1); })
#define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
#define pmd_free_slow(x) do { } while (0)
#define pmd_free_fast(x) do { } while (0)
#define pmd_free(x) do { } while (0)
#define pgd_populate(mm, pmd, pte) BUG()
extern int do_check_pgt_cache(int, int);
/*
* TLB flushing:
*
* - flush_tlb() flushes the current mm struct TLBs
* - flush_tlb_all() flushes all processes TLBs
* - flush_tlb_mm(mm) flushes the specified mm context TLB's
* - flush_tlb_page(vma, vmaddr) flushes one page
* - flush_tlb_range(mm, start, end) flushes a range of pages
* - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
*
* ..but the i386 has somewhat limited tlb flushing capabilities,
* and page-granular flushes are available only on i486 and up.
*/
#ifndef CONFIG_SMP
#define flush_tlb() __flush_tlb()
#define flush_tlb_all() __flush_tlb_all()
#define local_flush_tlb() __flush_tlb()
static inline void flush_tlb_mm(struct mm_struct *mm)
{
if (mm == current->active_mm)
__flush_tlb();
}
static inline void flush_tlb_page2(struct mm_struct *mm,
unsigned long addr)
{
if (mm == current->active_mm)
__flush_tlb_one(addr);
}
static inline void flush_tlb_range(struct mm_struct *mm,
unsigned long start, unsigned long end)
{
if (mm == current->active_mm)
__flush_tlb();
}
#else
#include <asm/smp.h>
extern void flush_tlb_page2(struct mm_struct *, unsigned long);
#define local_flush_tlb() \
__flush_tlb()
extern void flush_tlb_all(void);
extern void flush_tlb_current_task(void);
extern void flush_tlb_mm(struct mm_struct *);
extern void flush_tlb_page(struct vm_area_struct *, unsigned long);
#define flush_tlb() flush_tlb_current_task()
static inline void flush_tlb_range(struct mm_struct * mm, unsigned long start, unsigned long end)
{
flush_tlb_mm(mm);
}
#define TLBSTATE_OK 1
#define TLBSTATE_LAZY 2
struct tlb_state
{
struct mm_struct *active_mm;
int state;
};
extern struct tlb_state cpu_tlbstate[NR_CPUS];
#endif
static inline void flush_tlb_pgtables(struct mm_struct *mm,
unsigned long start, unsigned long end)
{
/* i386 does not keep any page table caches in TLB */
}
#endif /* _I386_PGALLOC_H */
|
rroart/freevms
|
linux/include/asm-i386/pgalloc.h
|
C
|
gpl-2.0
| 6,741
|
HAY-landing-page
================
Landing page for HAY application
|
WenigerSH/HAY-landing-page
|
README.md
|
Markdown
|
gpl-2.0
| 68
|
/*
command.h
flexemu, an MC6809 emulator running FLEX
Copyright (C) 1997-2022 W. Schwotzer
This program 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 2 of the License, or
any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef COMMAND_INCLUDED
#define COMMAND_INCLUDED
#include "misc1.h"
#include "iodevice.h"
#include "bobservd.h"
#include <string>
#define MAX_COMMAND (128)
#define INVALID_DRIVE (4)
#define CR (0x0d)
class Inout;
class E2floppy;
class Scheduler;
class Command : public IoDevice, public BObserved
{
// Internal registers
protected:
Inout &inout;
Scheduler &scheduler;
E2floppy &fdc;
char command[MAX_COMMAND];
Word command_index;
Word answer_index;
std::string answer;
// private interface:
private:
void skip_token(char **);
const char *next_token(char **, int *);
const char *modify_command_token(char *p);
// public interface
public:
void resetIo() override;
Byte readIo(Word offset) override;
void writeIo(Word offset, Byte val) override;
const char *getName() override
{
return "command";
};
Word sizeOfIo() override
{
return 1;
}
public:
Command(
Inout &x_inout,
Scheduler &x_scheduler,
E2floppy &x_fdc);
virtual ~Command();
};
#endif // COMMAND_INCLUDED
|
aladur/flexemu
|
src/command.h
|
C
|
gpl-2.0
| 1,982
|
package org.mule.tooling.incubator.maven.ui.internal;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import org.mule.tooling.incubator.maven.core.MavenArtifactResolver;
public class ProjectModelCache {
private static ProjectModelCache INSTANCE;
ProjectModelCache() {
}
public static ProjectModelCache getInstance() {
if (INSTANCE == null)
INSTANCE = new ProjectModelCache();
return INSTANCE;
}
Map<String, Object> cache = new HashMap<String, Object>();
public PluginDescriptor getPluginDescriptor(Plugin plugin) throws IOException, PlexusConfigurationException, Exception {
synchronized (cache) {
PluginDescriptor descriptor = (PluginDescriptor) cache.get(plugin.getKey());
if (descriptor == null) {
String version = plugin.getVersion();
VersionRange range = null;
if (version == null) {
version = "LATEST";
range = VersionRange.createFromVersionSpec(version);
} else {
range = VersionRange.createFromVersion(version);
}
DefaultArtifact pluginArtifact = new DefaultArtifact(plugin.getGroupId(), plugin.getArtifactId(), range, null, "jar", null, new DefaultArtifactHandler("jar"));
descriptor = MavenArtifactResolver.getInstance().getPluginDescriptor(pluginArtifact);
cache.put(plugin.getKey(), descriptor);
}
return descriptor;
}
}
}
|
mulesoft/mule-tooling-incubator
|
org.mule.tooling.incubator.maven.ui.contribution/src/org/mule/tooling/incubator/maven/ui/internal/ProjectModelCache.java
|
Java
|
gpl-2.0
| 1,927
|
/*
* Copyright (C) 2013-2014 Team KODI
* http://kodi.tv
*
* This Program 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 2, or (at your option)
* any later version.
*
* This Program 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 KODI; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "addons/kodi-addon-dev-kit/include/kodi/libKODI_audioengine.h"
#include "addons/binary/interfaces/api1/AudioEngine/AddonCallbacksAudioEngine.h"
#ifdef _WIN32
#include <windows.h>
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#endif
using namespace std;
using namespace KodiAPI::V1::AudioEngine;
#define LIBRARY_NAME "libKODI_audioengine"
extern "C"
{
DLLEXPORT void* AudioEngine_register_me(void *hdl)
{
CB_AudioEngineLib *cb = NULL;
if (!hdl)
fprintf(stderr, "%s-ERROR: AudioEngine_register_me is called with NULL handle !!!\n", LIBRARY_NAME);
else
{
cb = (CB_AudioEngineLib*)((AddonCB*)hdl)->AudioEngineLib_RegisterMe(((AddonCB*)hdl)->addonData);
if (!cb)
fprintf(stderr, "%s-ERROR: AudioEngine_register_me can't get callback table from KODI !!!\n", LIBRARY_NAME);
}
return cb;
}
DLLEXPORT void AudioEngine_unregister_me(void *hdl, void* cb)
{
if (hdl && cb)
((AddonCB*)hdl)->AudioEngineLib_UnRegisterMe(((AddonCB*)hdl)->addonData, (CB_AudioEngineLib*)cb);
}
// ---------------------------------------------
// CAddonAEStream implementations
// ---------------------------------------------
DLLEXPORT CAddonAEStream* AudioEngine_make_stream(void *hdl, void *cb, AudioEngineFormat& Format, unsigned int Options)
{
if (!hdl || !cb)
{
fprintf(stderr, "%s-ERROR: AudioEngine_register_me is called with NULL handle !!!\n", LIBRARY_NAME);
return NULL;
}
AEStreamHandle *streamHandle = ((CB_AudioEngineLib*)cb)->MakeStream(Format, Options);
if (!streamHandle)
{
fprintf(stderr, "%s-ERROR: AudioEngine_make_stream MakeStream failed!\n", LIBRARY_NAME);
return NULL;
}
return new CAddonAEStream(hdl, cb, streamHandle);
}
DLLEXPORT void AudioEngine_free_stream(CAddonAEStream *p)
{
if (p)
{
delete p;
}
}
DLLEXPORT bool AudioEngine_get_current_sink_Format(void *hdl, void *cb, AudioEngineFormat *SinkFormat)
{
if (!cb)
{
return false;
}
return ((CB_AudioEngineLib*)cb)->GetCurrentSinkFormat(((AddonCB*)hdl)->addonData, SinkFormat);
}
CAddonAEStream::CAddonAEStream(void *Addon, void *Callbacks, AEStreamHandle *StreamHandle)
{
m_AddonHandle = Addon;
m_Callbacks = Callbacks;
m_StreamHandle = StreamHandle;
}
CAddonAEStream::~CAddonAEStream()
{
if (m_StreamHandle)
{
((CB_AudioEngineLib*)m_Callbacks)->FreeStream(m_StreamHandle);
m_StreamHandle = NULL;
}
}
unsigned int CAddonAEStream::GetSpace()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetSpace(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
unsigned int CAddonAEStream::AddData(uint8_t* const *Data, unsigned int Offset, unsigned int Frames)
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_AddData(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle, Data, Offset, Frames);
}
double CAddonAEStream::GetDelay()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetDelay(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
bool CAddonAEStream::IsBuffering()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_IsBuffering(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
double CAddonAEStream::GetCacheTime()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetCacheTime(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
double CAddonAEStream::GetCacheTotal()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetCacheTotal(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
void CAddonAEStream::Pause()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_Pause(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
void CAddonAEStream::Resume()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_Resume(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
void CAddonAEStream::Drain(bool Wait)
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_Drain(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle, Wait);
}
bool CAddonAEStream::IsDraining()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_IsDraining(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
bool CAddonAEStream::IsDrained()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_IsDrained(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
void CAddonAEStream::Flush()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_Flush(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
float CAddonAEStream::GetVolume()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetVolume(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
void CAddonAEStream::SetVolume(float Volume)
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_SetVolume(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle, Volume);
}
float CAddonAEStream::GetAmplification()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetAmplification(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
void CAddonAEStream::SetAmplification(float Amplify)
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_SetAmplification(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle, Amplify);
}
const unsigned int CAddonAEStream::GetFrameSize() const
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetFrameSize(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
const unsigned int CAddonAEStream::GetChannelCount() const
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetChannelCount(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
const unsigned int CAddonAEStream::GetSampleRate() const
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetSampleRate(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
const AEDataFormat CAddonAEStream::GetDataFormat() const
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetDataFormat(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
double CAddonAEStream::GetResampleRatio()
{
return ((CB_AudioEngineLib*)m_Callbacks)->AEStream_GetResampleRatio(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle);
}
void CAddonAEStream::SetResampleRatio(double Ratio)
{
((CB_AudioEngineLib*)m_Callbacks)->AEStream_SetResampleRatio(((AddonCB*)m_AddonHandle)->addonData, m_StreamHandle, Ratio);
}
};
|
raptorjr/xbmc
|
lib/addons/library.kodi.audioengine/libKODI_audioengine.cpp
|
C++
|
gpl-2.0
| 6,983
|
package com.yunruiinfo.iclass.student.fragment;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.JsonParseException;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.yunruiinfo.iclass.student.R;
import com.yunruiinfo.iclass.student.AppException;
import com.yunruiinfo.iclass.student.activity.MainActivity;
import com.yunruiinfo.iclass.student.adapter.ListViewCourseAdapter;
import com.yunruiinfo.iclass.student.bean.Course;
import com.yunruiinfo.iclass.student.bean.Result;
import com.yunruiinfo.iclass.student.bean.URLs;
import com.yunruiinfo.iclass.student.util.JsonUtils;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.TextView;
public class CourseListFragment extends BaseFragment{
@ViewInject(R.id.empty_text) private TextView mEmptyView;
@ViewInject(R.id.course_list) private ListView mCoursesView;
private List<Course> mCoursesData = new ArrayList<Course>();
private ListViewCourseAdapter mCourseAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_list_course, container, false);
ViewUtils.inject(this, view);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getActivity().setTitle("在线课程");
mCoursesView.setEmptyView(mEmptyView);
mCourseAdapter = new ListViewCourseAdapter(getActivity());
mCourseAdapter.setOnItemClickListener(new ListViewCourseAdapter.OnItemClickListener() {
@Override
public void onClick(int position) {
Course course = (Course) mCourseAdapter.getItem(position);
showResourses(course.getId());
}
});
mCoursesView.setAdapter(mCourseAdapter);
mCoursesView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Course course = (Course) mCourseAdapter.getItem(position);
showCourse(course.getId());
}
});
HttpUtils http = new HttpUtils();
RequestParams params = new RequestParams();
params.addQueryStringParameter("type", "courses");
params.addQueryStringParameter("userId", Integer.toString(appContext.getUserId()));
http.send(HttpMethod.GET, URLs.API_URL, params, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
try {
Result result = JsonUtils.fromJson(responseInfo.result, Result.class);
if (!result.OK()) {
throw AppException.custom(result.Message());
} else if (result.courses.size() > 0) {
mCoursesData = result.courses;
mCourseAdapter.setCourses(mCoursesData);
mCourseAdapter.notifyDataSetChanged();
} else {
mEmptyView.setText("暂无课程数据");
}
} catch (JsonParseException e) {
AppException.json(e).makeToast(getActivity());
} catch (AppException e) {
e.makeToast(getActivity());
}
}
@Override
public void onStart() {
mEmptyView.setText("正在获取课程列表");
}
@Override
public void onFailure(HttpException error, String msg) {
mEmptyView.setText("暂无课程数据");
}
});
}
private void showCourse(int id) {
Bundle bundle = new Bundle();
bundle.putInt("id", id);
MainActivity fca = (MainActivity) getActivity();
Fragment fragment = Fragment.instantiate(getActivity(), CourseInfoFragment.class.getName(), bundle);
fca.switchContent(fragment);
}
/**
* 显示教学材料
* @param courseId
*/
private void showResourses(int courseId) {
Bundle bundle = new Bundle();
bundle.putSerializable("id", courseId);
MainActivity fca = (MainActivity) getActivity();
Fragment fragment = Fragment.instantiate(getActivity(), ResourseFragment.class.getName(), bundle);
fca.switchContent(fragment);
}
}
|
ChuJianan/iStudent_Android
|
src/com/yunruiinfo/iclass/student/fragment/CourseListFragment.java
|
Java
|
gpl-2.0
| 4,415
|
/*
* Copyright (C) 2010-2011 Project SkyFire <http://www.projectskyfire.org/>
*
* This program 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 2 of the License, or (at your
* option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptPCH.h"
#include "blackrock_caverns.h"
class boss_corla_herald_of_twilight : public CreatureScript
{
public:
boss_corla_herald_of_twilight() : CreatureScript("boss_corla_herald_of_twilight") { }
CreatureAI* GetAI(Creature* creature) const
{
return new boss_corla_herald_of_twilightAI (creature);
}
struct boss_corla_herald_of_twilightAI : public ScriptedAI
{
boss_corla_herald_of_twilightAI(Creature* creature) : ScriptedAI(creature)
{
instance = creature->GetInstanceScript();
}
InstanceScript* instance;
void Reset() {}
void EnterCombat(Unit* /*who*/) {}
void UpdateAI(const uint32 Diff)
{
if (!UpdateVictim())
return;
DoMeleeAttackIfReady();
}
};
};
void AddSC_boss_corla_herald_of_twilight()
{
new boss_corla_herald_of_twilight();
}
|
sourceleaker/gaycore
|
src/server/scripts/EasternKingdoms/BlackrockCaverns/boss_corla_herald_of_twilight.cpp
|
C++
|
gpl-2.0
| 1,640
|
import React from 'react';
import { toJunction } from 'brookjs';
import { Observable } from 'kefir';
import { i18n, link } from '../../../helpers';
import { jobDispatchClick } from '../../../actions';
import { Job } from './types';
type Props = Job & { onClick: (slug: string) => void };
const Row: React.FC<Props> = ({ name, description, status, slug, onClick }) => (
<tr>
<td>
<strong>{name}</strong>
</td>
<td>{description}</td>
<td>{status}</td>
<td>
<a href={link('wpgp_route', `jobs/${slug}`)}>{i18n('jobs.runs.view')}</a>
</td>
<td>
<button
className="button button-primary"
data-testid={`dispatch-job-${slug}`}
onClick={() => onClick(slug)}
>
{i18n('jobs.dispatch')}
</button>
</td>
</tr>
);
const events = {
onClick: (evt$: Observable<string, never>) =>
evt$.map(jobDispatchClick).debounce(200),
};
export default toJunction(events)(Row);
|
mAAdhaTTah/WP-Gistpen
|
client/components/SettingsPage/Jobs/Row.tsx
|
TypeScript
|
gpl-2.0
| 956
|
// Aseprite UI Library
// Copyright (C) 2001-2014 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifndef UI_MOVE_REGION_H_INCLUDED
#define UI_MOVE_REGION_H_INCLUDED
#pragma once
#include "gfx/region.h"
namespace ui { // TODO all these functions are deprecated and must be replaced by Graphics methods.
void move_region(const gfx::Region& region, int dx, int dy);
} // namespace ui
#endif
|
0x414c/aseprite
|
src/ui/move_region.h
|
C
|
gpl-2.0
| 470
|
package it.polimi.sheepland.model;
/**
* This class represents regions
* @author Andrea
*
*/
public class Sheepsburg extends Region {
private static final long serialVersionUID = -903818216547674994L;
private static final String NAME = "Sheepsburg";
/**Constructor for the class
* @param type
* @param id
*/
public Sheepsburg(int id) {
super(null, id);
}
/**
* This is getter for name
* @return name
*/
@Override
public String getName() {
return NAME;
}
}
|
aturri/sheepland-aturri-asalmoiraghi
|
cg_1/src/main/java/it/polimi/sheepland/model/Sheepsburg.java
|
Java
|
gpl-2.0
| 518
|
cmd_drivers/bluetooth/bthid/built-in.o := rm -f drivers/bluetooth/bthid/built-in.o; /opt/toolchains/arm-2009q3/bin/arm-none-eabi-ar rcs drivers/bluetooth/bthid/built-in.o
|
dizgustipated/BOCA-2.6.35.14
|
drivers/bluetooth/bthid/.built-in.o.cmd
|
Batchfile
|
gpl-2.0
| 172
|
<!DOCTYPE html>
<html>
<head>
<!-- CSS -->
<link rel="stylesheet" href="/assets/css/main.css">
<title>
µflix: Easy Plex Server · Michael's Normcore Blog
</title>
<!-- Metadata -->
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="mobile-web-app-capable" content="yes">
<meta name="HandheldFriendly" content="True" />
<meta name="MobileOptimized" content="320" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.png">
<!-- Theme Color for Chrome on Android Lollipop -->
<meta name="theme-color" content="#52be80">
</head>
<body>
<!-- Header -->
<div class="animated fadeIn top-level-header ">
</div>
<div class="header-image" style="background-image: url(' /assets/images/cover.jpg ');">
</div>
<div class="toplevel-content">
<div class="container">
<div class="middle top-menu">
<a
class="menu-item fadeInDown animated"
href="/">blog</a>
<a
class="menu-item fadeInDown animated"
href="/tags">archive</a>
<a
class="menu-item fadeInDown animated"
href="/portfolio">projects</a>
<a
class="menu-item fadeInDown animated"
href="/about">me</a>
</div>
<div class="middle">
<div class="article animated fadeIn ">
<div class="post-title-container">
<h1 class="post-title"><b>µflix: Easy Plex Server</b></h1>
<p></p>
<div class="post-list-tags">
<a href="/tag/code">
<span class="tag new badge">code</span>
</a>
<a href="/tag/linux">
<span class="tag new badge">linux</span>
</a>
</div>
</div>
<p>Movies are really <strong>really</strong> great.</p>
<p>Ever since I started to prepare for the great apocalypse
that will wipe the world of sin I thought to myself:
“Wouldn’t it be <strong>really</strong> great if I could keep all the movies I love?
So my children, and my children’s children will think I’m cool?”
Keeping with the sin theme I decided to use <a href="https://plex.tv">Plex</a>, a non-FOSS Media
Server, to ensure that my taste outlives me.</p>
<p>So if you love hoarding movies (but don’t watch hoarders) and
preparing for the end (but haven’t seen that reality show about that)
you’ll love my new Plex container which is <em>dead simple</em> to use.</p>
<p>The project is <a href="https://github.com/illegalprime/uflix">hosted on GitHub</a> and is built on Docker.
If you’re unfamiliar with Docker, its a container framework,
and containers are kernel namespaces. The important metaphor
here is that containers are like shipping containers:
standardized, plug-n-play, and (sometimes) have lots of wasted space.
Basically you get an app running with all the dependencies, configuration,
etc. done for you! And its really easy to get rid of afterward
(unlike KDE, but I’m excited to try out NixOS, which is another solution to the KDE problem)!</p>
<p>After <a href="https://docs.docker.com/engine/installation/linux/ubuntulinux/">installing docker</a> all you need to set up your server is:</p>
<div class="language-bash highlighter-rouge"><pre class="highlight"><code>git clone https://github.com/illegalprime/uflix.git
<span class="nb">cd </span>uflix
sudo ./build
</code></pre>
</div>
<h2 id="its-got-features">Its got features!</h2>
<ul>
<li>No Configuration!</li>
<li>Easy to deploy, remove, and copy.</li>
<li>Just re-run <code class="highlighter-rouge">sudo ./build</code> to update!</li>
<li>Supports local discovery with <code class="highlighter-rouge">avahi</code>!</li>
<li>Mount as many drives or directories as you want with command line args</li>
<li>SSH Access to poke around</li>
</ul>
<p>To run simply call:</p>
<div class="language-bash highlighter-rouge"><pre class="highlight"><code>sudo ./start --metadata <plex metadata dir / disk>
</code></pre>
</div>
<p>The only required command line arg is where to store the Plex metadata.
This makes it easy to clone servers since you only need to copy your data drives.</p>
<p>Even with all this cool tech a more serious question remains, if we could
<em>only</em> save one terabyte of movies for the future which ones would they be?</p>
<p>I have my list. Do you?</p>
<br/>
<div class="post-footer">
<p>
— Michael
</p>
<div class="social">
<a href="/feed.xml"><i class="fa fa-rss" aria-hidden="true"></i></a>
<a href="https://github.com/illegalprime/">
<i class="fa fa-github" aria-hidden="true"></i>
</a>
<a href="https://matrix.to/#/@illegalprime:matrix.org">
<i class="fa fa-comments" aria-hidden="true"></i>
</a>
</div>
</div>
<hr>
<br/>
<!-- Disqus Comments Box -->
<h2><b>Say It Loud! Leave a comment below:</b></h2>
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = "https://oddoreden.com/2016/11/12/uflix/";
this.page.identifier = "_2016_11_12_uflix_";
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//icanteden.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Enable JavaScript to view comments.</noscript>
</div>
</div>
</div>
</div>
<footer>
</footer>
</body>
</html>
|
illegalprime/illegalprime.github.io
|
2016/11/12/uflix/index.html
|
HTML
|
gpl-2.0
| 5,766
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>McKenzie PTA Wilmette Illinois</title>
<link href="Formats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-image: url(Images/Background_1.jpg);
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
-->
</style>
<link href="/Formats.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style4 {color: #990066}
.style11 {color: #319DCE}
-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<style type="text/css">
<!--
.style62 {color: #000000;
}
.style75 {color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
}
.style15 {color: #329CCC}
.style16 {color: #2F9BCC}
-->
</style>
<style type="text/css">
<!--
.style19 {font-size: 14px; text-decoration: none; line-height: normal; font-weight: normal; letter-spacing: normal; font-family: Arial, Helvetica, sans-serif; color: #319DCE; }
-->
</style>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="index.html"><img src="Images/Background_2.jpg" width="900" height="112" border="0" /></a></td>
</tr>
<tr>
<td height="53" align="center" valign="middle" bgcolor="#98CEE6">
<div align="center">
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="index.html">HOME </a> </li>
<li><a href="#" class="MenuBarItemSubmenu">PROGRAMS & EVENTS </a>
<ul>
<li><a href="beyond_pta.html" class="MenuBarItemSubmenu">Parent Education</a>
<ul>
<li><a href="parent_learning_network.html">Parent Learning Network</a></li>
<li><a href="http://fan-ntts.ntnow.org/">Family Awareness Network</a></li>
<li><a href="http://www.peccalendar.org/">PEC Monthly Calendar</a></li>
</ul>
</li>
<li><a href="birthday_book.html">Birthday Books</a></li>
<li><a href="chess_club.html">Chess Club</a></li>
<li><a href="mcclubs/index.html">McClubs</a></li>
<li><a href="open_gym.html">Open Gym</a></li>
</ul>
</li>
<li><a href="committees.html">COMMITTEES </a> </li>
<li><a href="#" class="MenuBarItemSubmenu">FORMS & INFORMATION</a>
<ul>
<li><a href="communication.html">Communication</a></li>
<li><a href="treasurer.html">Treasurer</a></li>
<li><a href="membership.html">Membership</a></li>
<li><a href="operations.html">Operations</a></li>
<li><a href="archives.html">Archives</a></li>
<li><a href="faq.html">F.A.Q.</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">POLICIES & GUIDELINES</a>
<ul>
<li><a href="Archives/FromsDocuments/McK_pta_bylaws_020811.pdf">BYLAWS</a></li>
<li><a href="Archives/FromsDocuments/LetsGoMcKenzieGuide2010web.pdf">GETTING TO KNOW McKENZIE</a></li>
</ul>
</li>
<li><a href="contact.html">CONTACT US</a></li>
</ul>
</div></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF"><table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"><p> </p>
<p class="general_body_header">Site Map</p>
<table width="500" border="0" cellspacing="15" cellpadding="15">
<tr>
<td width="42"> </td>
<td width="353">coming soon...</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="general_body_subheader"> </td>
</tr>
</table>
<p> </p>
</td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p align="center" class="footer"><strong>Email <a href="mailto:AskCheetah@McKenziePTA.com" class="style11">AskCheetah@McKenziePTA.com</a> with any PTA related questions or concerns.</strong></p>
<p align="center" class="footer"><a href="index.html" class="footer">home</a> | <a href="sitemap.html" class="footer">site map</a> | <a href="archives.html" class="footer">archives</a> | <a href="mailto:WebMaster@McKenziePTA.com" class="footer">web administrator</a> | <a href="Archives/FromsDocuments/LetsGoMcKenzieGuide2010web.pdf" class="footer">school guide</a></p>
<p align="center" class="general_body"></p> <p align="center" class="general_body"> </p> </td>
</tr>
</table>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>
|
slb535/mckenziepta-2011
|
oldsite/sitemap.html
|
HTML
|
gpl-2.0
| 6,119
|
using UnityEngine;
using System.Collections;
public class GameManager : MonoBehaviour {
static public int currentLevel = 1;
static public bool integratedVersion = false;
static public int numOfLevels = 18;
public static GameObject measure;
public static Transform measureTransform;
public Sprite[] comicSprites;
public static void SetMeasure(GameObject measure, Transform transform) {
GameManager.measure = measure;
GameManager.measureTransform = transform;
}
void Start() {
if (GameManager.measure != null) {
if (!GameManager.integratedVersion) {
GameObject measure = GameManager.measure;
foreach (SpriteRenderer sr in measure.transform.GetComponentsInChildren<SpriteRenderer>())
sr.sprite = this.comicSprites[GameManager.currentLevel-2];
}
StartCoroutine (this.ShrinkMeasure(GameManager.measure));
}
}
private static class Constants
{
public static readonly float measureMoveTime = 1.2f;
public static readonly float measureShrinkTime = 2.2f;
}
private IEnumerator ShrinkMeasure (GameObject measure) {
measure.transform.parent = this.gameObject.transform;
measure.transform.position = GameManager.measureTransform.position;
measure.transform.localScale = GameManager.measureTransform.localScale * (4.95f / 4.25f);
LevelSelectionGrid grid = LevelSelectionGrid.singleton;
GameObject measureTile;
if (GameManager.integratedVersion) {
measureTile = grid.musicUnlockTiles [currentLevel - 2];
yield return new WaitForSeconds (0.2f);
} else {
measureTile = grid.comicUnlockTiles [currentLevel - 2];
measure.transform.localScale *= 2.5f;
measure.transform.position = new Vector3(0, 0, measure.transform.position.z);
//measure.GetComponent<SpriteRenderer>().sprite.pivot
yield return new WaitForSeconds(2f);
}
Vector3 startPosition = measure.transform.position;
Vector3 destPosition = new Vector3(measureTile.transform.position.x, measureTile.transform.position.y, -9);
Vector3 startScale = measure.transform.localScale;
Vector3 destScale = new Vector3 (0f, 0f, startScale.z);
float t, s;
float currentTime = 0f;
float moveTime = Constants.measureMoveTime;
float shrinkTime = Constants.measureShrinkTime;
Transform transform = measure.transform;
while (currentTime <= moveTime) {
t = currentTime / moveTime;
t = t * t * t * (t * (6f * t - 15f) + 10f);
s = currentTime / shrinkTime;
s = s * s * s * (s * (6f * s - 15f) + 10f);
transform.position = Vector3.Lerp (startPosition, destPosition, t);
transform.localScale = Vector3.Lerp (startScale, destScale, s);
yield return new WaitForEndOfFrame();
currentTime += Time.deltaTime;
}
transform.position = destPosition;
while (currentTime <= shrinkTime) {
s = currentTime / shrinkTime;
s = s * s * s * (s * (6f * s - 15f) + 10f);
transform.localScale = Vector3.Lerp(startScale, destScale, s);
yield return new WaitForEndOfFrame();
currentTime += Time.deltaTime;
}
Destroy (transform.gameObject);
GameManager.measure = null;
}
public static void MyLog(string message) {
Debug.Log(message + "\n" + System.DateTime.Now.ToString());
}
}
|
bluquar/martian-music-invasion
|
MMI0/Assets/Scripts/GameManager.cs
|
C#
|
gpl-2.0
| 3,168
|
package com.app.demos.base;
import com.app.demos.R;
import com.app.demos.base.BaseAuth;
import com.app.demos.demo.DemoMap;
import com.app.demos.demo.DemoWeb;
import com.app.demos.model.Customer;
import com.app.demos.test.TestUi;
import com.app.demos.ui.UiBlogs;
import com.app.demos.ui.UiConfig;
import com.app.demos.ui.UiIndex;
import com.app.demos.ui.UiLogin;
import android.app.AlertDialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
public class BaseUiAuth extends BaseUi {
private final int MENU_APP_WRITE = 0;
private final int MENU_APP_LOGOUT = 1;
private final int MENU_APP_ABOUT = 2;
private final int MENU_DEMO_WEB = 3;
private final int MENU_DEMO_MAP = 4;
private final int MENU_DEMO_TEST = 5;
protected static Customer customer = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!BaseAuth.isLogin()) {
this.forward(UiLogin.class);
this.onStop();
} else {
customer = BaseAuth.getCustomer();
}
}
@Override
public void onStart() {
super.onStart();
this.bindMainTop();
this.bindMainTab();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
menu.add(0, MENU_APP_WRITE, 0, R.string.menu_app_write).setIcon(android.R.drawable.ic_menu_add);
menu.add(0, MENU_APP_LOGOUT, 0, R.string.menu_app_logout).setIcon(android.R.drawable.ic_menu_close_clear_cancel);
menu.add(0, MENU_APP_ABOUT, 0, R.string.menu_app_about).setIcon(android.R.drawable.ic_menu_info_details);
menu.add(0, MENU_DEMO_WEB, 0, R.string.menu_demo_web).setIcon(android.R.drawable.ic_menu_view);
menu.add(0, MENU_DEMO_MAP, 0, R.string.menu_demo_map).setIcon(android.R.drawable.ic_menu_view);
menu.add(0, MENU_DEMO_TEST, 0, R.string.menu_demo_test).setIcon(android.R.drawable.ic_menu_view);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_APP_WRITE: {
doEditBlog();
break;
}
case MENU_APP_LOGOUT: {
doLogout(); // do logout first
forward(UiLogin.class);
break;
}
case MENU_APP_ABOUT:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.menu_app_about);
String appName = this.getString(R.string.app_name);
String appVersion = this.getString(R.string.app_version);
builder.setMessage(appName + " " + appVersion);
builder.setIcon(R.drawable.face);
builder.setPositiveButton(R.string.btn_cancel, null);
builder.show();
break;
case MENU_DEMO_WEB:
forward(DemoWeb.class);
break;
case MENU_DEMO_MAP:
forward(DemoMap.class);
break;
case MENU_DEMO_TEST:
forward(TestUi.class);
break;
}
return super.onOptionsItemSelected(item);
}
private void bindMainTop () {
Button bTopQuit = (Button) findViewById(R.id.main_top_quit);
if (bTopQuit != null) {
OnClickListener mOnClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.main_top_quit:
doFinish();
break;
}
}
};
bTopQuit.setOnClickListener(mOnClickListener);
}
}
private void bindMainTab () {
ImageButton bTabHome = (ImageButton) findViewById(R.id.main_tab_1);
ImageButton bTabBlog = (ImageButton) findViewById(R.id.main_tab_2);
ImageButton bTabConf = (ImageButton) findViewById(R.id.main_tab_3);
ImageButton bTabWrite = (ImageButton) findViewById(R.id.main_tab_4);
if (bTabHome != null && bTabBlog != null && bTabConf != null) {
OnClickListener mOnClickListener = new OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.main_tab_1:
forward(UiIndex.class);
break;
case R.id.main_tab_2:
forward(UiBlogs.class);
break;
case R.id.main_tab_3:
forward(UiConfig.class);
break;
case R.id.main_tab_4:
doEditBlog();
break;
}
}
};
bTabHome.setOnClickListener(mOnClickListener);
bTabBlog.setOnClickListener(mOnClickListener);
bTabConf.setOnClickListener(mOnClickListener);
bTabWrite.setOnClickListener(mOnClickListener);
}
}
}
|
liningwang/camera-beijing
|
android-php-weibo/client/src/com/app/demos/base/BaseUiAuth.java
|
Java
|
gpl-2.0
| 4,425
|
/*
* Copyright (c) 2021 Charles University, Faculty of Arts,
* Institute of the Czech National Corpus
* Copyright (c) 2021 Tomas Machalek <tomas.machalek@gmail.com>
* Copyright (c) 2021 Martin Zimandl <martin.zimandl@gmail.com>
*
* This program 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; version 2
* dated June, 1991.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as React from 'react';
import { Bound, IActionDispatcher } from 'kombo';
import * as Kontext from '../../../types/kontext';
import { PqueryResultModel, PqueryResultModelState, SortColumn } from '../../../models/pquery/result';
import { Actions } from '../../../models/pquery/actions';
import * as S from './style';
import { Color, id, List, pipe } from 'cnc-tskit';
import { init as initSaveViews } from './save';
import { PqueryResultsSaveModel } from '../../../models/pquery/save';
import { colorHeatmap } from '../../theme/default';
export interface PqueryFormViewsArgs {
dispatcher:IActionDispatcher;
he:Kontext.ComponentHelpers;
resultModel:PqueryResultModel;
saveModel:PqueryResultsSaveModel;
}
export function init({dispatcher, he, resultModel, saveModel}:PqueryFormViewsArgs):React.ComponentClass<{}> {
const layoutViews = he.getLayoutViews();
// ------------------------ <PageCounter /> --------------------------
const saveViews = initSaveViews(dispatcher, he, saveModel);
const PageCounter:React.FC<{
maxPage:number;
currPage:number;
currPageInput:Kontext.FormValue<string>;
}> = (props) => {
const setPage = (page:string|number) => () => {
dispatcher.dispatch(
Actions.SetPageInput,
{
value: typeof page === 'string' ? page : page + ''
}
);
};
return <S.PageCounter>
<a className={props.currPage === 1 ? "inactive" : null} onClick={props.currPage > 1 ? setPage(props.currPage-1) : null}>
<img src={he.createStaticUrl('img/prev-page.svg')} />
</a>
<span className="num-input">
<input type="text" className={props.currPageInput.isInvalid ? 'error' : null} value={props.currPageInput.value}
onChange={e => setPage(e.target.value)()} /> / {props.maxPage}
</span>
<a className={props.currPage === props.maxPage ? "inactive" : null} onClick={props.currPage < props.maxPage ? setPage(props.currPage+1) : null}>
<img src={he.createStaticUrl('img/next-page.svg')} />
</a>
</S.PageCounter>
};
// ------------------------ <ThSortable /> --------------------------
const ThSortable:React.FC<{
sortColumn:SortColumn;
actualSortColumn:SortColumn;
label:string;
}> = (props) => {
const isSortedByMe = () => {
if (!props.actualSortColumn) {
return false;
}
if (props.sortColumn.type === 'partial_freq' &&
props.actualSortColumn.type === 'partial_freq') {
return props.sortColumn.concId === props.actualSortColumn.concId;
}
return props.sortColumn.type === props.actualSortColumn.type;
}
const renderSortFlag = () => {
if (isSortedByMe()) {
return props.actualSortColumn.reverse ?
<img className="sort-flag" src={he.createStaticUrl('img/sort_desc.svg')} /> :
<img className="sort-flag" src={he.createStaticUrl('img/sort_asc.svg')} />;
} else {
return null;
}
};
const handleSortClick = () => {
dispatcher.dispatch<typeof Actions.SortLines>({
name: Actions.SortLines.name,
payload: {
...props.sortColumn,
reverse: !(isSortedByMe() && props.actualSortColumn.reverse)
}
});
};
const getTitle = () => {
if (isSortedByMe()) {
return he.translate('global__sorted_click_change');
}
return he.translate('global__click_to_sort');
};
return (
<th>
<a onClick={handleSortClick} title={getTitle()}>
{props.label}
{renderSortFlag()}
</a>
</th>
);
};
// ---------------- <PqueryResultSection /> ----------------------------
const PqueryResultSection:React.FC<PqueryResultModelState> = (props) => {
const _handleSaveFormClose = () => {
dispatcher.dispatch<typeof Actions.ResultCloseSaveForm>({
name: Actions.ResultCloseSaveForm.name
})
};
const mapColor = (idx:number) => colorHeatmap[~~Math.floor((idx) * (colorHeatmap.length - 1) / props.concIds.length)];
const _handleFilter = (value:string, concId:string) => (e) => {
dispatcher.dispatch<typeof Actions.ResultApplyQuickFilter>({
name: Actions.ResultApplyQuickFilter.name,
payload: {
value,
concId,
blankWindow: e.ctrlKey
}
});
};
const renderContent = () => {
if (props.numLines === 0) {
return <S.NoResultPar>{he.translate('pquery__no_result')}</S.NoResultPar>;
} else {
return (
<>
<section className="heading">
<div className="controls">
<p>{he.translate('pquery__avail_label')}: {props.numLines}</p>
<PageCounter
maxPage={Math.ceil(props.numLines/props.pageSize)}
currPage={props.page}
currPageInput={props.pageInput} />
</div>
<div className="loader">
{props.isBusy ? <layoutViews.AjaxLoaderImage /> : <div />}
</div>
</section>
<table className={`data${props.isBusy ? ' busy' : ''}`}>
<thead>
<tr>
<th colSpan={2} />
{List.map(
(concId, i) => (
<React.Fragment key={concId}>
<th className="conc-group" colSpan={2}>{`Conc ${i+1}`}</th>
</React.Fragment>
),
props.concIds
)}
<th />
</tr>
<tr>
<th />
<ThSortable sortColumn={{type: 'value', reverse: false}}
actualSortColumn={props.sortColumn} label="Value"/>
{List.map(
(concId, i) => (
<React.Fragment key={concId}>
<ThSortable sortColumn={{type: 'partial_freq', concId, reverse: false}}
actualSortColumn={props.sortColumn} label="Freq" />
<th>Filter</th>
</React.Fragment>
),
props.concIds
)}
<ThSortable sortColumn={{type: 'freq', reverse: false}} actualSortColumn={props.sortColumn}
label={'Freq \u2211'} />
</tr>
</thead>
<tbody>
{List.map(
([word, ...freqs], i) => (
<tr key={`${i}:${word}`}>
<td className="num">{(props.page-1)*props.pageSize+i+1}</td>
<td>{word}</td>
{List.map(
(f, i) => {
const idx = pipe(
freqs,
List.sortedBy(id),
List.findIndex(v => v === f)
);
const bgCol = mapColor(idx);
const textCol = pipe(
bgCol,
Color.importColor(1),
Color.textColorFromBg(),
Color.color2str()
);
const style = {
backgroundColor: bgCol,
color: textCol
};
return (
<React.Fragment key={props.concIds[i]}>
<td style={style} className="num">{f}</td>
<td><a onClick={_handleFilter(word, props.concIds[i])}>p</a></td>
</React.Fragment>
);
},
freqs
)}
<td className="num sum">{List.foldl((acc, curr) => acc + curr, 0, freqs)}</td>
</tr>
),
props.data
)}
</tbody>
</table>
{props.saveFormActive ?
<saveViews.SavePqueryForm onClose={_handleSaveFormClose} /> :
null
}
</>
);
}
};
return <S.PqueryResultSection>{renderContent()}</S.PqueryResultSection>;
};
return Bound(PqueryResultSection, resultModel);
}
|
czcorpus/kontext
|
public/files/js/views/pquery/result/index.tsx
|
TypeScript
|
gpl-2.0
| 11,875
|
#
# @BEGIN LICENSE
#
# Psi4: an open-source quantum chemistry software package
#
# Copyright (c) 2007-2017 The Psi4 Developers.
#
# The copyrights for code used from other parties are included in
# the corresponding files.
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# @END LICENSE
#
"""Module with a *procedures* dictionary specifying available quantum
chemical methods.
"""
from __future__ import print_function
from __future__ import absolute_import
from . import proc
from . import interface_cfour
# never import wrappers or aliases into this file
# Procedure lookup tables
procedures = {
'energy': {
'hf' : proc.run_scf,
'scf' : proc.run_scf,
'mcscf' : proc.run_mcscf,
'dcft' : proc.run_dcft,
'mp3' : proc.select_mp3,
'mp2.5' : proc.select_mp2p5,
'mp2' : proc.select_mp2,
'omp2' : proc.select_omp2,
'scs-omp2' : proc.run_occ,
'scs(n)-omp2' : proc.run_occ,
'scs-omp2-vdw' : proc.run_occ,
'sos-omp2' : proc.run_occ,
'sos-pi-omp2' : proc.run_occ,
'omp3' : proc.select_omp3,
'scs-omp3' : proc.run_occ,
'scs(n)-omp3' : proc.run_occ,
'scs-omp3-vdw' : proc.run_occ,
'sos-omp3' : proc.run_occ,
'sos-pi-omp3' : proc.run_occ,
'olccd' : proc.select_olccd,
'omp2.5' : proc.select_omp2p5,
'dfocc' : proc.run_dfocc, # full control over dfocc
'qchf' : proc.run_qchf,
'ccd' : proc.run_dfocc,
'sapt0' : proc.run_sapt,
'ssapt0' : proc.run_sapt,
'sapt2' : proc.run_sapt,
'sapt2+' : proc.run_sapt,
'sapt2+(3)' : proc.run_sapt,
'sapt2+3' : proc.run_sapt,
'sapt2+(ccd)' : proc.run_sapt,
'sapt2+(3)(ccd)': proc.run_sapt,
'sapt2+3(ccd)' : proc.run_sapt,
'sapt2+dmp2' : proc.run_sapt,
'sapt2+(3)dmp2' : proc.run_sapt,
'sapt2+3dmp2' : proc.run_sapt,
'sapt2+(ccd)dmp2' : proc.run_sapt,
'sapt2+(3)(ccd)dmp2' : proc.run_sapt,
'sapt2+3(ccd)dmp2' : proc.run_sapt,
'sapt0-ct' : proc.run_sapt_ct,
'sapt2-ct' : proc.run_sapt_ct,
'sapt2+-ct' : proc.run_sapt_ct,
'sapt2+(3)-ct' : proc.run_sapt_ct,
'sapt2+3-ct' : proc.run_sapt_ct,
'sapt2+(ccd)-ct' : proc.run_sapt_ct,
'sapt2+(3)(ccd)-ct' : proc.run_sapt_ct,
'sapt2+3(ccd)-ct' : proc.run_sapt_ct,
'fisapt0' : proc.run_fisapt,
'ccenergy' : proc.run_ccenergy, # full control over ccenergy
'ccsd' : proc.select_ccsd,
'ccsd(t)' : proc.select_ccsd_t_,
'ccsd(at)' : proc.select_ccsd_at_,
'cc2' : proc.run_ccenergy,
'cc3' : proc.run_ccenergy,
'mrcc' : proc.run_mrcc, # interface to Kallay's MRCC program
'bccd' : proc.run_bccd,
'bccd(t)' : proc.run_bccd,
'eom-ccsd' : proc.run_eom_cc,
'eom-cc2' : proc.run_eom_cc,
'eom-cc3' : proc.run_eom_cc,
'detci' : proc.run_detci, # full control over detci
'mp' : proc.run_detci, # arbitrary order mp(n)
'zapt' : proc.run_detci, # arbitrary order zapt(n)
'cisd' : proc.select_cisd,
'cisdt' : proc.run_detci,
'cisdtq' : proc.run_detci,
'ci' : proc.run_detci, # arbitrary order ci(n)
'fci' : proc.run_detci,
'casscf' : proc.run_detcas,
'rasscf' : proc.run_detcas,
'adc' : proc.run_adc,
# 'cphf' : proc.run_libfock,
# 'cis' : proc.run_libfock,
# 'tdhf' : proc.run_libfock,
# 'cpks' : proc.run_libfock,
# 'tda' : proc.run_libfock,
# 'tddft' : proc.run_libfock,
'psimrcc' : proc.run_psimrcc,
'psimrcc_scf' : proc.run_psimrcc_scf,
'qcisd' : proc.run_fnocc,
'qcisd(t)' : proc.run_fnocc,
'mp4' : proc.select_mp4,
'mp4(sdq)' : proc.run_fnocc,
'fno-ccsd' : proc.select_fnoccsd,
'fno-ccsd(t)' : proc.select_fnoccsd_t_,
'fno-qcisd' : proc.run_fnocc,
'fno-qcisd(t)' : proc.run_fnocc,
'fno-mp3' : proc.run_fnocc,
'fno-mp4(sdq)' : proc.run_fnocc,
'fno-mp4' : proc.run_fnocc,
'fno-lccd' : proc.run_cepa,
'fno-lccsd' : proc.run_cepa,
'fno-cepa(0)' : proc.run_cepa,
'fno-cepa(1)' : proc.run_cepa,
'fno-cepa(3)' : proc.run_cepa,
'fno-acpf' : proc.run_cepa,
'fno-aqcc' : proc.run_cepa,
'fno-cisd' : proc.run_cepa,
'lccd' : proc.select_lccd,
'lccsd' : proc.run_cepa,
'cepa(0)' : proc.run_cepa,
'cepa(1)' : proc.run_cepa,
'cepa(3)' : proc.run_cepa,
'acpf' : proc.run_cepa,
'aqcc' : proc.run_cepa,
'efp' : proc.run_efp,
'dmrg-scf' : proc.run_dmrgscf,
'dmrg-caspt2' : proc.run_dmrgscf,
'dmrg-ci' : proc.run_dmrgci,
# Upon adding a method to this list, add it to the docstring in energy() below
# Aliases are discouraged. If you must add an alias to this list (e.g.,
# lccsd/cepa(0)), please search the whole driver to find uses of
# name in return values and psi variables and extend the logic to
# encompass the new alias.
},
'gradient' : {
'hf' : proc.run_scf_gradient,
'scf' : proc.run_scf_gradient,
'cc2' : proc.run_ccenergy_gradient,
'ccsd' : proc.select_ccsd_gradient,
'ccsd(t)' : proc.select_ccsd_t__gradient,
'mp2' : proc.select_mp2_gradient,
'eom-ccsd' : proc.run_eom_cc_gradient,
'dcft' : proc.run_dcft_gradient,
'omp2' : proc.select_omp2_gradient,
'omp3' : proc.select_omp3_gradient,
'mp3' : proc.select_mp3_gradient,
'mp2.5' : proc.select_mp2p5_gradient,
'omp2.5' : proc.select_omp2p5_gradient,
'lccd' : proc.select_lccd_gradient,
'olccd' : proc.select_olccd_gradient,
'ccd' : proc.run_dfocc_gradient,
# Upon adding a method to this list, add it to the docstring in optimize() below
},
'hessian' : {
# Upon adding a method to this list, add it to the docstring in frequency() below
'hf' : proc.run_scf_hessian,
'scf' : proc.run_scf_hessian,
},
'property' : {
'hf' : proc.run_scf_property,
'scf' : proc.run_scf_property,
'mp2' : proc.select_mp2_property,
'cc2' : proc.run_cc_property,
'ccsd' : proc.run_cc_property,
'eom-cc2' : proc.run_cc_property,
'eom-ccsd' : proc.run_cc_property,
'detci' : proc.run_detci_property, # full control over detci
'cisd' : proc.run_detci_property,
'cisdt' : proc.run_detci_property,
'cisdtq' : proc.run_detci_property,
'ci' : proc.run_detci_property, # arbitrary order ci(n)
'fci' : proc.run_detci_property,
'rasscf' : proc.run_detci_property,
'casscf' : proc.run_detci_property,
# Upon adding a method to this list, add it to the docstring in property() below
}}
# Will only allow energy to be run for the following methods
energy_only_methods = [x for x in procedures['energy'].keys() if 'sapt' in x]
energy_only_methods += ['adc', 'efp', 'cphf', 'tdhf', 'cis']
# Integrate DFT with driver routines
superfunc_list = proc.dft_functional.superfunctional_list
for ssuper in superfunc_list:
procedures['energy'][ssuper.name().lower()] = proc.run_dft
if not ssuper.is_c_hybrid():
procedures['property'][ssuper.name().lower()] = proc.run_dft_property
for ssuper in superfunc_list:
if ((not ssuper.is_c_hybrid()) and (not ssuper.is_c_lrc()) and (not ssuper.is_x_lrc())):
procedures['gradient'][ssuper.name().lower()] = proc.run_dft_gradient
# Integrate CFOUR with driver routines
for ssuper in interface_cfour.cfour_list():
procedures['energy'][ssuper.lower()] = interface_cfour.run_cfour
for ssuper in interface_cfour.cfour_gradient_list():
procedures['gradient'][ssuper.lower()] = interface_cfour.run_cfour
# dictionary to register pre- and post-compute hooks for driver routines
hooks = dict((k1, dict((k2, []) for k2 in ['pre', 'post'])) for k1 in ['energy', 'optimize', 'frequency'])
|
andysim/psi4
|
psi4/driver/procrouting/proc_table.py
|
Python
|
gpl-2.0
| 10,293
|
<?php
/**
* phpwcms content management system
*
* @author Oliver Georgi <og@phpwcms.org>
* @copyright Copyright (c) 2002-2019, Oliver Georgi
* @license http://opensource.org/licenses/GPL-2.0 GNU GPL-2
* @link http://www.phpwcms.org
*
**/
$BL['EN'] = 'English';
$BL['AR'] = 'عربي';
$BL['BG'] = 'Български';
$BL['BS'] = 'Bosanski';
$BL['CA'] = 'Català';
$BL['CZ'] = 'Česky (CZ)';
$BL['CS'] = 'Česky (CS)';
$BL['DA'] = 'Dansk';
$BL['DE'] = 'Deutsch';
$BL['ET'] = 'Eesti';
$BL['ES'] = 'Español';
$BL['FR'] = 'Français';
$BL['GR'] = 'Ελληνικά';
$BL['IT'] = 'Italiano';
$BL['LT'] = 'Lietuviu';
$BL['HU'] = 'Magyar';
$BL['NL'] = 'Nederlands';
$BL['NO'] = 'Norsk';
$BL['PL'] = 'Polski';
$BL['PT'] = 'Português';
$BL['RO'] = 'Română';
$BL['FI'] = 'Suomi';
$BL['SE'] = 'Svenska';
$BL['RU'] = 'Русском';
$BL['SK'] = 'Slovenčina';
$BL['SL'] = 'Slovenščina';
$BL['TR'] = 'Türkçe';
$BL['VN'] = 'Tiếng Việt';
|
marcus-at-localhorst/phpwcms
|
include/inc_lang/code.lang.inc.php
|
PHP
|
gpl-2.0
| 1,151
|
package se.agile.activities;
import java.util.LinkedList;
import se.agile.model.BranchNotification;
import se.agile.model.CommitNotification;
import se.agile.model.ConflictNotification;
import se.agile.model.NotificationListArrayAdapter;
import se.agile.model.Notification;
import se.agile.model.NotificationHandler;
import se.agile.model.TemporaryStorage;
import se.agile.princepolo.R;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
public class NotificationsFragment extends Fragment {
private String logTag;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
logTag = getResources().getString(R.string.logtag_main);
View rootView = inflater.inflate(R.layout.fragment_notification_list_view, container, false);
final ListView listview = (ListView) rootView.findViewById(R.id.listview);
LinkedList<Notification> list = TemporaryStorage.getNotifications();
if(list != null){
final NotificationListArrayAdapter adapter = new NotificationListArrayAdapter(getActivity(), list);
listview.setAdapter(adapter);
listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
Log.d(logTag, "pressed pos: " + position );
Notification not = adapter.getNotification(position);
if(not instanceof CommitNotification){
CommitNotification commitNot = (CommitNotification) not;
CommitFragment commitFragment = new CommitFragment();
commitFragment.setCommit(commitNot.getData());
if(!not.hasBeenViewed()){
not.setHasBeenViewed(true);
NotificationHandler.viewedNotification(commitNot);
}
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.addToBackStack("Notes");
transaction.replace(R.id.content_notification_holder, commitFragment);
transaction.commit();
}else if(not instanceof BranchNotification){
BranchNotification branchNot = (BranchNotification) not;
BranchFragment branchFragment = new BranchFragment();
branchFragment.setBranch(branchNot.getData());
if(!not.hasBeenViewed()){
not.setHasBeenViewed(true);
NotificationHandler.viewedNotification(branchNot);
}
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.addToBackStack("Notes");
transaction.replace(R.id.content_notification_holder, branchFragment);
transaction.commit();
}else if(not instanceof ConflictNotification){
ConflictNotification conflictNot = (ConflictNotification) not;
ConflictFragment conflictFragment = new ConflictFragment();
conflictFragment.setTuple(conflictNot.getData());
if(!not.hasBeenViewed()){
not.setHasBeenViewed(true);
NotificationHandler.viewedNotification(conflictNot);
}
FragmentManager fm = getFragmentManager();
FragmentTransaction transaction = fm.beginTransaction();
transaction.addToBackStack("Notes");
transaction.replace(R.id.content_notification_holder, conflictFragment);
transaction.commit();
}
}
});
}
return rootView;
}
}
|
Jake91/PrincePolo
|
src/se/agile/activities/NotificationsFragment.java
|
Java
|
gpl-2.0
| 4,276
|
/* $Id: newgrf_widget.h 23932 2012-02-12 10:32:41Z rubidium $ */
/*
* This file is part of OpenTTD.
* OpenTTD 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, version 2.
* OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file newgrf_widget.h Types related to the newgrf widgets. */
#ifndef WIDGETS_NEWGRF_WIDGET_H
#define WIDGETS_NEWGRF_WIDGET_H
#include "../newgrf_config.h"
#include "../textfile_type.h"
/** Widgets of the #NewGRFParametersWindow class. */
enum NewGRFParametersWidgets {
WID_NP_SHOW_NUMPAR, ///< #NWID_SELECTION to optionally display #WID_NP_NUMPAR.
WID_NP_NUMPAR_DEC, ///< Button to decrease number of parameters.
WID_NP_NUMPAR_INC, ///< Button to increase number of parameters.
WID_NP_NUMPAR, ///< Optional number of parameters.
WID_NP_NUMPAR_TEXT, ///< Text description.
WID_NP_BACKGROUND, ///< Panel to draw the settings on.
WID_NP_SCROLLBAR, ///< Scrollbar to scroll through all settings.
WID_NP_ACCEPT, ///< Accept button.
WID_NP_RESET, ///< Reset button.
WID_NP_SHOW_DESCRIPTION, ///< #NWID_SELECTION to optionally display parameter descriptions.
WID_NP_DESCRIPTION, ///< Multi-line description of a parameter.
};
/** Widgets of the #NewGRFWindow class. */
enum NewGRFStateWidgets {
WID_NS_PRESET_LIST, ///< Active NewGRF preset.
WID_NS_PRESET_SAVE, ///< Save list of active NewGRFs as presets.
WID_NS_PRESET_DELETE, ///< Delete active preset.
WID_NS_ADD, ///< Add NewGRF to active list.
WID_NS_REMOVE, ///< Remove NewGRF from active list.
WID_NS_MOVE_UP, ///< Move NewGRF up in active list.
WID_NS_MOVE_DOWN, ///< Move NewGRF down in active list.
WID_NS_UPGRADE, ///< Upgrade NewGRFs that have a newer version available.
WID_NS_FILTER, ///< Filter list of available NewGRFs.
WID_NS_FILE_LIST, ///< List window of active NewGRFs.
WID_NS_SCROLLBAR, ///< Scrollbar for active NewGRF list.
WID_NS_AVAIL_LIST, ///< List window of available NewGRFs.
WID_NS_SCROLL2BAR, ///< Scrollbar for available NewGRF list.
WID_NS_NEWGRF_INFO_TITLE, ///< Title for Info on selected NewGRF.
WID_NS_NEWGRF_INFO, ///< Panel for Info on selected NewGRF.
WID_NS_OPEN_URL, ///< Open URL of NewGRF.
WID_NS_NEWGRF_TEXTFILE, ///< Open NewGRF readme, changelog (+1) or license (+2).
WID_NS_SET_PARAMETERS = WID_NS_NEWGRF_TEXTFILE + TFT_END, ///< Open Parameters Window for selected NewGRF for editing parameters.
WID_NS_VIEW_PARAMETERS, ///< Open Parameters Window for selected NewGRF for viewing parameters.
WID_NS_TOGGLE_PALETTE, ///< Toggle Palette of selected, active NewGRF.
WID_NS_APPLY_CHANGES, ///< Apply changes to NewGRF config.
WID_NS_RESCAN_FILES, ///< Rescan files (available NewGRFs).
WID_NS_RESCAN_FILES2, ///< Rescan files (active NewGRFs).
WID_NS_CONTENT_DOWNLOAD, ///< Open content download (available NewGRFs).
WID_NS_CONTENT_DOWNLOAD2, ///< Open content download (active NewGRFs).
WID_NS_SHOW_REMOVE, ///< Select active list buttons (0 = normal, 1 = simple layout).
WID_NS_SHOW_APPLY, ///< Select display of the buttons below the 'details'.
};
/** Widgets of the #SavePresetWindow class. */
enum SavePresetWidgets {
WID_SVP_PRESET_LIST, ///< List with available preset names.
WID_SVP_SCROLLBAR, ///< Scrollbar for the list available preset names.
WID_SVP_EDITBOX, ///< Edit box for changing the preset name.
WID_SVP_CANCEL, ///< Button to cancel saving the preset.
WID_SVP_SAVE, ///< Button to save the preset.
};
/** Widgets of the #ScanProgressWindow class. */
enum ScanProgressWidgets {
WID_SP_PROGRESS_BAR, ///< Simple progress bar.
WID_SP_PROGRESS_TEXT, ///< Text explaining what is happening.
};
#endif /* WIDGETS_NEWGRF_WIDGET_H */
|
KeldorKatarn/OpenTTD_PatchPack
|
src/widgets/newgrf_widget.h
|
C
|
gpl-2.0
| 4,292
|
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
/*!
\class QmlJS::PersistentTrie::Trie
\brief The Trie class implements a trie that is
persistent (not on disk but in memory).
This means that several versions can coexist, as adding an element
is non-destructive, and as much as possible is shared.
The trie is only \e partially ordered. It preserves the order
of the inserted elements as much as possible.
This makes some operations a bit slower, but is considered
a feature.
This means the order in which you insert the elements matters.
An important use case for this is completions, and several
strategies are available.
Results order can be improved by using the matching strength.
All const operations are threadsafe, and copy is cheap (only a
QSharedPointer copy).
Assigning a shared pointer is not threadsafe, so updating the
head is not threadsafe, and should be done only on a local
instance (shared pointer used only from a single thread), or
protected with locks.
This is a two-level implementation, based on a fully functional
implementation (PersistentTrie::Trie), which could be private
but was left public because deemed useful.
Would gain from some memory optimization, or direct string implementation.
*/
#include "persistenttrie.h"
#include <QDebug>
#include <QMap>
#include <QString>
#include <QStringList>
#include <algorithm>
#include <utility>
namespace QmlJS
{
namespace PersistentTrie
{
TrieNode::TrieNode(const QString &pre, QList<TrieNode::Ptr> post) :
prefix(pre), postfixes(post) {}
TrieNode::TrieNode(const TrieNode &o) : prefix(o.prefix),
postfixes(o.postfixes) {}
TrieNode::Ptr TrieNode::create(const QString &pre, QList<TrieNode::Ptr> post)
{
return TrieNode::Ptr(new TrieNode(pre,post));
}
void TrieNode::complete(QStringList &res, const TrieNode::Ptr &trie,
const QString &value, const QString &base, LookupFlags flags)
{
// one could also modify this and make it return a TrieNode, instead of a QStringList
if (trie.isNull())
return;
QString::const_iterator i = trie->prefix.constBegin(), iEnd = trie->prefix.constEnd();
QString::const_iterator j = value.constBegin(), jEnd = value.constEnd();
while (i != iEnd && j != jEnd)
{
if (i->isSpace())
{
if (! j->isSpace() && (flags & SkipSpaces) == 0)
return;
while (j != jEnd && j->isSpace())
{
++j;
} ;
do
{
++i;
}
while (i != iEnd && i->isSpace());
}
else
{
if (*i != *j && ((flags & CaseInsensitive) == 0 || i->toLower() != j->toLower()))
{
if ((flags & SkipChars) != 0)
--j;
else
return;
}
++i;
++j;
}
}
QString base2 = base + trie->prefix;
if (j == jEnd)
{
if (trie->postfixes.isEmpty())
res.append(base2);
if (trie->postfixes.size() == 1)
{
complete(res, trie->postfixes[0],QString(), base2, flags);
return;
}
foreach (TrieNode::Ptr t, trie->postfixes)
{
if ((flags & Partial) != 0)
res.append(base2 + t->prefix);
else
complete(res, t, QString(), base2, flags);
}
return;
}
foreach (const TrieNode::Ptr v, trie->postfixes)
{
QString::const_iterator vi = v->prefix.constBegin(), vEnd = v->prefix.constEnd();
if (vi != vEnd && (*vi == *j || ((flags & CaseInsensitive) != 0
&& vi->toLower() == j->toLower()) || ((flags & SkipChars) != 0)))
complete(res, v, value.right(jEnd-j), base2, flags);
}
}
TrieNode::Ptr TrieNode::insertF(const TrieNode::Ptr &trie,
const QString &value)
{
if (trie.isNull())
{
if (value.isEmpty())
return trie;
return TrieNode::create(value);
}
typedef TrieNode T;
QString::const_iterator i = trie->prefix.constBegin(), iEnd = trie->prefix.constEnd();
QString::const_iterator j = value.constBegin(), jEnd = value.constEnd();
while (i != iEnd && j != jEnd)
{
if (i->isSpace())
{
if (! j->isSpace())
break;
do
{
++j;
}
while (j != jEnd && j->isSpace());
do
{
++i;
}
while (i != iEnd && i->isSpace());
}
else
{
if (*i != *j)
break;
++i;
++j;
}
}
if (i == iEnd)
{
if (j == jEnd)
return trie;
int tSize = trie->postfixes.size();
for (int i=0; i < tSize; ++i)
{
const T::Ptr &v=trie->postfixes[i];
QString::const_iterator vi = v->prefix.constBegin(), vEnd = v->prefix.constEnd();
if (vi != vEnd && *vi == *j)
{
T::Ptr res = insertF(v, value.right(jEnd-j));
if (res != v)
{
QList<T::Ptr> post = trie->postfixes;
post.replace(i, res);
return T::create(trie->prefix,post);
}
else
{
return trie;
}
}
}
QList<T::Ptr> post = trie->postfixes;
if (post.isEmpty())
post.append(T::create());
post.append(T::create(value.right(jEnd - j)));
return T::create(trie->prefix, post);
}
else
{
T::Ptr newTrie1 = T::create(trie->prefix.right(iEnd - i), trie->postfixes);
T::Ptr newTrie2 = T::create(value.right(jEnd - j));
return T::create(trie->prefix.left(i - trie->prefix.constBegin()),
QList<T::Ptr>() << newTrie1 << newTrie2);
}
}
bool TrieNode::contains(const TrieNode::Ptr &trie,
const QString &value, LookupFlags flags)
{
if (trie.isNull())
return false;
QString::const_iterator i = trie->prefix.constBegin(), iEnd = trie->prefix.constEnd();
QString::const_iterator j = value.constBegin(), jEnd = value.constEnd();
while (i != iEnd && j != jEnd)
{
if (i->isSpace())
{
if (! j->isSpace())
return false;
do
{
++j;
}
while (j != jEnd && j->isSpace());
do
{
++i;
}
while (i != iEnd && i->isSpace());
}
else
{
if (*i != *j && ((flags & CaseInsensitive) == 0 || i->toLower() != j->toLower()))
return false;
++i;
++j;
}
}
if (j == jEnd)
{
if ((flags & Partial) != 0)
return true;
if (i == iEnd)
{
foreach (const TrieNode::Ptr t, trie->postfixes)
if (t->prefix.isEmpty())
return true;
return trie->postfixes.isEmpty();
}
return false;
}
if (i != iEnd)
return false;
bool res = false;
foreach (const TrieNode::Ptr v, trie->postfixes)
{
QString::const_iterator vi = v->prefix.constBegin(), vEnd = v->prefix.constEnd();
if (vi != vEnd && (*vi == *j || ((flags & CaseInsensitive) != 0
&& vi->toLower() == j->toLower())))
res = res || contains(v, value.right(jEnd-j), flags);
}
return res;
}
namespace
{
class Appender
{
public:
Appender() {}
QStringList res;
void operator()(const QString &s)
{
res.append(s);
}
};
}
QStringList TrieNode::stringList(const TrieNode::Ptr &trie)
{
Appender a;
enumerateTrieNode<Appender>(trie, a, QString());
return a.res;
}
bool TrieNode::isSame(const TrieNode::Ptr &trie1, const TrieNode::Ptr &trie2)
{
if (trie1.data() == trie2.data())
return true;
if (trie1.isNull() || trie2.isNull())
return false; // assume never to generate non null empty tries
if (trie1->prefix != trie2->prefix)
return false; // assume no excess splitting
QList<TrieNode::Ptr> t1 = trie1->postfixes, t2 =trie2->postfixes;
int nEl = t1.size();
if (nEl != t2.size()) return false;
// different order = different trie
for (int i = 0; i < nEl; ++i)
{
if (!isSame(t1.value(i), t2.value(i)))
return false;
}
return true;
}
namespace
{
class ReplaceInTrie
{
public:
TrieNode::Ptr trie;
QHash<QString, QString> replacements;
ReplaceInTrie() { }
void operator()(QString s)
{
QHashIterator<QString, QString> i(replacements);
QString res = s;
while (i.hasNext())
{
i.next();
res.replace(i.key(), i.value());
}
trie = TrieNode::insertF(trie,res);
}
};
}
TrieNode::Ptr TrieNode::replaceF(const TrieNode::Ptr &trie, const QHash<QString, QString> &replacements)
{
// inefficient...
ReplaceInTrie rep;
rep.replacements = replacements;
enumerateTrieNode<ReplaceInTrie>(trie, rep, QString());
return rep.trie;
}
std::pair<TrieNode::Ptr,int> TrieNode::intersectF(
const TrieNode::Ptr &v1, const TrieNode::Ptr &v2, int index1)
{
typedef TrieNode::Ptr P;
typedef QMap<QString,int>::const_iterator MapIterator;
if (v1.isNull() || v2.isNull())
return std::make_pair(P(0), ((v1.isNull()) ? 1 : 0) | ((v2.isNull()) ? 2 : 0));
QString::const_iterator i = v1->prefix.constBegin()+index1, iEnd = v1->prefix.constEnd();
QString::const_iterator j = v2->prefix.constBegin(), jEnd = v2->prefix.constEnd();
while (i != iEnd && j != jEnd)
{
if (i->isSpace())
{
if (! j->isSpace())
break;
do
{
++j;
}
while (j != jEnd && j->isSpace());
do
{
++i;
}
while (i != iEnd && i->isSpace());
}
else
{
if (*i != *j)
break;
++i;
++j;
}
}
if (i == iEnd)
{
if (j == jEnd)
{
if (v1->postfixes.isEmpty() || v2->postfixes.isEmpty())
{
if (v1->postfixes.isEmpty() && v2->postfixes.isEmpty())
return std::make_pair(v1, 3);
foreach (P t1, v1->postfixes)
if (t1->prefix.isEmpty())
{
if (index1 == 0)
return std::make_pair(v2, 2);
else
return std::make_pair(TrieNode::create(
v1->prefix.left(index1).append(v2->prefix), v2->postfixes),0);
}
foreach (P t2, v2->postfixes)
if (t2->prefix.isEmpty())
return std::make_pair(v1,1);
return std::make_pair(P(0), 0);
}
QMap<QString,int> p1, p2;
QList<P> p3;
int ii = 0;
foreach (P t1, v1->postfixes)
p1[t1->prefix] = ii++;
ii = 0;
foreach (P t2, v2->postfixes)
p2[t2->prefix] = ii++;
MapIterator p1Ptr = p1.constBegin(), p2Ptr = p2.constBegin(),
p1End = p1.constEnd(), p2End = p2.constEnd();
int sameV1V2 = 3;
while (p1Ptr != p1End && p2Ptr != p2End)
{
if (p1Ptr.key().isEmpty())
{
if (p2Ptr.key().isEmpty())
{
if (sameV1V2 == 0)
p3.append(v1->postfixes.at(p1Ptr.value()));
++p1Ptr;
++p2Ptr;
}
else
{
if (sameV1V2 == 1)
for (MapIterator p1I = p1.constBegin(); p1I != p1Ptr; ++p1I)
p3.append(v1->postfixes.at(p1I.value()));
++p1Ptr;
sameV1V2 &= 2;
}
}
else if (p2Ptr.key().isEmpty())
{
if (sameV1V2 == 2)
for (MapIterator p2I = p2.constBegin(); p2I != p2Ptr; ++p2I)
p3.append(v2->postfixes.at(p2I.value()));
++p2Ptr;
sameV1V2 &= 1;
}
else
{
QChar c1 = p1Ptr.key().at(0);
QChar c2 = p2Ptr.key().at(0);
if (c1 < c2)
{
if (sameV1V2 == 1)
for (MapIterator p1I = p1.constBegin(); p1I != p1Ptr; ++p1I)
p3.append(v1->postfixes.at(p1I.value()));
++p1Ptr;
sameV1V2 &= 2;
}
else if (c1 > c2)
{
if (sameV1V2 == 2)
for (MapIterator p2I = p2.constBegin(); p2I != p2Ptr; ++p2I)
p3.append(v2->postfixes.at(p2I. value()));
++p2Ptr;
sameV1V2 &= 1;
}
else
{
std::pair<P,int> res = intersectF(v1->postfixes.at(p1Ptr.value()),
v2->postfixes.at(p2Ptr.value()));
if (sameV1V2 !=0 && (sameV1V2 & res.second) == 0)
{
if ((sameV1V2 & 1) == 1)
for (MapIterator p1I = p1.constBegin(); p1I != p1Ptr; ++p1I)
p3.append(v1->postfixes.at(p1I.value()));
if (sameV1V2 == 2)
for (MapIterator p2I = p2.constBegin(); p2I != p2Ptr; ++p2I)
p3.append(v2->postfixes.at(p2I.value()));
}
sameV1V2 &= res.second;
if (sameV1V2 == 0 && !res.first.isNull())
p3.append(res.first);
++p1Ptr;
++p2Ptr;
}
}
}
if (p1Ptr != p1End)
{
if (sameV1V2 == 1)
for (MapIterator p1I = p1.constBegin(); p1I != p1Ptr; ++p1I)
p3.append(v1->postfixes.at(p1I.value()));
sameV1V2 &= 2;
}
else if (p2Ptr != p2End)
{
if (sameV1V2 == 2)
{
for (MapIterator p2I = p2.constBegin(); p2I != p2Ptr; ++p2I)
p3.append(v2->postfixes.at(p2I. value()));
}
sameV1V2 &= 1;
}
switch (sameV1V2)
{
case 0:
if (p3.isEmpty())
return std::make_pair(P(0),0);
else
return std::make_pair(TrieNode::create(v1->prefix,p3),0);
case 2:
if (index1 == 0)
return std::make_pair(v2,2);
else
return std::make_pair(TrieNode::create(
v1->prefix.left(index1).append(v2->prefix), v2->postfixes), 0);
default:
return std::make_pair(v1,sameV1V2);
}
}
// i == iEnd && j != jEnd
foreach (const P &t1, v1->postfixes)
if ((!t1->prefix.isEmpty()) && t1->prefix.at(0) == *j)
{
std::pair<P,int> res = intersectF(v2,t1,j-v2->prefix.constBegin());
if (index1 == 0)
return std::make_pair(res.first, (((res.second & 1)==1) ? 2 : 0));
else
return std::make_pair(TrieNode::create(
v1->prefix.left(index1).append(res.first->prefix),
res.first->postfixes), 0);
}
return std::make_pair(P(0), 0);
}
else
{
// i != iEnd && j == jEnd
foreach (P t2, v2->postfixes)
if (!t2->prefix.isEmpty() && t2->prefix.at(0) == *i)
{
std::pair<P,int> res = intersectF(v1,t2,i-v1->prefix.constBegin());
return std::make_pair(res.first, (res.second & 1));
}
return std::make_pair(P(0), 0);
}
}
namespace
{
class InplaceTrie
{
public:
TrieNode::Ptr trie;
void operator()(QString s)
{
trie = TrieNode::insertF(trie,s);
}
};
}
std::pair<TrieNode::Ptr,int> TrieNode::mergeF(
const TrieNode::Ptr &v1, const TrieNode::Ptr &v2)
{
//could be much more efficient if implemented directly on the trie like intersectF
InplaceTrie t;
t.trie = v1;
enumerateTrieNode<InplaceTrie>(v2, t, QString());
return std::make_pair(t.trie, ((t.trie == v1) ? 1 : 0));
}
QDebug &TrieNode::printStrings(QDebug &dbg, const TrieNode::Ptr &trie)
{
if (trie.isNull())
return dbg << "Trie{*NULL*}";
dbg<<"Trie{ contents:[";
bool first = true;
foreach (const QString &s, stringList(trie))
{
if (!first)
dbg << ",";
else
first = false;
dbg << s;
}
dbg << "]}";
return dbg;
}
QDebug &TrieNode::describe(QDebug &dbg, const TrieNode::Ptr &trie,
int indent = 0)
{
dbg.space();
dbg.nospace();
if (trie.isNull())
{
dbg << "NULL";
return dbg;
}
dbg << trie->prefix;
int newIndent = indent + trie->prefix.size() + 3;
bool newLine = false;
foreach (TrieNode::Ptr sub, trie->postfixes)
{
if (newLine)
{
dbg << "\n";
for (int i=0; i < newIndent; ++i)
dbg << " ";
}
else
{
newLine = true;
}
describe(dbg, sub, newIndent);
}
return dbg;
}
QDebug &operator<<(QDebug &dbg, const TrieNode::Ptr &trie)
{
dbg.nospace()<<"Trie{\n";
TrieNode::describe(dbg,trie,0);
dbg << "}";
return dbg.space();
}
QDebug &operator<<(QDebug &dbg, const Trie &trie)
{
dbg.nospace()<<"Trie{\n";
TrieNode::describe(dbg,trie.trie,0);
dbg << "}";
return dbg.space();
}
Trie::Trie() {}
Trie::Trie(const TrieNode::Ptr &trie) : trie(trie) {}
Trie::Trie(const Trie &o) : trie(o.trie) {}
QStringList Trie::complete(const QString &root, const QString &base,
LookupFlags flags) const
{
QStringList res;
TrieNode::complete(res, trie, root, base, flags);
return res;
}
bool Trie::contains(const QString &value, LookupFlags flags) const
{
return TrieNode::contains(trie, value, flags);
}
QStringList Trie::stringList() const
{
return TrieNode::stringList(trie);
}
/*!
Inserts into the current trie.
Non threadsafe. Only use this function on an instance that is used only
in a single thread, or that is protected by locks.
*/
void Trie::insert(const QString &value)
{
trie = TrieNode::insertF(trie, value);
}
/*!
Intersects into the current trie.
Non threadsafe. Only use this function on an instance that is used only
in a single thread, or that is protected by locks.
*/
void Trie::intersect(const Trie &v)
{
trie = TrieNode::intersectF(trie, v.trie).first;
}
/*!
Merges the given trie into the current one.
Non threadsafe. Only use this function on an instance that is used only
in a single thread, or that is protected by locks.
*/
void Trie::merge(const Trie &v)
{
trie = TrieNode::mergeF(trie, v.trie).first;
}
void Trie::replace(const QHash<QString, QString> &replacements)
{
trie = TrieNode::replaceF(trie, replacements);
}
bool Trie::isEmpty() const
{
return trie.isNull(); // assuming to never generate an empty non null trie
}
bool Trie::operator==(const Trie &o)
{
return TrieNode::isSame(trie,o.trie);
}
bool Trie::operator!=(const Trie &o)
{
return !TrieNode::isSame(trie,o.trie);
}
Trie Trie::insertF(const QString &value) const
{
return Trie(TrieNode::insertF(trie, value));
}
Trie Trie::intersectF(const Trie &v) const
{
return Trie(TrieNode::intersectF(trie, v.trie).first);
}
Trie Trie::mergeF(const Trie &v) const
{
return Trie(TrieNode::mergeF(trie, v.trie).first);
}
Trie Trie::replaceF(const QHash<QString, QString> &replacements) const
{
return Trie(TrieNode::replaceF(trie, replacements));
}
/*!
Returns a number defining how well \a searchStr matches \a str.
Quite simplistic, looks only at the first match, and prefers contiguous
matches, or matches to capitalized or separated words.
Match to the last character is also preferred.
*/
int matchStrength(const QString &searchStr, const QString &str)
{
QString::const_iterator i = searchStr.constBegin(), iEnd = searchStr.constEnd(),
j = str.constBegin(), jEnd = str.constEnd();
bool lastWasNotUpper=true, lastWasSpacer=true, lastWasMatch = false, didJump = false;
int res = 0;
while (i != iEnd && j != jEnd)
{
bool thisIsUpper = (*j).isUpper();
bool thisIsLetterOrNumber = (*j).isLetterOrNumber();
if ((*i).toLower() == (*j).toLower())
{
if (lastWasMatch || (lastWasNotUpper && thisIsUpper)
|| (thisIsUpper && (*i).isUpper())
|| (lastWasSpacer && thisIsLetterOrNumber))
++res;
lastWasMatch = true;
++i;
}
else
{
didJump = true;
lastWasMatch = false;
}
++j;
lastWasNotUpper = !thisIsUpper;
lastWasSpacer = !thisIsLetterOrNumber;
}
if (i != iEnd)
return i - iEnd;
if (j == jEnd)
++res;
if (!didJump)
res+=2;
return res;
}
namespace
{
class CompareMatchStrength
{
QString searchStr;
public:
CompareMatchStrength(const QString& searchStr) : searchStr(searchStr) { }
bool operator()(const QString &v1, const QString &v2)
{
return matchStrength(searchStr,v1) > matchStrength(searchStr,v2);
}
};
}
/*!
Returns a number defining the matching strength of \a res to \a searchStr.
*/
QStringList matchStrengthSort(const QString &searchStr, QStringList &res)
{
CompareMatchStrength compare(searchStr);
std::stable_sort(res.begin(), res.end(), compare);
return res;
}
} // end namespace PersistentTrie
} // end namespace QmlJS
|
tonytheodore/tora
|
src/parsing/persistenttrie.cpp
|
C++
|
gpl-2.0
| 30,407
|
angular.module('starter').controller('historyAllMeasurementsCtrl', ["$scope", "$state", "$stateParams", "$rootScope",
"$timeout", "$ionicActionSheet", "qmService", "qmLogService", function($scope, $state, $stateParams, $rootScope, $timeout,
$ionicActionSheet, qmService, qmLogService){
$scope.controller_name = "historyAllMeasurementsCtrl";
$scope.state = {
helpCardTitle: "Past Measurements",
history: [],
limit: 50,
loadingText: "Fetching measurements...",
moreDataCanBeLoaded: true,
noHistory: false,
showLocationToggle: false,
sort: "-startTime",
title: "History",
units: [],
};
$scope.$on('$ionicView.beforeEnter', function(e){
if (document.title !== $scope.state.title) {document.title = $scope.state.title;}
if(!$scope.helpCard || $scope.helpCard.title !== "Past Measurements"){
$scope.helpCard = {
title: "Past Measurements",
bodyText: "Edit or add notes by tapping on any measurement below. Drag down to refresh and get your most recent measurements.",
icon: "ion-calendar"
};
}
if($stateParams.refresh){$scope.state.history = [];}
qm.measurements.addLocalMeasurements($scope.state.history, getRequestParams(), function(combined){
$scope.safeApply(function () {
$scope.state.history = combined;
})
})
$scope.state.moreDataCanBeLoaded = true;
// Need to use rootScope here for some reason
qmService.rootScope.setProperty('hideHistoryPageInstructionsCard',
qm.storage.getItem('hideHistoryPageInstructionsCard'));
});
$scope.$on('$ionicView.enter', function(e){
qmService.navBar.showNavigationMenuIfHideUrlParamNotSet();
var cat = getVariableCategoryName();
if(cat && cat !== 'Anything'){
document.title = $scope.state.title = cat + ' History';
$scope.state.showLocationToggle = cat === "Location";
}
if(cat){setupVariableCategoryActionSheet();}
getScopedVariableObject();
if(getVariableName()){$scope.state.title = getVariableName() + ' History';}
updateNavigationMenuButton();
if(!$scope.state.history || !$scope.state.history.length){ // Otherwise it keeps add more measurements whenever we edit one
$scope.getHistory();
}
});
function updateNavigationMenuButton(){
$timeout(function(){
qmService.rootScope.setShowActionSheetMenu(function(){
// Show the action sheet
var hideSheet = $ionicActionSheet.show({
buttons: [
qmService.actionSheets.actionSheetButtons.refresh,
qmService.actionSheets.actionSheetButtons.settings,
qmService.actionSheets.actionSheetButtons.sortDescendingValue,
qmService.actionSheets.actionSheetButtons.sortAscendingValue,
qmService.actionSheets.actionSheetButtons.sortDescendingTime,
qmService.actionSheets.actionSheetButtons.sortAscendingTime
],
cancelText: '<i class="icon ion-ios-close"></i>Cancel',
cancel: function(){
qmLogService.debug('CANCELLED', null);
},
buttonClicked: function(index, button){
if(index === 0){
$scope.refreshHistory();
}
if(index === 1){
qmService.goToState(qm.stateNames.settings);
}
if(button.text === qmService.actionSheets.actionSheetButtons.sortDescendingValue.text){
changeSortAndGetHistory('-value');
}
if(button.text === qmService.actionSheets.actionSheetButtons.sortAscendingValue.text){
changeSortAndGetHistory('value');
}
if(button.text === qmService.actionSheets.actionSheetButtons.sortDescendingTime.text){
changeSortAndGetHistory('-startTime');
}
if(button.text === qmService.actionSheets.actionSheetButtons.sortAscendingTime.text){
changeSortAndGetHistory('startTime');
}
return true;
}
});
});
}, 1);
}
function changeSortAndGetHistory(sort){
$scope.state.history = qm.arrayHelper.sortByProperty($scope.state.history, sort)
$scope.state.sort = sort;
$scope.getHistory();
}
function hideLoader(){
//Stop the ion-refresher from spinning
$scope.$broadcast('scroll.refreshComplete');
$scope.state.loading = false;
qmService.hideLoader();
$scope.$broadcast('scroll.infiniteScrollComplete');
}
function getScopedVariableObject(){
if($scope.state.variableObject && $scope.state.variableObject.name === getVariableName()){
return $scope.state.variableObject;
}
if($stateParams.variableObject){
return $scope.state.variableObject = $stateParams.variableObject;
}
return null;
}
function getVariableName(){
if($stateParams.variableName){
return $stateParams.variableName;
}
if($stateParams.variableObject){
return $stateParams.variableObject.name;
}
if(qm.urlHelper.getParam('variableName')){
return qm.urlHelper.getParam('variableName');
}
qmLog.info("Could not get variableName")
}
function getVariableCategoryName(){
return qm.variableCategoryHelper.getVariableCategoryNameFromStateParamsOrUrl($stateParams);
}
function getConnectorName(){
if($stateParams.connectorName){
return $stateParams.connectorName;
}
if(qm.urlHelper.getParam('connectorName')){
return qm.urlHelper.getParam('connectorName');
}
if(getConnectorId()){
var connectorId = getConnectorId();
var connector = qm.connectorHelper.getConnectorById(connectorId);
if(!connector){
qm.qmLog.error(
"Cannot filter by connector id because we could not find a matching connector locally");
return null;
}
return connector.name;
}
qmLog.debug("Could not get connectorName")
}
function getConnectorId(){
if($stateParams.connectorId){
return $stateParams.connectorId;
}
if(qm.urlHelper.getParam('connector_id')){
return qm.urlHelper.getParam('connector_id');
}
qmLog.debug("Could not get connector_id")
}
$scope.editMeasurement = function(measurement){
//measurement.hide = true; // Hiding when we go to edit so we don't see the old value when we come back
qmService.goToState('app.measurementAdd', {
measurement: measurement, fromState: $state.current.name,
fromUrl: window.location.href
});
};
$scope.refreshHistory = function(){
$scope.state.history = [];
$scope.getHistory();
};
function getRequestParams(params){
params = params || {};
if(getVariableName()){
params.variableName = getVariableName();
}
if(getConnectorName()){
params.connectorName = getConnectorName();
}
if(getVariableCategoryName()){
params.variableCategoryName = getVariableCategoryName();
}
params.sort = $scope.state.sort;
return params;
}
$scope.getHistory = function(){
if($scope.state.loading){
return qmLog.info("Already getting measurements!");
}
if(!$scope.state.moreDataCanBeLoaded){
hideLoader();
return qmLog.info("No more measurements!");
}
$scope.state.loading = true;
if(!$scope.state.history){
$scope.state.history = [];
}
var params = {
offset: $scope.state.history.length,
limit: $scope.state.limit,
sort: $scope.state.sort,
doNotProcess: true
};
params = getRequestParams(params);
if(getVariableName()){
if(!$scope.state.variableObject){
qmService.searchUserVariablesDeferred('*', {variableName: getVariableName()}).then(function(variables){
$scope.state.variableObject = variables[0];
}, function(error){
qmLogService.error(error);
});
}
}
function successHandler(measurements){
if(!measurements || measurements.length < params.limit){
$scope.state.moreDataCanBeLoaded = false;
}
if(measurements.length < $scope.state.limit){
$scope.state.noHistory = measurements.length === 0;
}
qm.measurements.addLocalMeasurements(measurements, getRequestParams(),function (combined) {
$scope.state.history = combined;
hideLoader();
})
}
function errorHandler(error){
qmLogService.error("History update error: ", error);
$scope.state.noHistory = true;
hideLoader();
}
//qmService.showBasicLoader();
qm.measurements.getMeasurementsFromApi(params, successHandler, errorHandler);
};
function setupVariableCategoryActionSheet(){
qmService.rootScope.setShowActionSheetMenu(function(){
var hideSheet = $ionicActionSheet.show({
buttons: [
//{ text: '<i class="icon ion-ios-star"></i>Add to Favorites'},
{text: '<i class="icon ion-happy-outline"></i>Emotions'},
{text: '<i class="icon ion-ios-nutrition-outline"></i>Foods'},
{text: '<i class="icon ion-sad-outline"></i>Symptoms'},
{text: '<i class="icon ion-ios-medkit-outline"></i>Treatments'},
{text: '<i class="icon ion-ios-body-outline"></i>Physical Activity'},
{text: '<i class="icon ion-ios-pulse"></i>Vital Signs'},
{text: '<i class="icon ion-ios-location-outline"></i>Locations'}
],
cancelText: '<i class="icon ion-ios-close"></i>Cancel',
cancel: function(){
qmLogService.debug('CANCELLED', null);
},
buttonClicked: function(index, button){
if(index === 0){
qmService.goToState('app.historyAll', {variableCategoryName: 'Emotions'});
}
if(index === 1){
qmService.goToState('app.historyAll', {variableCategoryName: 'Foods'});
}
if(index === 2){
qmService.goToState('app.historyAll', {variableCategoryName: 'Symptoms'});
}
if(index === 3){
qmService.goToState('app.historyAll', {variableCategoryName: 'Treatments'});
}
if(index === 4){
qmService.goToState('app.historyAll', {variableCategoryName: 'Physical Activity'});
}
if(index === 5){
qmService.goToState('app.historyAll', {variableCategoryName: 'Vital Signs'});
}
if(index === 6){
qmService.goToState('app.historyAll', {variableCategoryName: 'Locations'});
}
return true;
},
destructiveButtonClicked: function(){
}
});
$timeout(function(){
hideSheet();
}, 20000);
});
}
$scope.deleteMeasurement = function(measurement){
measurement.hide = true;
qmService.deleteMeasurementFromServer(measurement);
};
qmService.navBar.setFilterBarSearchIcon(false);
$scope.showActionSheetForMeasurement = function(measurement){
$scope.state.measurement = measurement;
var variableObject = JSON.parse(JSON.stringify(measurement));
variableObject.variableId = measurement.variableId;
variableObject.name = measurement.variableName;
var buttons = [
{text: '<i class="icon ion-edit"></i>Edit Measurement'},
qmService.actionSheets.actionSheetButtons.reminderAdd,
qmService.actionSheets.actionSheetButtons.charts,
qmService.actionSheets.actionSheetButtons.historyAllVariable,
qmService.actionSheets.actionSheetButtons.variableSettings,
qmService.actionSheets.actionSheetButtons.relationships
];
if(measurement.url){
buttons.push(qmService.actionSheets.actionSheetButtons.openUrl);
}
var hideSheet = $ionicActionSheet.show({
buttons: buttons,
destructiveText: '<i class="icon ion-trash-a"></i>Delete Measurement',
cancelText: '<i class="icon ion-ios-close"></i>Cancel',
cancel: function(){
qmLogService.debug(null, $state.current.name + ': ' + 'CANCELLED', null);
},
buttonClicked: function(index, button){
qmLogService.debug(null, $state.current.name + ': ' + 'BUTTON CLICKED', null, index);
if(index === 0){
$scope.editMeasurement($scope.state.measurement);
}
if(index === 1){
qmService.goToState('app.reminderAdd', {variableObject: variableObject});
}
if(index === 2){
qmService.goToState('app.charts', {variableObject: variableObject});
}
if(index === 3){
qmService.goToState('app.historyAllVariable', {variableObject: variableObject});
}
if(index === 4){
qmService.goToVariableSettingsByName($scope.state.measurement.variableName);
}
if(index === 5){
qmService.showBlackRingLoader();
qmService.goToCorrelationsListForVariable($scope.state.measurement.variableName);
}
if(index === 6){
qm.urlHelper.openUrlInNewTab(measurement.url);
}
return true;
},
destructiveButtonClicked: function(){
$scope.deleteMeasurement(measurement);
return true;
}
});
$timeout(function(){
hideSheet();
}, 20000);
};
}]);
|
Abolitionist-Project/QuantiModo-Ionic-Template-App
|
src/js/controllers/historyAllMeasurementsCtrl.js
|
JavaScript
|
gpl-2.0
| 16,677
|
#include "GUITestBase.h"
namespace HI {
GUITestBase::~GUITestBase() {
qDeleteAll(tests);
}
bool GUITestBase::registerTest(GUITest* test) {
Q_ASSERT(test != nullptr && !test->name.isEmpty());
if (hasTest(test->name)) {
return false;
}
tests.insert(test->getFullName(), test);
return true;
}
GUITest* GUITestBase::getTest(const QString& fullTestName) const {
return tests.value(fullTestName);
}
GUITest* GUITestBase::takeTest(const QString& fullTestName) {
return tests.take(fullTestName);
}
bool GUITestBase::hasTest(const QString& fullTestName) const {
return tests.contains(fullTestName);
}
GUITest* GUITestBase::getTest(const QString& suiteName, const QString& testName) const {
return getTest(GUITest::getFullTestName(suiteName, testName));
}
GUITest* GUITestBase::takeTest(const QString& suiteName, const QString& testName) {
return takeTest(GUITest::getFullTestName(suiteName, testName));
}
QList<GUITest*> GUITestBase::getTests() const {
return tests.values();
}
QList<GUITest*> GUITestBase::takeTests() {
QList<GUITest*> testList = getTests();
tests.clear();
return testList;
}
} // namespace HI
|
ugeneunipro/ugene
|
src/libs_3rdparty/QSpec/src/core/GUITestBase.cpp
|
C++
|
gpl-2.0
| 1,183
|
/*
* linux/arch/arm/kernel/smp.c
*
* Copyright (C) 2002 ARM Limited, All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/cache.h>
#include <linux/profile.h>
#include <linux/errno.h>
#include <linux/ftrace.h>
#include <linux/mm.h>
#include <linux/err.h>
#include <linux/cpu.h>
#include <linux/smp.h>
#include <linux/seq_file.h>
#include <linux/irq.h>
#include <linux/percpu.h>
#include <linux/clockchips.h>
#include <linux/completion.h>
#include <asm/atomic.h>
#include <asm/cacheflush.h>
#include <asm/cpu.h>
#include <asm/cputype.h>
#include <asm/mmu_context.h>
#include <asm/pgtable.h>
#include <asm/pgalloc.h>
#include <asm/processor.h>
#include <asm/sections.h>
#include <asm/tlbflush.h>
#include <asm/ptrace.h>
#include <asm/localtimer.h>
#include <mach/sec_debug.h>
/*
* as from 2.5, kernels no longer have an init_tasks structure
* so we need some other way of telling a new secondary core
* where to place its SVC stack
*/
struct secondary_data secondary_data;
enum ipi_msg_type {
IPI_TIMER = 2,
IPI_RESCHEDULE,
IPI_CALL_FUNC,
IPI_CALL_FUNC_SINGLE,
IPI_CPU_STOP,
IPI_CPU_BACKTRACE,
};
int __cpuinit __cpu_up(unsigned int cpu)
{
struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
struct task_struct *idle = ci->idle;
pgd_t *pgd;
int ret;
/*
* Spawn a new process manually, if not already done.
* Grab a pointer to its task struct so we can mess with it
*/
if (!idle) {
idle = fork_idle(cpu);
if (IS_ERR(idle)) {
printk(KERN_ERR "CPU%u: fork() failed\n", cpu);
return PTR_ERR(idle);
}
ci->idle = idle;
} else {
/*
* Since this idle thread is being re-used, call
* init_idle() to reinitialize the thread structure.
*/
init_idle(idle, cpu);
}
/*
* Allocate initial page tables to allow the new CPU to
* enable the MMU safely. This essentially means a set
* of our "standard" page tables, with the addition of
* a 1:1 mapping for the physical address of the kernel.
*/
pgd = pgd_alloc(&init_mm);
if (!pgd)
return -ENOMEM;
if (PHYS_OFFSET != PAGE_OFFSET) {
#ifndef CONFIG_HOTPLUG_CPU
identity_mapping_add(pgd, __pa(__init_begin), __pa(__init_end));
#endif
identity_mapping_add(pgd, __pa(_stext), __pa(_etext));
identity_mapping_add(pgd, __pa(_sdata), __pa(_edata));
}
/*
* We need to tell the secondary core where to find
* its stack and the page tables.
*/
secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
secondary_data.pgdir = virt_to_phys(pgd);
secondary_data.swapper_pg_dir = virt_to_phys(swapper_pg_dir);
__cpuc_flush_dcache_area(&secondary_data, sizeof(secondary_data));
outer_clean_range(__pa(&secondary_data), __pa(&secondary_data + 1));
/*
* Now bring the CPU into our world.
*/
ret = boot_secondary(cpu, idle);
if (ret == 0) {
unsigned long timeout;
/*
* CPU was successfully started, wait for it
* to come online or time out.
*/
timeout = jiffies + HZ;
while (time_before(jiffies, timeout)) {
if (cpu_online(cpu))
break;
udelay(10);
barrier();
}
if (!cpu_online(cpu)) {
pr_crit("CPU%u: failed to come online\n", cpu);
ret = -EIO;
}
} else {
pr_err("CPU%u: failed to boot: %d\n", cpu, ret);
}
secondary_data.stack = NULL;
secondary_data.pgdir = 0;
if (PHYS_OFFSET != PAGE_OFFSET) {
#ifndef CONFIG_HOTPLUG_CPU
identity_mapping_del(pgd, __pa(__init_begin), __pa(__init_end));
#endif
identity_mapping_del(pgd, __pa(_stext), __pa(_etext));
identity_mapping_del(pgd, __pa(_sdata), __pa(_edata));
}
pgd_free(&init_mm, pgd);
return ret;
}
#ifdef CONFIG_HOTPLUG_CPU
static void percpu_timer_stop(void);
/*
* __cpu_disable runs on the processor to be shutdown.
*/
int __cpu_disable(void)
{
unsigned int cpu = smp_processor_id();
struct task_struct *p;
int ret;
ret = platform_cpu_disable(cpu);
if (ret)
return ret;
/*
* Take this CPU offline. Once we clear this, we can't return,
* and we must not schedule until we're ready to give up the cpu.
*/
set_cpu_online(cpu, false);
/*
* OK - migrate IRQs away from this CPU
*/
migrate_irqs();
/*
* Stop the local timer for this CPU.
*/
percpu_timer_stop();
/*
* Flush user cache and TLB mappings, and then remove this CPU
* from the vm mask set of all processes.
*/
flush_cache_all();
local_flush_tlb_all();
read_lock(&tasklist_lock);
for_each_process(p) {
if (p->mm)
cpumask_clear_cpu(cpu, mm_cpumask(p->mm));
}
read_unlock(&tasklist_lock);
return 0;
}
static DECLARE_COMPLETION(cpu_died);
/*
* called on the thread which is asking for a CPU to be shutdown -
* waits until shutdown has completed, or it is timed out.
*/
void __cpu_die(unsigned int cpu)
{
if (!wait_for_completion_timeout(&cpu_died, msecs_to_jiffies(5000))) {
pr_err("CPU%u: cpu didn't die\n", cpu);
return;
}
printk(KERN_NOTICE "CPU%u: shutdown\n", cpu);
if (!platform_cpu_kill(cpu))
printk("CPU%u: unable to kill\n", cpu);
}
/*
* Called from the idle thread for the CPU which has been shutdown.
*
* Note that we disable IRQs here, but do not re-enable them
* before returning to the caller. This is also the behaviour
* of the other hotplug-cpu capable cores, so presumably coming
* out of idle fixes this.
*/
void __ref cpu_die(void)
{
unsigned int cpu = smp_processor_id();
idle_task_exit();
local_irq_disable();
mb();
/* Tell __cpu_die() that this CPU is now safe to dispose of */
complete(&cpu_died);
/*
* actual CPU shutdown procedure is at least platform (if not
* CPU) specific.
*/
platform_cpu_die(cpu);
/*
* Do not return to the idle loop - jump back to the secondary
* cpu initialisation. There's some initialisation which needs
* to be repeated to undo the effects of taking the CPU offline.
*/
__asm__("mov sp, %0\n"
" mov fp, #0\n"
" b secondary_start_kernel"
:
: "r" (task_stack_page(current) + THREAD_SIZE - 8));
}
#endif /* CONFIG_HOTPLUG_CPU */
/*
* Called by both boot and secondaries to move global data into
* per-processor storage.
*/
static void __cpuinit smp_store_cpu_info(unsigned int cpuid)
{
struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpuid);
cpu_info->loops_per_jiffy = loops_per_jiffy;
}
/*
* Skip the secondary calibration on architectures sharing clock
* with primary cpu. Archs can use ARCH_SKIP_SECONDARY_CALIBRATE
* for this.
*/
static inline int skip_secondary_calibrate(void)
{
#ifdef CONFIG_ARCH_SKIP_SECONDARY_CALIBRATE
return 0;
#else
return -ENXIO;
#endif
}
/*
* This is the secondary CPU boot entry. We're using this CPUs
* idle thread stack, but a set of temporary page tables.
*/
asmlinkage void __cpuinit secondary_start_kernel(void)
{
struct mm_struct *mm = &init_mm;
unsigned int cpu;
/*
* The identity mapping is uncached (strongly ordered), so
* switch away from it before attempting any exclusive accesses.
*/
cpu_switch_mm(mm->pgd, mm);
enter_lazy_tlb(mm, current);
local_flush_tlb_all();
/*
* All kernel threads share the same mm context; grab a
* reference and switch to it.
*/
cpu = smp_processor_id();
atomic_inc(&mm->mm_count);
current->active_mm = mm;
cpumask_set_cpu(cpu, mm_cpumask(mm));
printk("CPU%u: Booted secondary processor\n", cpu);
printk("CPU%u: Booted secondary processor\n", cpu);
cpu_init();
preempt_disable();
trace_hardirqs_off();
/*
* Give the platform a chance to do its own initialisation.
*/
platform_secondary_init(cpu);
notify_cpu_starting(cpu);
if (skip_secondary_calibrate())
calibrate_delay();
smp_store_cpu_info(cpu);
/*
* OK, now it's safe to let the boot CPU continue. Wait for
* the CPU migration code to notice that the CPU is online
* before we continue.
*/
set_cpu_online(cpu, true);
/*
* Setup the percpu timer for this CPU.
*/
percpu_timer_setup();
local_irq_enable();
local_fiq_enable();
/*
* OK, it's off to the idle thread for us
*/
cpu_idle();
}
void __init smp_cpus_done(unsigned int max_cpus)
{
int cpu;
unsigned long bogosum = 0;
for_each_online_cpu(cpu)
bogosum += per_cpu(cpu_data, cpu).loops_per_jiffy;
printk(KERN_INFO "SMP: Total of %d processors activated "
"(%lu.%02lu BogoMIPS).\n",
num_online_cpus(),
bogosum / (500000/HZ),
(bogosum / (5000/HZ)) % 100);
}
void __init smp_prepare_boot_cpu(void)
{
unsigned int cpu = smp_processor_id();
per_cpu(cpu_data, cpu).idle = current;
}
void __init smp_prepare_cpus(unsigned int max_cpus)
{
unsigned int ncores = num_possible_cpus();
smp_store_cpu_info(smp_processor_id());
/*
* are we trying to boot more cores than exist?
*/
if (max_cpus > ncores)
max_cpus = ncores;
if (max_cpus > 1) {
/*
* Enable the local timer or broadcast device for the
* boot CPU, but only if we have more than one CPU.
*/
percpu_timer_setup();
/*
* Initialise the SCU if there are more than one CPU
* and let them know where to start.
*/
platform_smp_prepare_cpus(max_cpus);
}
}
static void (*smp_cross_call)(const struct cpumask *, unsigned int);
void __init set_smp_cross_call(void (*fn)(const struct cpumask *, unsigned int))
{
smp_cross_call = fn;
}
void arch_send_call_function_ipi_mask(const struct cpumask *mask)
{
smp_cross_call(mask, IPI_CALL_FUNC);
}
void arch_send_call_function_single_ipi(int cpu)
{
smp_cross_call(cpumask_of(cpu), IPI_CALL_FUNC_SINGLE);
}
static const char *ipi_types[NR_IPI] = {
#define S(x,s) [x - IPI_TIMER] = s
S(IPI_TIMER, "Timer broadcast interrupts"),
S(IPI_RESCHEDULE, "Rescheduling interrupts"),
S(IPI_CALL_FUNC, "Function call interrupts"),
S(IPI_CALL_FUNC_SINGLE, "Single function call interrupts"),
S(IPI_CPU_STOP, "CPU stop interrupts"),
S(IPI_CPU_BACKTRACE, "CPU backtrace"),
};
void show_ipi_list(struct seq_file *p, int prec)
{
unsigned int cpu, i;
for (i = 0; i < NR_IPI; i++) {
seq_printf(p, "%*s%u: ", prec - 1, "IPI", i);
for_each_present_cpu(cpu)
seq_printf(p, "%10u ",
__get_irq_stat(cpu, ipi_irqs[i]));
seq_printf(p, " %s\n", ipi_types[i]);
}
}
u64 smp_irq_stat_cpu(unsigned int cpu)
{
u64 sum = 0;
int i;
for (i = 0; i < NR_IPI; i++)
sum += __get_irq_stat(cpu, ipi_irqs[i]);
#ifdef CONFIG_LOCAL_TIMERS
sum += __get_irq_stat(cpu, local_timer_irqs);
#endif
return sum;
}
/*
* Timer (local or broadcast) support
*/
static DEFINE_PER_CPU(struct clock_event_device, percpu_clockevent);
static void ipi_timer(void)
{
struct clock_event_device *evt = &__get_cpu_var(percpu_clockevent);
evt->event_handler(evt);
}
#ifdef CONFIG_LOCAL_TIMERS
asmlinkage void __exception_irq_entry do_local_timer(struct pt_regs *regs)
{
struct pt_regs *old_regs = set_irq_regs(regs);
int cpu = smp_processor_id();
if (local_timer_ack()) {
__inc_irq_stat(cpu, local_timer_irqs);
irq_enter();
ipi_timer();
irq_exit();
}
set_irq_regs(old_regs);
}
void show_local_irqs(struct seq_file *p, int prec)
{
unsigned int cpu;
seq_printf(p, "%*s: ", prec, "LOC");
for_each_present_cpu(cpu)
seq_printf(p, "%10u ", __get_irq_stat(cpu, local_timer_irqs));
seq_printf(p, " Local timer interrupts\n");
}
#endif
#ifdef CONFIG_GENERIC_CLOCKEVENTS_BROADCAST
static void smp_timer_broadcast(const struct cpumask *mask)
{
smp_cross_call(mask, IPI_TIMER);
}
#else
#define smp_timer_broadcast NULL
#endif
static void broadcast_timer_set_mode(enum clock_event_mode mode,
struct clock_event_device *evt)
{
}
static void __cpuinit broadcast_timer_setup(struct clock_event_device *evt)
{
evt->name = "dummy_timer";
evt->features = CLOCK_EVT_FEAT_ONESHOT |
CLOCK_EVT_FEAT_PERIODIC |
CLOCK_EVT_FEAT_DUMMY;
evt->rating = 400;
evt->mult = 1;
evt->set_mode = broadcast_timer_set_mode;
clockevents_register_device(evt);
}
void __cpuinit percpu_timer_setup(void)
{
unsigned int cpu = smp_processor_id();
struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
evt->cpumask = cpumask_of(cpu);
evt->broadcast = smp_timer_broadcast;
if (local_timer_setup(evt))
broadcast_timer_setup(evt);
}
#ifdef CONFIG_HOTPLUG_CPU
/*
* The generic clock events code purposely does not stop the local timer
* on CPU_DEAD/CPU_DEAD_FROZEN hotplug events, so we have to do it
* manually here.
*/
static void percpu_timer_stop(void)
{
unsigned int cpu = smp_processor_id();
struct clock_event_device *evt = &per_cpu(percpu_clockevent, cpu);
evt->set_mode(CLOCK_EVT_MODE_UNUSED, evt);
}
#endif
static DEFINE_SPINLOCK(stop_lock);
/*
* ipi_cpu_stop - handle IPI from smp_send_stop()
*/
static void ipi_cpu_stop(unsigned int cpu)
{
if (system_state == SYSTEM_BOOTING ||
system_state == SYSTEM_RUNNING) {
spin_lock(&stop_lock);
printk(KERN_CRIT "CPU%u: stopping\n", cpu);
dump_stack();
spin_unlock(&stop_lock);
}
set_cpu_online(cpu, false);
local_fiq_disable();
local_irq_disable();
flush_cache_all();
local_flush_tlb_all();
while (1)
cpu_relax();
}
static cpumask_t backtrace_mask;
static DEFINE_RAW_SPINLOCK(backtrace_lock);
/* "in progress" flag of arch_trigger_all_cpu_backtrace */
static unsigned long backtrace_flag;
void smp_send_all_cpu_backtrace(void)
{
unsigned int this_cpu = smp_processor_id();
int i;
if (test_and_set_bit(0, &backtrace_flag))
/*
* If there is already a trigger_all_cpu_backtrace() in progress
* (backtrace_flag == 1), don't output double cpu dump infos.
*/
return;
cpumask_copy(&backtrace_mask, cpu_online_mask);
cpu_clear(this_cpu, backtrace_mask);
pr_info("Backtrace for cpu %d (current):\n", this_cpu);
dump_stack();
pr_info("\nsending IPI to all other CPUs:\n");
smp_cross_call(&backtrace_mask, IPI_CPU_BACKTRACE);
/* Wait for up to 10 seconds for all other CPUs to do the backtrace */
for (i = 0; i < 10 * 1000; i++) {
if (cpumask_empty(&backtrace_mask))
break;
mdelay(1);
}
clear_bit(0, &backtrace_flag);
smp_mb__after_clear_bit();
}
/*
* ipi_cpu_backtrace - handle IPI from smp_send_all_cpu_backtrace()
*/
static void ipi_cpu_backtrace(unsigned int cpu, struct pt_regs *regs)
{
if (cpu_isset(cpu, backtrace_mask)) {
raw_spin_lock(&backtrace_lock);
pr_warning("IPI backtrace for cpu %d\n", cpu);
show_regs(regs);
raw_spin_unlock(&backtrace_lock);
cpu_clear(cpu, backtrace_mask);
}
}
/*
* Main handler for inter-processor interrupts
*/
asmlinkage void __exception_irq_entry do_IPI(int ipinr, struct pt_regs *regs)
{
unsigned int cpu = smp_processor_id();
struct pt_regs *old_regs = set_irq_regs(regs);
if (ipinr >= IPI_TIMER && ipinr < IPI_TIMER + NR_IPI)
__inc_irq_stat(cpu, ipi_irqs[ipinr - IPI_TIMER]);
switch (ipinr) {
case IPI_TIMER:
irq_enter();
ipi_timer();
irq_exit();
break;
case IPI_RESCHEDULE:
scheduler_ipi();
break;
case IPI_CALL_FUNC:
irq_enter();
generic_smp_call_function_interrupt();
irq_exit();
break;
case IPI_CALL_FUNC_SINGLE:
irq_enter();
generic_smp_call_function_single_interrupt();
irq_exit();
break;
case IPI_CPU_STOP:
irq_enter();
ipi_cpu_stop(cpu);
irq_exit();
break;
default:
printk(KERN_CRIT "CPU%u: Unknown IPI message 0x%x\n",
cpu, ipinr);
break;
}
sec_debug_irq_log(ipinr, do_IPI, 2);
set_irq_regs(old_regs);
}
void smp_send_reschedule(int cpu)
{
smp_cross_call(cpumask_of(cpu), IPI_RESCHEDULE);
}
void smp_send_stop(void)
{
unsigned long timeout;
if (num_online_cpus() > 1) {
cpumask_t mask = cpu_online_map;
cpu_clear(smp_processor_id(), mask);
smp_cross_call(&mask, IPI_CPU_STOP);
}
/* Wait up to one second for other CPUs to stop */
timeout = USEC_PER_SEC;
while (num_online_cpus() > 1 && timeout--)
udelay(1);
if (num_online_cpus() > 1)
pr_warning("SMP: failed to stop secondary CPUs\n");
}
/*
* not supported here
*/
int setup_profiling_timer(unsigned int multiplier)
{
return -EINVAL;
}
static void flush_all_cpu_cache(void *info)
{
flush_cache_all();
}
void flush_all_cpu_caches(void)
{
on_each_cpu(flush_all_cpu_cache, NULL, 1);
}
|
Koumajutsu/KoumaKernel-3.0.89_N8013
|
arch/arm/kernel/smp.c
|
C
|
gpl-2.0
| 16,174
|
package com.charlesdream.office.shared.enums;
import com.charlesdream.office.BaseEnum;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
/**
* Specifies the intensity of light used on a shape.
* <p>
*
* @author Charles Cui on 5/5/2016.
* @since 1.0
*/
public enum MsoPresetLightingSoftness implements BaseEnum {
/**
* Bright light.
*
* @since 1.0
*/
msoLightingBright(3),
/**
* Dim light.
*
* @since 1.0
*/
msoLightingDim(1),
/**
* Normal light.
*
* @since 1.0
*/
msoLightingNormal(2),
/**
* Not supported.
*
* @since 1.0
*/
msoPresetLightingSoftnessMixed(-2);
private static final Map<Integer, MsoPresetLightingSoftness> lookup;
static {
lookup = new HashMap<>();
for (MsoPresetLightingSoftness e : EnumSet.allOf(MsoPresetLightingSoftness.class)) {
lookup.put(e.value(), e);
}
}
private final int value;
MsoPresetLightingSoftness(int value) {
this.value = value;
}
/**
* Find the enum type by its value.
*
* @param value The enum value.
* @return The enum type, or null if this enum value does not exists.
* @since 1.0
*/
public static MsoPresetLightingSoftness find(int value) {
MsoPresetLightingSoftness result = lookup.get(value);
return result;
}
/**
* Find the enum type by its value, with the default value.
*
* @param value The enum value.
* @param defaultValue The default return value if the enum value does not exists.
* @return The enum type, or the default value if this enum value does not exists.
* @since 1.0
*/
public static MsoPresetLightingSoftness find(int value, MsoPresetLightingSoftness defaultValue) {
MsoPresetLightingSoftness result = MsoPresetLightingSoftness.find(value);
if (result == null) {
result = defaultValue;
}
return result;
}
/**
* Get the value of a enum type.
*
* @return The value of a enum type.
* @since 1.0
*/
public int value() {
return this.value;
}
}
|
Lotusun/OfficeHelper
|
src/main/java/com/charlesdream/office/shared/enums/MsoPresetLightingSoftness.java
|
Java
|
gpl-2.0
| 2,230
|
<?php
/**
* Elgg file plugin language pack
*
* @package ElggFile
*/
$danish = array(
/**
* Menu items and titles
*/
'file' => "Filer",
'file:user' => "%s's filer",
'file:friends' => "Venners filer",
'file:all' => "Alle filer",
'file:edit' => "Rediger fil",
'file:more' => "Flere filer",
'file:list' => "Liste",
'file:group' => "Gruppe filer",
'file:gallery' => "Galleri",
'file:gallery_list' => "Vis som liste eller galleri",
'file:num_files' => "Antal viste filer",
'file:user:gallery' => "Se %s galleri",
'file:via' => 'via filer',
'file:upload' => "Tilføj en fil",
'file:replace' => 'Erstat fil indhold (lad være tom for ikke at ændre i fil)',
'file:list:title' => "%s's %s %s",
'file:title:friends' => "Venner'",
'file:add' => 'Upload en fil',
'file:file' => "Fil",
'file:title' => "Titel",
'file:desc' => "Beskrivelse",
'file:tags' => "Tags",
'file:types' => "Tilføjede filtyper",
'file:type:' => 'Filer',
'file:type:all' => "Alle filer",
'file:type:video' => "Videoer",
'file:type:document' => "Dokumenter",
'file:type:audio' => "Lyd",
'file:type:image' => "Billeder",
'file:type:general' => "Andre",
'file:user:type:video' => "%s's videoer",
'file:user:type:document' => "%s's dokumenter",
'file:user:type:audio' => "%s's lyd",
'file:user:type:image' => "%s's billeder",
'file:user:type:general' => "%s's generelle filer",
'file:friends:type:video' => "Dine venners videoer",
'file:friends:type:document' => "Dine venners dokumenter",
'file:friends:type:audio' => "Dine venners lyd",
'file:friends:type:image' => "Dine venners billeder",
'file:friends:type:general' => "Dine venners generelle filer",
'file:widget' => "Fil widget",
'file:widget:description' => "Fremvis dine seneste filer",
'groups:enablefiles' => 'Aktiver gruppefiler',
'file:download' => "Hent dette",
'file:delete:confirm' => "Er du sikker på, at du vil slette denne fil?",
'file:tagcloud' => "Tag sky",
'file:display:number' => "Antal viste filer",
'river:create:object:file' => '%s tilføjede filen %s',
'river:comment:object:file' => '%s kommenterede filen %s',
'item:object:file' => "Filer",
/**
* Embed media
**/
'file:embed' => "Embed medie",
'file:embedall' => "Alle",
/**
* Status messages
*/
'file:saved' => "Din fil blev gemt.",
'file:deleted' => "Din fil blev slettet.",
/**
* Error messages
*/
'file:none' => "Vi kan ikke finde nogle filer i øjeblikket",
'file:uploadfailed' => "Beklager, vi kunne ikke gemme din fil.",
'file:downloadfailed' => "Beklager, denne fil er ikke til rådighed lige nu.",
'file:deletefailed' => "Din fil kunne ikke slettes.",
'file:noaccess' => "Du har ikke tilladelse ti at ændre denne fil",
'file:cannotload' => "Der opstod en fejl med indlæsning af filen",
'file:nofile' => "Du skal vælge en fil",
);
add_translation('da',$danish);
|
lorea/Elgg
|
mod/languages/languages/da/da.file.php
|
PHP
|
gpl-2.0
| 3,027
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.tools.ant.util;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
/**
* Subclass of Hashtable that wraps a LinkedHashMap to provide
* predictable iteration order.
*
* <p>This is not a general purpose class but has been written because
* the protected members of {@link org.apache.tools.ant.taskdefs.Copy
* Copy} prohibited later revisions from using a more predictable
* collection.</p>
*
* <p>Methods are synchronized to keep Hashtable's contract.</p>
*
* @since Ant 1.8.2
*/
public class LinkedHashtable extends Hashtable {
private final LinkedHashMap map;
public LinkedHashtable() {
map = new LinkedHashMap();
}
public LinkedHashtable(int initialCapacity) {
map = new LinkedHashMap(initialCapacity);
}
public LinkedHashtable(int initialCapacity, float loadFactor) {
map = new LinkedHashMap(initialCapacity, loadFactor);
}
public LinkedHashtable(Map m) {
map = new LinkedHashMap(m);
}
public synchronized void clear() {
map.clear();
}
public boolean contains(Object value) {
return containsKey(value);
}
public synchronized boolean containsKey(Object value) {
return map.containsKey(value);
}
public synchronized boolean containsValue(Object value) {
return map.containsValue(value);
}
public Enumeration elements() {
return CollectionUtils.asEnumeration(values().iterator());
}
public synchronized Set entrySet() {
return map.entrySet();
}
public synchronized boolean equals(Object o) {
return map.equals(o);
}
public synchronized Object get(Object k) {
return map.get(k);
}
public synchronized int hashCode() {
return map.hashCode();
}
public synchronized boolean isEmpty() {
return map.isEmpty();
}
public Enumeration keys() {
return CollectionUtils.asEnumeration(keySet().iterator());
}
public synchronized Set keySet() {
return map.keySet();
}
public synchronized Object put(Object k, Object v) {
return map.put(k, v);
}
public synchronized void putAll(Map m) {
map.putAll(m);
}
public synchronized Object remove(Object k) {
return map.remove(k);
}
public synchronized int size() {
return map.size();
}
public synchronized String toString() {
return map.toString();
}
public synchronized Collection values() {
return map.values();
}
}
|
BIORIMP/biorimp
|
BIO-RIMP/test_data/code/antapache/src/main/org/apache/tools/ant/util/LinkedHashtable.java
|
Java
|
gpl-2.0
| 3,483
|
<?php
/*
Plugin Name: Auditions
* Description: Auditions
*/
global $wpdb, $wp_version,$wp_query;
define("WP_auditions_TABLE", $wpdb->prefix . "auditions");
define( 'Auditions_plugin_Basename', plugin_basename( __FILE__ ) );
function auditions_plugin_url( $path = '' ) {
return plugins_url( $path, Auditions_plugin_Basename );
}
/** In main plugin file **/
function auditions_install()
{
global $wpdb, $wp_version;
add_option('auditions_title', "Auditions");
if($wpdb->get_var("show tables like '". WP_auditions_TABLE . "'") != WP_auditions_TABLE)
{
$wpdb->query("CREATE TABLE IF NOT EXISTS `". WP_auditions_TABLE . "` (
`auditions_id` int(11) NOT NULL auto_increment,
`auditions_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL ,
`auditions_times` text COLLATE latin1_swedish_ci NOT NULL ,
`auditions_location` varchar(500) CHARACTER SET utf8 COLLATE utf8_bin ,
`auditions_requirements` text COLLATE latin1_swedish_ci ,
`auditions_whattobring` text COLLATE latin1_swedish_ci ,
`auditions_date` date NOT NULL default '0000-00-00',
PRIMARY KEY (`auditions_id`) )
");
}
}
function auditions_admin_option()
{
//echo "<div class='wrap'>";
//echo "This plugin is created to store description of post formats with respect to their associted categories.";
//echo "</div>";
global $wpdb;
include_once("viewauditions.php");
}
function add_admin_menu_auditions() {
global $wpdb;
include_once("addauditions.php");
}
function add_admin_menu_option_auditions()
{
add_menu_page( __( 'Auditions', 'auditions' ), __( 'Auditions', 'auditions' ), 'administrator', 'auditions', 'auditions_admin_option' );
add_submenu_page('auditions', 'Add auditions', 'Add auditions', 'administrator', 'add_admin_menu_auditions', 'add_admin_menu_auditions');
}
add_action('admin_menu', 'add_admin_menu_option_auditions');
register_activation_hook(__FILE__, 'auditions_install');
//register_deactivation_hook(__FILE__, 'auditions_install');
?>
|
souvikchaudhury/rockawaytheatrecompany
|
wp-content/plugins/Auditions/auditions.php
|
PHP
|
gpl-2.0
| 2,011
|
package net.lodoma.lime.server;
import java.io.IOException;
import java.util.List;
import net.lodoma.lime.util.Identifiable;
public abstract class ServerPacket implements Identifiable<Integer>
{
protected Server server;
private int hash;
private Class<?>[] expected;
public ServerPacket(Server server, int hash, Class<?>... expected)
{
this.server = server;
this.hash = hash;
this.expected = expected;
}
@Override
public Integer getIdentifier()
{
return hash;
}
@Override
public void setIdentifier(Integer identifier)
{
throw new UnsupportedOperationException();
}
protected abstract void localWrite(ServerUser user, Object... args) throws IOException;
public final void write(ServerUser user, Object... args)
{
try
{
user.outputStream.writeInt(hash);
if(expected.length != args.length)
throw new IllegalArgumentException();
for (int i = 0; i < expected.length; i++)
if (!expected[i].isInstance(args[i]))
throw new IllegalArgumentException();
localWrite(user, args);
user.outputStream.flush();
}
catch (IOException e)
{
user.closed = true;
}
}
public final void handleAll(Object... args)
{
List<ServerUser> users = server.userManager.getUserSet();
for(ServerUser user : users)
write(user, args);
}
}
|
LoDoMa/Lime
|
src/net/lodoma/lime/server/ServerPacket.java
|
Java
|
gpl-2.0
| 1,596
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "common/debug.h"
#include "sludge/allfiles.h"
#include "sludge/sound.h"
#include "sludge/errors.h"
#include "sludge/sludge.h"
#include "sludge/version.h"
namespace Sludge {
const char emergencyMemoryMessage[] = "Out of memory displaying error message!";
extern int numResourceNames /* = 0*/;
extern Common::String *allResourceNames /*= ""*/;
int resourceForFatal = -1;
const Common::String resourceNameFromNum(int i) {
if (i == -1)
return NULL;
if (numResourceNames == 0)
return "RESOURCE";
if (i < numResourceNames)
return allResourceNames[i];
return "Unknown resource";
}
bool hasFatal() {
if (!g_sludge->fatalMessage.empty())
return true;
return false;
}
void registerWindowForFatal() {
g_sludge->fatalInfo = "There's an error with this SLUDGE game! If you're designing this game, please turn on verbose error messages in the project manager and recompile. If not, please contact the author saying where and how this problem occured.";
}
int inFatal(const Common::String &str) {
g_sludge->_soundMan->killSoundStuff();
error("%s", str.c_str());
return true;
}
int checkNew(const void *mem) {
if (mem == NULL) {
inFatal(ERROR_OUT_OF_MEMORY);
return 0;
}
return 1;
}
void setFatalInfo(const Common::String &userFunc, const Common::String &BIF) {
g_sludge->fatalInfo = "Currently in this sub: " + userFunc + "\nCalling: " + BIF;
debugC(0, kSludgeDebugFatal, "%s", g_sludge->fatalInfo.c_str());
}
void setResourceForFatal(int n) {
resourceForFatal = n;
}
int fatal(const Common::String &str1) {
if (numResourceNames && resourceForFatal != -1) {
Common::String r = resourceNameFromNum(resourceForFatal);
Common::String newStr = g_sludge->fatalInfo + "\nResource: " + r + "\n\n" + str1;
inFatal(newStr);
} else {
Common::String newStr = g_sludge->fatalInfo + "\n\n" + str1;
inFatal(newStr);
}
return 0;
}
int fatal(const Common::String &str1, const Common::String &str2) {
Common::String newStr = str1 + " " + str2;
fatal(newStr);
return 0;
}
} // End of namespace Sludge
|
yinsimei/scummvm
|
engines/sludge/newfatal.cpp
|
C++
|
gpl-2.0
| 2,986
|
<!DOCTYPE html>
<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head lang="en-US">
<title>My Family Tree - Cunningham, Sally Sarah</title>
<meta charset="UTF-8" />
<meta name ="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" />
<meta name ="apple-mobile-web-app-capable" content="yes" />
<meta name="generator" content="Gramps 4.2.2 http://gramps-project.org/" />
<meta name="author" content="" />
<link href="../../../images/favicon2.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../../css/narrative-screen.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../../../css/narrative-print.css" media="print" rel="stylesheet" type="text/css" />
<link href="../../../css/ancestortree.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<h1 id="SiteTitle">My Family Tree</h1>
</div>
<div class="wrapper" id="nav" role="navigation">
<div class="container">
<ul class="menu" id="dropmenu">
<li class = "CurrentSection"><a href="../../../individuals.html" title="Individuals">Individuals</a></li>
<li><a href="../../../index.html" title="Surnames">Surnames</a></li>
<li><a href="../../../families.html" title="Families">Families</a></li>
<li><a href="../../../places.html" title="Places">Places</a></li>
<li><a href="../../../sources.html" title="Sources">Sources</a></li>
<li><a href="../../../repositories.html" title="Repositories">Repositories</a></li>
<li><a href="../../../media.html" title="Media">Media</a></li>
<li><a href="../../../thumbnails.html" title="Thumbnails">Thumbnails</a></li>
<li><a href="../../../addressbook.html" title="Address Book">Address Book</a></li>
</ul>
</div>
</div>
<div class="content" id="IndividualDetail">
<h3>Cunningham, Sally Sarah<sup><small> <a href="#sref1">1</a></small></sup></h3>
<div id="summaryarea">
<table class="infolist">
<tr>
<td class="ColumnAttribute">Birth Name</td>
<td class="ColumnValue">
Cunningham, Sally Sarah
</td>
</tr>
<tr>
<td class="ColumnAttribute">Gramps ID</td>
<td class="ColumnValue">I0464</td>
</tr>
<tr>
<td class="ColumnAttribute">Gender</td>
<td class="ColumnValue">female</td>
</tr>
<tr>
<td class="ColumnAttribute">Age at Death</td>
<td class="ColumnValue">61 years, 4 months, 24 days</td>
</tr>
</table>
</div>
<div class="subsection" id="events">
<h4>Events</h4>
<table class="infolist eventlist">
<thead>
<tr>
<th class="ColumnEvent">Event</th>
<th class="ColumnDate">Date</th>
<th class="ColumnPlace">Place</th>
<th class="ColumnDescription">Description</th>
<th class="ColumnNotes">Notes</th>
<th class="ColumnSources">Sources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ColumnEvent">
Birth
</td>
<td class="ColumnDate">1805-09-25</td>
<td class="ColumnPlace">
<a href="../../../plc/b/r/R92KQCHJHYWI3HRVRB.html" title="Canon City, CO, USA">
Canon City, CO, USA
</a>
</td>
<td class="ColumnDescription">
Birth of Cunningham, Sally Sarah
</td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
<tr>
<td class="ColumnEvent">
Death
</td>
<td class="ColumnDate">1867-02-19</td>
<td class="ColumnPlace">
<a href="../../../plc/w/h/192KQC6R3Z8S89HMHW.html" title="San Diego, San Diego, CA, USA">
San Diego, San Diego, CA, USA
</a>
</td>
<td class="ColumnDescription">
Death of Cunningham, Sally Sarah
</td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
<tr>
<td class="ColumnEvent">
Burial
</td>
<td class="ColumnDate"> </td>
<td class="ColumnPlace">
<a href="../../../plc/a/t/JKUJQCQ6IUY6JTBXTA.html" title="Guaynabo, PR, USA">
Guaynabo, PR, USA
</a>
</td>
<td class="ColumnDescription">
Burial of Cunningham, Sally Sarah
</td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
</tbody>
</table>
</div>
<div class="subsection" id="parents">
<h4>Parents</h4>
<table class="infolist">
<thead>
<tr>
<th class="ColumnAttribute">Relation to main person</th>
<th class="ColumnValue">Name</th>
<th class="ColumnValue">Relation within this family (if not by birth)</th>
</tr>
</thead>
<tbody>
</tbody>
<tr>
<td class="ColumnAttribute">Father</td>
<td class="ColumnValue">
<a href="../../../ppl/k/i/2C2KQCYKETRCKNEUIK.html">Cunningham, William Philip<span class="grampsid"> [I0467]</span></a>
</td>
</tr>
<tr>
<td class="ColumnAttribute">Mother</td>
<td class="ColumnValue">
<a href="../../../ppl/b/h/CD2KQCWNA8KIVBAWHB.html">Park, Susannah<span class="grampsid"> [I0468]</span></a>
</td>
</tr>
<tr>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue"> <a href="../../../ppl/t/j/J92KQCFE0HMFGQ03JT.html">Cunningham, Sally Sarah<span class="grampsid"> [I0464]</span></a></td>
<td class="ColumnValue"></td>
</tr>
</table>
</div>
<div class="subsection" id="families">
<h4>Families</h4>
<table class="infolist">
<tr class="BeginFamily">
<td class="ColumnType"> </td>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue"><a href="../../../fam/g/e/69VJQCQTZ5HATCIBEG.html" title="Family of Blake, George and Cunningham, Sally Sarah">Family of Blake, George and Cunningham, Sally Sarah<span class="grampsid"> [F0105]</span></a></td>
</tr>
<tr class="BeginFamily">
<td class="ColumnType">Married</td>
<td class="ColumnAttribute">Husband</td>
<td class="ColumnValue">
<a href="../../../ppl/2/w/L82KQC1IWB1KHMCJW2.html">Blake, George<span class="grampsid"> [I0463]</span></a>
</td>
</tr>
<tr>
<td class="ColumnType"> </td>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue">
<table class="infolist eventlist">
<thead>
<tr>
<th class="ColumnEvent">Event</th>
<th class="ColumnDate">Date</th>
<th class="ColumnPlace">Place</th>
<th class="ColumnDescription">Description</th>
<th class="ColumnNotes">Notes</th>
<th class="ColumnSources">Sources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ColumnEvent">
Marriage
</td>
<td class="ColumnDate">1831-12-15</td>
<td class="ColumnPlace"> </td>
<td class="ColumnDescription">
Marriage of Blake, George and Cunningham, Sally Sarah
</td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
</tbody>
</table>
</td>
<tr>
<td class="ColumnType"> </td>
<td class="ColumnAttribute">Children</td>
<td class="ColumnValue">
<ol>
<li>
<a href="../../../ppl/w/t/I8VJQCNTR40JLJKXTW.html">Blake, M. Susannah<span class="grampsid"> [I0067]</span></a>
</li>
</ol>
</td>
</tr>
</tr>
</table>
</div>
<div class="subsection" id="familymap">
<h4>Family Map</h4>
<a class="familymap" href="../../../maps/t/j/J92KQCFE0HMFGQ03JT.html" title="Family Map">Family Map</a>
</div>
<div class="subsection" id="pedigree">
<h4>Pedigree</h4>
<ol class="pedigreegen">
<li>
<a href="../../../ppl/k/i/2C2KQCYKETRCKNEUIK.html">Cunningham, William Philip<span class="grampsid"> [I0467]</span></a>
<ol>
<li class="spouse">
<a href="../../../ppl/b/h/CD2KQCWNA8KIVBAWHB.html">Park, Susannah<span class="grampsid"> [I0468]</span></a>
<ol>
<li class="thisperson">
Cunningham, Sally Sarah
<ol class="spouselist">
<li class="spouse">
<a href="../../../ppl/2/w/L82KQC1IWB1KHMCJW2.html">Blake, George<span class="grampsid"> [I0463]</span></a>
<ol>
<li>
<a href="../../../ppl/w/t/I8VJQCNTR40JLJKXTW.html">Blake, M. Susannah<span class="grampsid"> [I0067]</span></a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</div>
<div class="subsection" id="tree">
<h4>Ancestors</h4>
<div id="treeContainer" style="width:735px; height:602px;">
<div class="boxbg female AncCol0" style="top: 269px; left: 6px;">
<a class="noThumb" href="../../../ppl/t/j/J92KQCFE0HMFGQ03JT.html">
Cunningham, Sally Sarah
</a>
</div>
<div class="shadow" style="top: 274px; left: 10px;"></div>
<div class="bvline" style="top: 301px; left: 165px; width: 15px"></div>
<div class="gvline" style="top: 306px; left: 165px; width: 20px"></div>
<div class="boxbg male AncCol1" style="top: 119px; left: 196px;">
<a class="noThumb" href="../../../ppl/k/i/2C2KQCYKETRCKNEUIK.html">
Cunningham, William Philip
</a>
</div>
<div class="shadow" style="top: 124px; left: 200px;"></div>
<div class="bvline" style="top: 151px; left: 180px; width: 15px;"></div>
<div class="gvline" style="top: 156px; left: 185px; width: 20px;"></div>
<div class="bhline" style="top: 151px; left: 180px; height: 150px;"></div>
<div class="gvline" style="top: 156px; left: 185px; height: 150px;"></div>
<div class="bvline" style="top: 151px; left: 355px; width: 15px"></div>
<div class="gvline" style="top: 156px; left: 355px; width: 20px"></div>
<div class="boxbg male AncCol2" style="top: 44px; left: 386px;">
<a class="noThumb" href="../../../ppl/r/l/YD2KQCZC7LCXIX5RLR.html">
Cunningham, Peter Sr.
</a>
</div>
<div class="shadow" style="top: 49px; left: 390px;"></div>
<div class="bvline" style="top: 76px; left: 370px; width: 15px;"></div>
<div class="gvline" style="top: 81px; left: 375px; width: 20px;"></div>
<div class="bhline" style="top: 76px; left: 370px; height: 75px;"></div>
<div class="gvline" style="top: 81px; left: 375px; height: 75px;"></div>
<div class="boxbg female AncCol2" style="top: 194px; left: 386px;">
<a class="noThumb" href="../../../ppl/3/r/889KQC80UAKGI4B2R3.html">
Dunn, Margaret Mary?
</a>
</div>
<div class="shadow" style="top: 199px; left: 390px;"></div>
<div class="bvline" style="top: 226px; left: 370px; width: 15px;"></div>
<div class="gvline" style="top: 231px; left: 375px; width: 20px;"></div>
<div class="bhline" style="top: 151px; left: 370px; height: 75px;"></div>
<div class="gvline" style="top: 156px; left: 375px; height: 75px;"></div>
<div class="boxbg female AncCol1" style="top: 419px; left: 196px;">
<a class="noThumb" href="../../../ppl/b/h/CD2KQCWNA8KIVBAWHB.html">
Park, Susannah
</a>
</div>
<div class="shadow" style="top: 424px; left: 200px;"></div>
<div class="bvline" style="top: 451px; left: 180px; width: 15px;"></div>
<div class="gvline" style="top: 456px; left: 185px; width: 20px;"></div>
<div class="bhline" style="top: 301px; left: 180px; height: 150px;"></div>
<div class="gvline" style="top: 306px; left: 185px; height: 150px;"></div>
<div class="bvline" style="top: 451px; left: 355px; width: 15px"></div>
<div class="gvline" style="top: 456px; left: 355px; width: 20px"></div>
<div class="boxbg male AncCol2" style="top: 344px; left: 386px;">
<a class="noThumb" href="../../../ppl/8/x/0F2KQC3Z0BOSGLKRX8.html">
Park, James
</a>
</div>
<div class="shadow" style="top: 349px; left: 390px;"></div>
<div class="bvline" style="top: 376px; left: 370px; width: 15px;"></div>
<div class="gvline" style="top: 381px; left: 375px; width: 20px;"></div>
<div class="bhline" style="top: 376px; left: 370px; height: 75px;"></div>
<div class="gvline" style="top: 381px; left: 375px; height: 75px;"></div>
</div>
</div>
<div class="subsection" id="sourcerefs">
<h4>Source References</h4>
<ol>
<li>
<a href="../../../src/x/a/X5TJQC9JXU4RKT6VAX.html" title="Import from test2.ged" name ="sref1">
Import from test2.ged
<span class="grampsid"> [S0003]</span>
</a>
</li>
</ol>
</div>
</div>
<div class="fullclear"></div>
<div id="footer">
<p id="createdate">
Generated by <a href="http://gramps-project.org/">Gramps</a> 4.2.2 on 2015-12-25<br />Last change was the 2007-07-26 08:34:25<br />Created for <a href="../../../ppl/h/o/GNUJQCL9MD64AM56OH.html">Garner von Zieliński, Lewis Anderson Sr</a>
</p>
<p id="copyright">
</p>
</div>
</body>
</html>
|
belissent/testing-example-reports
|
gramps42/gramps/example_NAVWEB1/ppl/t/j/J92KQCFE0HMFGQ03JT.html
|
HTML
|
gpl-2.0
| 13,142
|
/*
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU Lesser General Public License v.2.1.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "log.h"
#include "lvm2cmd.h"
#include "errors.h"
#include "libdevmapper-event.h"
#include "dmeventd_lvm.h"
#include <pthread.h>
#include <syslog.h>
extern int dmeventd_debug;
/*
* register_device() is called first and performs initialisation.
* Only one device may be registered or unregistered at a time.
*/
static pthread_mutex_t _register_mutex = PTHREAD_MUTEX_INITIALIZER;
/*
* Number of active registrations.
*/
static int _register_count = 0;
static struct dm_pool *_mem_pool = NULL;
static void *_lvm_handle = NULL;
/*
* Currently only one event can be processed at a time.
*/
static pthread_mutex_t _event_mutex = PTHREAD_MUTEX_INITIALIZER;
/*
* FIXME Do not pass things directly to syslog, rather use the existing logging
* facilities to sort logging ... however that mechanism needs to be somehow
* configurable and we don't have that option yet
*/
static void _temporary_log_fn(int level,
const char *file __attribute__((unused)),
int line __attribute__((unused)),
int dm_errno __attribute__((unused)),
const char *message)
{
level &= ~(_LOG_STDERR | _LOG_ONCE);
switch (level) {
case _LOG_DEBUG:
if (dmeventd_debug >= 3)
syslog(LOG_DEBUG, "%s", message);
break;
case _LOG_INFO:
if (dmeventd_debug >= 2)
syslog(LOG_INFO, "%s", message);
break;
case _LOG_NOTICE:
if (dmeventd_debug >= 1)
syslog(LOG_NOTICE, "%s", message);
break;
case _LOG_WARN:
syslog(LOG_WARNING, "%s", message);
break;
case _LOG_ERR:
syslog(LOG_ERR, "%s", message);
break;
default:
syslog(LOG_CRIT, "%s", message);
}
}
void dmeventd_lvm2_lock(void)
{
pthread_mutex_lock(&_event_mutex);
}
void dmeventd_lvm2_unlock(void)
{
pthread_mutex_unlock(&_event_mutex);
}
int dmeventd_lvm2_init(void)
{
int r = 0;
pthread_mutex_lock(&_register_mutex);
/*
* Need some space for allocations. 1024 should be more
* than enough for what we need (device mapper name splitting)
*/
if (!_mem_pool && !(_mem_pool = dm_pool_create("mirror_dso", 1024)))
goto out;
if (!_lvm_handle) {
lvm2_log_fn(_temporary_log_fn);
if (!(_lvm_handle = lvm2_init())) {
dm_pool_destroy(_mem_pool);
_mem_pool = NULL;
goto out;
}
lvm2_disable_dmeventd_monitoring(_lvm_handle);
/* FIXME Temporary: move to dmeventd core */
lvm2_run(_lvm_handle, "_memlock_inc");
}
_register_count++;
r = 1;
out:
pthread_mutex_unlock(&_register_mutex);
return r;
}
void dmeventd_lvm2_exit(void)
{
pthread_mutex_lock(&_register_mutex);
if (!--_register_count) {
lvm2_run(_lvm_handle, "_memlock_dec");
dm_pool_destroy(_mem_pool);
_mem_pool = NULL;
lvm2_exit(_lvm_handle);
_lvm_handle = NULL;
}
pthread_mutex_unlock(&_register_mutex);
}
struct dm_pool *dmeventd_lvm2_pool(void)
{
return _mem_pool;
}
int dmeventd_lvm2_run(const char *cmdline)
{
return lvm2_run(_lvm_handle, cmdline);
}
int dmeventd_lvm2_command(struct dm_pool *mem, char *buffer, size_t size,
const char *cmd, const char *device)
{
char *vg = NULL, *lv = NULL, *layer;
int r;
if (!dm_split_lvm_name(mem, device, &vg, &lv, &layer)) {
syslog(LOG_ERR, "Unable to determine VG name from %s.\n",
device);
return 0;
}
/* strip off the mirror component designations */
layer = strstr(lv, "_mlog");
if (layer)
*layer = '\0';
r = dm_snprintf(buffer, size, "%s %s/%s", cmd, vg, lv);
dm_pool_free(mem, vg);
if (r < 0) {
syslog(LOG_ERR, "Unable to form LVM command. (too long).\n");
return 0;
}
return 1;
}
|
andyvand/cyglvm2
|
daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c
|
C
|
gpl-2.0
| 4,030
|
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Magix.Brix.Components.ActiveTypes.TalkBack")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Magix.Brix.Components.ActiveTypes.TalkBack")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("605eb806-f3da-4334-a179-60fd0c1ebe02")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
xingh/magix
|
Magix-Brix/Magix.Brix.Components/ActiveTypes/Magix.Brix.Components.ActiveTypes.TalkBack/Properties/AssemblyInfo.cs
|
C#
|
gpl-2.0
| 1,496
|
/** @file mul.cpp
*
* Implementation of GiNaC's products of expressions. */
/*
* GiNaC Copyright (C) 1999-2009 Johannes Gutenberg University Mainz, Germany
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "mul.h"
#include "add.h"
#include "power.h"
#include "operators.h"
#include "matrix.h"
#include "indexed.h"
#include "lst.h"
#include "archive.h"
#include "utils.h"
#include "symbol.h"
#include "compiler.h"
#include <iostream>
#include <limits>
#include <stdexcept>
#include <vector>
namespace GiNaC {
GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(mul, expairseq,
print_func<print_context>(&mul::do_print).
print_func<print_latex>(&mul::do_print_latex).
print_func<print_csrc>(&mul::do_print_csrc).
print_func<print_tree>(&mul::do_print_tree).
print_func<print_python_repr>(&mul::do_print_python_repr))
//////////
// default constructor
//////////
mul::mul()
{
}
//////////
// other constructors
//////////
// public
mul::mul(const ex & lh, const ex & rh)
{
overall_coeff = _ex1;
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
}
mul::mul(const exvector & v)
{
overall_coeff = _ex1;
construct_from_exvector(v);
GINAC_ASSERT(is_canonical());
}
mul::mul(const epvector & v)
{
overall_coeff = _ex1;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
}
mul::mul(const epvector & v, const ex & oc, bool do_index_renaming)
{
overall_coeff = oc;
construct_from_epvector(v, do_index_renaming);
GINAC_ASSERT(is_canonical());
}
mul::mul(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming)
{
GINAC_ASSERT(vp.get()!=0);
overall_coeff = oc;
construct_from_epvector(*vp, do_index_renaming);
GINAC_ASSERT(is_canonical());
}
mul::mul(const ex & lh, const ex & mh, const ex & rh)
{
exvector factors;
factors.reserve(3);
factors.push_back(lh);
factors.push_back(mh);
factors.push_back(rh);
overall_coeff = _ex1;
construct_from_exvector(factors);
GINAC_ASSERT(is_canonical());
}
//////////
// archiving
//////////
//////////
// functions overriding virtual functions from base classes
//////////
void mul::print_overall_coeff(const print_context & c, const char *mul_sym) const
{
const numeric &coeff = ex_to<numeric>(overall_coeff);
if (coeff.csgn() == -1)
c.s << '-';
if (!coeff.is_equal(*_num1_p) &&
!coeff.is_equal(*_num_1_p)) {
if (coeff.is_rational()) {
if (coeff.is_negative())
(-coeff).print(c);
else
coeff.print(c);
} else {
if (coeff.csgn() == -1)
(-coeff).print(c, precedence());
else
coeff.print(c, precedence());
}
c.s << mul_sym;
}
}
void mul::do_print(const print_context & c, unsigned level) const
{
if (precedence() <= level)
c.s << '(';
print_overall_coeff(c, "*");
epvector::const_iterator it = seq.begin(), itend = seq.end();
bool first = true;
while (it != itend) {
if (!first)
c.s << '*';
else
first = false;
recombine_pair_to_ex(*it).print(c, precedence());
++it;
}
if (precedence() <= level)
c.s << ')';
}
void mul::do_print_latex(const print_latex & c, unsigned level) const
{
if (precedence() <= level)
c.s << "{(";
print_overall_coeff(c, " ");
// Separate factors into those with negative numeric exponent
// and all others
epvector::const_iterator it = seq.begin(), itend = seq.end();
exvector neg_powers, others;
while (it != itend) {
GINAC_ASSERT(is_exactly_a<numeric>(it->coeff));
if (ex_to<numeric>(it->coeff).is_negative())
neg_powers.push_back(recombine_pair_to_ex(expair(it->rest, -(it->coeff))));
else
others.push_back(recombine_pair_to_ex(*it));
++it;
}
if (!neg_powers.empty()) {
// Factors with negative exponent are printed as a fraction
c.s << "\\frac{";
mul(others).eval().print(c);
c.s << "}{";
mul(neg_powers).eval().print(c);
c.s << "}";
} else {
// All other factors are printed in the ordinary way
exvector::const_iterator vit = others.begin(), vitend = others.end();
while (vit != vitend) {
c.s << ' ';
vit->print(c, precedence());
++vit;
}
}
if (precedence() <= level)
c.s << ")}";
}
void mul::do_print_csrc(const print_csrc & c, unsigned level) const
{
if (precedence() <= level)
c.s << "(";
if (!overall_coeff.is_equal(_ex1)) {
if (overall_coeff.is_equal(_ex_1))
c.s << "-";
else {
overall_coeff.print(c, precedence());
c.s << "*";
}
}
// Print arguments, separated by "*" or "/"
epvector::const_iterator it = seq.begin(), itend = seq.end();
while (it != itend) {
// If the first argument is a negative integer power, it gets printed as "1.0/<expr>"
bool needclosingparenthesis = false;
if (it == seq.begin() && it->coeff.info(info_flags::negint)) {
if (is_a<print_csrc_cl_N>(c)) {
c.s << "recip(";
needclosingparenthesis = true;
} else
c.s << "1.0/";
}
// If the exponent is 1 or -1, it is left out
if (it->coeff.is_equal(_ex1) || it->coeff.is_equal(_ex_1))
it->rest.print(c, precedence());
else if (it->coeff.info(info_flags::negint))
// Outer parens around ex needed for broken GCC parser:
(ex(power(it->rest, -ex_to<numeric>(it->coeff)))).print(c, level);
else
// Outer parens around ex needed for broken GCC parser:
(ex(power(it->rest, ex_to<numeric>(it->coeff)))).print(c, level);
if (needclosingparenthesis)
c.s << ")";
// Separator is "/" for negative integer powers, "*" otherwise
++it;
if (it != itend) {
if (it->coeff.info(info_flags::negint))
c.s << "/";
else
c.s << "*";
}
}
if (precedence() <= level)
c.s << ")";
}
void mul::do_print_python_repr(const print_python_repr & c, unsigned level) const
{
c.s << class_name() << '(';
op(0).print(c);
for (size_t i=1; i<nops(); ++i) {
c.s << ',';
op(i).print(c);
}
c.s << ')';
}
bool mul::info(unsigned inf) const
{
switch (inf) {
case info_flags::polynomial:
case info_flags::integer_polynomial:
case info_flags::cinteger_polynomial:
case info_flags::rational_polynomial:
case info_flags::crational_polynomial:
case info_flags::rational_function: {
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if (!(recombine_pair_to_ex(*i).info(inf)))
return false;
++i;
}
return overall_coeff.info(inf);
}
case info_flags::algebraic: {
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if ((recombine_pair_to_ex(*i).info(inf)))
return true;
++i;
}
return false;
}
}
return inherited::info(inf);
}
int mul::degree(const ex & s) const
{
// Sum up degrees of factors
int deg_sum = 0;
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if (ex_to<numeric>(i->coeff).is_integer())
deg_sum += recombine_pair_to_ex(*i).degree(s);
else {
if (i->rest.has(s))
throw std::runtime_error("mul::degree() undefined degree because of non-integer exponent");
}
++i;
}
return deg_sum;
}
int mul::ldegree(const ex & s) const
{
// Sum up degrees of factors
int deg_sum = 0;
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if (ex_to<numeric>(i->coeff).is_integer())
deg_sum += recombine_pair_to_ex(*i).ldegree(s);
else {
if (i->rest.has(s))
throw std::runtime_error("mul::ldegree() undefined degree because of non-integer exponent");
}
++i;
}
return deg_sum;
}
ex mul::coeff(const ex & s, int n) const
{
exvector coeffseq;
coeffseq.reserve(seq.size()+1);
if (n==0) {
// product of individual coeffs
// if a non-zero power of s is found, the resulting product will be 0
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
coeffseq.push_back(recombine_pair_to_ex(*i).coeff(s,n));
++i;
}
coeffseq.push_back(overall_coeff);
return (new mul(coeffseq))->setflag(status_flags::dynallocated);
}
epvector::const_iterator i = seq.begin(), end = seq.end();
bool coeff_found = false;
while (i != end) {
ex t = recombine_pair_to_ex(*i);
ex c = t.coeff(s, n);
if (!c.is_zero()) {
coeffseq.push_back(c);
coeff_found = 1;
} else {
coeffseq.push_back(t);
}
++i;
}
if (coeff_found) {
coeffseq.push_back(overall_coeff);
return (new mul(coeffseq))->setflag(status_flags::dynallocated);
}
return _ex0;
}
/** Perform automatic term rewriting rules in this class. In the following
* x, x1, x2,... stand for a symbolic variables of type ex and c, c1, c2...
* stand for such expressions that contain a plain number.
* - *(...,x;0) -> 0
* - *(+(x1,x2,...);c) -> *(+(*(x1,c),*(x2,c),...))
* - *(x;1) -> x
* - *(;c) -> c
*
* @param level cut-off in recursive evaluation */
ex mul::eval(int level) const
{
std::auto_ptr<epvector> evaled_seqp = evalchildren(level);
if (evaled_seqp.get()) {
// do more evaluation later
return (new mul(evaled_seqp, overall_coeff))->
setflag(status_flags::dynallocated);
}
#ifdef DO_GINAC_ASSERT
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
GINAC_ASSERT((!is_exactly_a<mul>(i->rest)) ||
(!(ex_to<numeric>(i->coeff).is_integer())));
GINAC_ASSERT(!(i->is_canonical_numeric()));
if (is_exactly_a<numeric>(recombine_pair_to_ex(*i)))
print(print_tree(std::cerr));
GINAC_ASSERT(!is_exactly_a<numeric>(recombine_pair_to_ex(*i)));
/* for paranoia */
expair p = split_ex_to_pair(recombine_pair_to_ex(*i));
GINAC_ASSERT(p.rest.is_equal(i->rest));
GINAC_ASSERT(p.coeff.is_equal(i->coeff));
/* end paranoia */
++i;
}
#endif // def DO_GINAC_ASSERT
if (flags & status_flags::evaluated) {
GINAC_ASSERT(seq.size()>0);
GINAC_ASSERT(seq.size()>1 || !overall_coeff.is_equal(_ex1));
return *this;
}
size_t seq_size = seq.size();
if (overall_coeff.is_zero()) {
// *(...,x;0) -> 0
return _ex0;
} else if (seq_size==0) {
// *(;c) -> c
return overall_coeff;
} else if (seq_size==1 && overall_coeff.is_equal(_ex1)) {
// *(x;1) -> x
return recombine_pair_to_ex(*(seq.begin()));
} else if ((seq_size==1) &&
is_exactly_a<add>((*seq.begin()).rest) &&
ex_to<numeric>((*seq.begin()).coeff).is_equal(*_num1_p)) {
// *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +())
const add & addref = ex_to<add>((*seq.begin()).rest);
std::auto_ptr<epvector> distrseq(new epvector);
distrseq->reserve(addref.seq.size());
epvector::const_iterator i = addref.seq.begin(), end = addref.seq.end();
while (i != end) {
distrseq->push_back(addref.combine_pair_with_coeff_to_pair(*i, overall_coeff));
++i;
}
return (new add(distrseq,
ex_to<numeric>(addref.overall_coeff).
mul_dyn(ex_to<numeric>(overall_coeff)))
)->setflag(status_flags::dynallocated | status_flags::evaluated);
} else if ((seq_size >= 2) && (! (flags & status_flags::expanded))) {
// Strip the content and the unit part from each term. Thus
// things like (-x+a)*(3*x-3*a) automagically turn into - 3*(x-a)2
epvector::const_iterator last = seq.end();
epvector::const_iterator i = seq.begin();
epvector::const_iterator j = seq.begin();
std::auto_ptr<epvector> s(new epvector);
numeric oc = *_num1_p;
bool something_changed = false;
while (i!=last) {
if (likely(! (is_a<add>(i->rest) && i->coeff.is_equal(_ex1)))) {
// power::eval has such a rule, no need to handle powers here
++i;
continue;
}
// XXX: What is the best way to check if the polynomial is a primitive?
numeric c = i->rest.integer_content();
const numeric lead_coeff =
ex_to<numeric>(ex_to<add>(i->rest).seq.begin()->coeff).div(c);
const bool canonicalizable = lead_coeff.is_integer();
// XXX: The main variable is chosen in a random way, so this code
// does NOT transform the term into the canonical form (thus, in some
// very unlucky event it can even loop forever). Hopefully the main
// variable will be the same for all terms in *this
const bool unit_normal = lead_coeff.is_pos_integer();
if (likely((c == *_num1_p) && ((! canonicalizable) || unit_normal))) {
++i;
continue;
}
if (! something_changed) {
s->reserve(seq_size);
something_changed = true;
}
while ((j!=i) && (j!=last)) {
s->push_back(*j);
++j;
}
if (! unit_normal)
c = c.mul(*_num_1_p);
oc = oc.mul(c);
// divide add by the number in place to save at least 2 .eval() calls
const add& addref = ex_to<add>(i->rest);
add* primitive = new add(addref);
primitive->setflag(status_flags::dynallocated);
primitive->clearflag(status_flags::hash_calculated);
primitive->overall_coeff = ex_to<numeric>(primitive->overall_coeff).div_dyn(c);
for (epvector::iterator ai = primitive->seq.begin();
ai != primitive->seq.end(); ++ai)
ai->coeff = ex_to<numeric>(ai->coeff).div_dyn(c);
s->push_back(expair(*primitive, _ex1));
++i;
++j;
}
if (something_changed) {
while (j!=last) {
s->push_back(*j);
++j;
}
return (new mul(s, ex_to<numeric>(overall_coeff).mul_dyn(oc))
)->setflag(status_flags::dynallocated);
}
}
return this->hold();
}
ex mul::evalf(int level) const
{
if (level==1)
return mul(seq,overall_coeff);
if (level==-max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
--level;
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
s->push_back(combine_ex_with_coeff_to_pair(i->rest.evalf(level),
i->coeff));
++i;
}
return mul(s, overall_coeff.evalf(level));
}
void mul::find_real_imag(ex & rp, ex & ip) const
{
rp = overall_coeff.real_part();
ip = overall_coeff.imag_part();
for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) {
ex factor = recombine_pair_to_ex(*i);
ex new_rp = factor.real_part();
ex new_ip = factor.imag_part();
if(new_ip.is_zero()) {
rp *= new_rp;
ip *= new_rp;
} else {
ex temp = rp*new_rp - ip*new_ip;
ip = ip*new_rp + rp*new_ip;
rp = temp;
}
}
rp = rp.expand();
ip = ip.expand();
}
ex mul::real_part() const
{
ex rp, ip;
find_real_imag(rp, ip);
return rp;
}
ex mul::imag_part() const
{
ex rp, ip;
find_real_imag(rp, ip);
return ip;
}
ex mul::evalm() const
{
// numeric*matrix
if (seq.size() == 1 && seq[0].coeff.is_equal(_ex1)
&& is_a<matrix>(seq[0].rest))
return ex_to<matrix>(seq[0].rest).mul(ex_to<numeric>(overall_coeff));
// Evaluate children first, look whether there are any matrices at all
// (there can be either no matrices or one matrix; if there were more
// than one matrix, it would be a non-commutative product)
std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
bool have_matrix = false;
epvector::iterator the_matrix;
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
const ex &m = recombine_pair_to_ex(*i).evalm();
s->push_back(split_ex_to_pair(m));
if (is_a<matrix>(m)) {
have_matrix = true;
the_matrix = s->end() - 1;
}
++i;
}
if (have_matrix) {
// The product contained a matrix. We will multiply all other factors
// into that matrix.
matrix m = ex_to<matrix>(the_matrix->rest);
s->erase(the_matrix);
ex scalar = (new mul(s, overall_coeff))->setflag(status_flags::dynallocated);
return m.mul_scalar(scalar);
} else
return (new mul(s, overall_coeff))->setflag(status_flags::dynallocated);
}
ex mul::eval_ncmul(const exvector & v) const
{
if (seq.empty())
return inherited::eval_ncmul(v);
// Find first noncommutative element and call its eval_ncmul()
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if (i->rest.return_type() == return_types::noncommutative)
return i->rest.eval_ncmul(v);
++i;
}
return inherited::eval_ncmul(v);
}
bool tryfactsubs(const ex & origfactor, const ex & patternfactor, int & nummatches, exmap& repls)
{
ex origbase;
int origexponent;
int origexpsign;
if (is_exactly_a<power>(origfactor) && origfactor.op(1).info(info_flags::integer)) {
origbase = origfactor.op(0);
int expon = ex_to<numeric>(origfactor.op(1)).to_int();
origexponent = expon > 0 ? expon : -expon;
origexpsign = expon > 0 ? 1 : -1;
} else {
origbase = origfactor;
origexponent = 1;
origexpsign = 1;
}
ex patternbase;
int patternexponent;
int patternexpsign;
if (is_exactly_a<power>(patternfactor) && patternfactor.op(1).info(info_flags::integer)) {
patternbase = patternfactor.op(0);
int expon = ex_to<numeric>(patternfactor.op(1)).to_int();
patternexponent = expon > 0 ? expon : -expon;
patternexpsign = expon > 0 ? 1 : -1;
} else {
patternbase = patternfactor;
patternexponent = 1;
patternexpsign = 1;
}
exmap saverepls = repls;
if (origexponent < patternexponent || origexpsign != patternexpsign || !origbase.match(patternbase,saverepls))
return false;
repls = saverepls;
int newnummatches = origexponent / patternexponent;
if (newnummatches < nummatches)
nummatches = newnummatches;
return true;
}
/** Checks wheter e matches to the pattern pat and the (possibly to be updated)
* list of replacements repls. This matching is in the sense of algebraic
* substitutions. Matching starts with pat.op(factor) of the pattern because
* the factors before this one have already been matched. The (possibly
* updated) number of matches is in nummatches. subsed[i] is true for factors
* that already have been replaced by previous substitutions and matched[i]
* is true for factors that have been matched by the current match.
*/
bool algebraic_match_mul_with_mul(const mul &e, const ex &pat, exmap& repls,
int factor, int &nummatches, const std::vector<bool> &subsed,
std::vector<bool> &matched)
{
if (factor == (int)pat.nops())
return true;
for (size_t i=0; i<e.nops(); ++i) {
if(subsed[i] || matched[i])
continue;
exmap newrepls = repls;
int newnummatches = nummatches;
if (tryfactsubs(e.op(i), pat.op(factor), newnummatches, newrepls)) {
matched[i] = true;
if (algebraic_match_mul_with_mul(e, pat, newrepls, factor+1,
newnummatches, subsed, matched)) {
repls = newrepls;
nummatches = newnummatches;
return true;
}
else
matched[i] = false;
}
}
return false;
}
bool mul::has(const ex & pattern, unsigned options) const
{
if(!(options&has_options::algebraic))
return basic::has(pattern,options);
if(is_a<mul>(pattern)) {
exmap repls;
int nummatches = std::numeric_limits<int>::max();
std::vector<bool> subsed(seq.size(), false);
std::vector<bool> matched(seq.size(), false);
if(algebraic_match_mul_with_mul(*this, pattern, repls, 0, nummatches,
subsed, matched))
return true;
}
return basic::has(pattern, options);
}
ex mul::algebraic_subs_mul(const exmap & m, unsigned options) const
{
std::vector<bool> subsed(seq.size(), false);
exvector subsresult(seq.size());
ex divide_by = 1;
ex multiply_by = 1;
for (exmap::const_iterator it = m.begin(); it != m.end(); ++it) {
if (is_exactly_a<mul>(it->first)) {
retry1:
int nummatches = std::numeric_limits<int>::max();
std::vector<bool> currsubsed(seq.size(), false);
exmap repls;
if(!algebraic_match_mul_with_mul(*this, it->first, repls, 0, nummatches, subsed, currsubsed))
continue;
for (size_t j=0; j<subsed.size(); j++)
if (currsubsed[j])
subsed[j] = true;
ex subsed_pattern
= it->first.subs(repls, subs_options::no_pattern);
divide_by *= power(subsed_pattern, nummatches);
ex subsed_result
= it->second.subs(repls, subs_options::no_pattern);
multiply_by *= power(subsed_result, nummatches);
goto retry1;
} else {
for (size_t j=0; j<this->nops(); j++) {
int nummatches = std::numeric_limits<int>::max();
exmap repls;
if (!subsed[j] && tryfactsubs(op(j), it->first, nummatches, repls)){
subsed[j] = true;
ex subsed_pattern
= it->first.subs(repls, subs_options::no_pattern);
divide_by *= power(subsed_pattern, nummatches);
ex subsed_result
= it->second.subs(repls, subs_options::no_pattern);
multiply_by *= power(subsed_result, nummatches);
}
}
}
}
bool subsfound = false;
for (size_t i=0; i<subsed.size(); i++) {
if (subsed[i]) {
subsfound = true;
break;
}
}
if (!subsfound)
return subs_one_level(m, options | subs_options::algebraic);
return ((*this)/divide_by)*multiply_by;
}
// protected
/** Implementation of ex::diff() for a product. It applies the product rule.
* @see ex::diff */
ex mul::derivative(const symbol & s) const
{
size_t num = seq.size();
exvector addseq;
addseq.reserve(num);
// D(a*b*c) = D(a)*b*c + a*D(b)*c + a*b*D(c)
epvector mulseq = seq;
epvector::const_iterator i = seq.begin(), end = seq.end();
epvector::iterator i2 = mulseq.begin();
while (i != end) {
expair ep = split_ex_to_pair(power(i->rest, i->coeff - _ex1) *
i->rest.diff(s));
ep.swap(*i2);
addseq.push_back((new mul(mulseq, overall_coeff * i->coeff))->setflag(status_flags::dynallocated));
ep.swap(*i2);
++i; ++i2;
}
return (new add(addseq))->setflag(status_flags::dynallocated);
}
int mul::compare_same_type(const basic & other) const
{
return inherited::compare_same_type(other);
}
unsigned mul::return_type() const
{
if (seq.empty()) {
// mul without factors: should not happen, but commutates
return return_types::commutative;
}
bool all_commutative = true;
epvector::const_iterator noncommutative_element; // point to first found nc element
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
unsigned rt = i->rest.return_type();
if (rt == return_types::noncommutative_composite)
return rt; // one ncc -> mul also ncc
if ((rt == return_types::noncommutative) && (all_commutative)) {
// first nc element found, remember position
noncommutative_element = i;
all_commutative = false;
}
if ((rt == return_types::noncommutative) && (!all_commutative)) {
// another nc element found, compare type_infos
if (noncommutative_element->rest.return_type_tinfo() != i->rest.return_type_tinfo()) {
// different types -> mul is ncc
return return_types::noncommutative_composite;
}
}
++i;
}
// all factors checked
return all_commutative ? return_types::commutative : return_types::noncommutative;
}
return_type_t mul::return_type_tinfo() const
{
if (seq.empty())
return make_return_type_t<mul>(); // mul without factors: should not happen
// return type_info of first noncommutative element
epvector::const_iterator i = seq.begin(), end = seq.end();
while (i != end) {
if (i->rest.return_type() == return_types::noncommutative)
return i->rest.return_type_tinfo();
++i;
}
// no noncommutative element found, should not happen
return make_return_type_t<mul>();
}
ex mul::thisexpairseq(const epvector & v, const ex & oc, bool do_index_renaming) const
{
return (new mul(v, oc, do_index_renaming))->setflag(status_flags::dynallocated);
}
ex mul::thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc, bool do_index_renaming) const
{
return (new mul(vp, oc, do_index_renaming))->setflag(status_flags::dynallocated);
}
expair mul::split_ex_to_pair(const ex & e) const
{
if (is_exactly_a<power>(e)) {
const power & powerref = ex_to<power>(e);
if (is_exactly_a<numeric>(powerref.exponent))
return expair(powerref.basis,powerref.exponent);
}
return expair(e,_ex1);
}
expair mul::combine_ex_with_coeff_to_pair(const ex & e,
const ex & c) const
{
// to avoid duplication of power simplification rules,
// we create a temporary power object
// otherwise it would be hard to correctly evaluate
// expression like (4^(1/3))^(3/2)
if (c.is_equal(_ex1))
return split_ex_to_pair(e);
return split_ex_to_pair(power(e,c));
}
expair mul::combine_pair_with_coeff_to_pair(const expair & p,
const ex & c) const
{
// to avoid duplication of power simplification rules,
// we create a temporary power object
// otherwise it would be hard to correctly evaluate
// expression like (4^(1/3))^(3/2)
if (c.is_equal(_ex1))
return p;
return split_ex_to_pair(power(recombine_pair_to_ex(p),c));
}
ex mul::recombine_pair_to_ex(const expair & p) const
{
if (ex_to<numeric>(p.coeff).is_equal(*_num1_p))
return p.rest;
else
return (new power(p.rest,p.coeff))->setflag(status_flags::dynallocated);
}
bool mul::expair_needs_further_processing(epp it)
{
if (is_exactly_a<mul>(it->rest) &&
ex_to<numeric>(it->coeff).is_integer()) {
// combined pair is product with integer power -> expand it
*it = split_ex_to_pair(recombine_pair_to_ex(*it));
return true;
}
if (is_exactly_a<numeric>(it->rest)) {
expair ep = split_ex_to_pair(recombine_pair_to_ex(*it));
if (!ep.is_equal(*it)) {
// combined pair is a numeric power which can be simplified
*it = ep;
return true;
}
if (it->coeff.is_equal(_ex1)) {
// combined pair has coeff 1 and must be moved to the end
return true;
}
}
return false;
}
ex mul::default_overall_coeff() const
{
return _ex1;
}
void mul::combine_overall_coeff(const ex & c)
{
GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
GINAC_ASSERT(is_exactly_a<numeric>(c));
overall_coeff = ex_to<numeric>(overall_coeff).mul_dyn(ex_to<numeric>(c));
}
void mul::combine_overall_coeff(const ex & c1, const ex & c2)
{
GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
GINAC_ASSERT(is_exactly_a<numeric>(c1));
GINAC_ASSERT(is_exactly_a<numeric>(c2));
overall_coeff = ex_to<numeric>(overall_coeff).mul_dyn(ex_to<numeric>(c1).power(ex_to<numeric>(c2)));
}
bool mul::can_make_flat(const expair & p) const
{
GINAC_ASSERT(is_exactly_a<numeric>(p.coeff));
// this assertion will probably fail somewhere
// it would require a more careful make_flat, obeying the power laws
// probably should return true only if p.coeff is integer
return ex_to<numeric>(p.coeff).is_equal(*_num1_p);
}
bool mul::can_be_further_expanded(const ex & e)
{
if (is_exactly_a<mul>(e)) {
for (epvector::const_iterator cit = ex_to<mul>(e).seq.begin(); cit != ex_to<mul>(e).seq.end(); ++cit) {
if (is_exactly_a<add>(cit->rest) && cit->coeff.info(info_flags::posint))
return true;
}
} else if (is_exactly_a<power>(e)) {
if (is_exactly_a<add>(e.op(0)) && e.op(1).info(info_flags::posint))
return true;
}
return false;
}
ex mul::expand(unsigned options) const
{
{
// trivial case: expanding the monomial (~ 30% of all calls)
epvector::const_iterator i = seq.begin(), seq_end = seq.end();
while ((i != seq.end()) && is_a<symbol>(i->rest) && i->coeff.info(info_flags::integer))
++i;
if (i == seq_end) {
setflag(status_flags::expanded);
return *this;
}
}
// do not rename indices if the object has no indices at all
if ((!(options & expand_options::expand_rename_idx)) &&
this->info(info_flags::has_indices))
options |= expand_options::expand_rename_idx;
const bool skip_idx_rename = !(options & expand_options::expand_rename_idx);
// First, expand the children
std::auto_ptr<epvector> expanded_seqp = expandchildren(options);
const epvector & expanded_seq = (expanded_seqp.get() ? *expanded_seqp : seq);
// Now, look for all the factors that are sums and multiply each one out
// with the next one that is found while collecting the factors which are
// not sums
ex last_expanded = _ex1;
epvector non_adds;
non_adds.reserve(expanded_seq.size());
for (epvector::const_iterator cit = expanded_seq.begin(); cit != expanded_seq.end(); ++cit) {
if (is_exactly_a<add>(cit->rest) &&
(cit->coeff.is_equal(_ex1))) {
if (is_exactly_a<add>(last_expanded)) {
// Expand a product of two sums, aggressive version.
// Caring for the overall coefficients in separate loops can
// sometimes give a performance gain of up to 15%!
const int sizedifference = ex_to<add>(last_expanded).seq.size()-ex_to<add>(cit->rest).seq.size();
// add2 is for the inner loop and should be the bigger of the two sums
// in the presence of asymptotically good sorting:
const add& add1 = (sizedifference<0 ? ex_to<add>(last_expanded) : ex_to<add>(cit->rest));
const add& add2 = (sizedifference<0 ? ex_to<add>(cit->rest) : ex_to<add>(last_expanded));
const epvector::const_iterator add1begin = add1.seq.begin();
const epvector::const_iterator add1end = add1.seq.end();
const epvector::const_iterator add2begin = add2.seq.begin();
const epvector::const_iterator add2end = add2.seq.end();
epvector distrseq;
distrseq.reserve(add1.seq.size()+add2.seq.size());
// Multiply add2 with the overall coefficient of add1 and append it to distrseq:
if (!add1.overall_coeff.is_zero()) {
if (add1.overall_coeff.is_equal(_ex1))
distrseq.insert(distrseq.end(),add2begin,add2end);
else
for (epvector::const_iterator i=add2begin; i!=add2end; ++i)
distrseq.push_back(expair(i->rest, ex_to<numeric>(i->coeff).mul_dyn(ex_to<numeric>(add1.overall_coeff))));
}
// Multiply add1 with the overall coefficient of add2 and append it to distrseq:
if (!add2.overall_coeff.is_zero()) {
if (add2.overall_coeff.is_equal(_ex1))
distrseq.insert(distrseq.end(),add1begin,add1end);
else
for (epvector::const_iterator i=add1begin; i!=add1end; ++i)
distrseq.push_back(expair(i->rest, ex_to<numeric>(i->coeff).mul_dyn(ex_to<numeric>(add2.overall_coeff))));
}
// Compute the new overall coefficient and put it together:
ex tmp_accu = (new add(distrseq, add1.overall_coeff*add2.overall_coeff))->setflag(status_flags::dynallocated);
exvector add1_dummy_indices, add2_dummy_indices, add_indices;
lst dummy_subs;
if (!skip_idx_rename) {
for (epvector::const_iterator i=add1begin; i!=add1end; ++i) {
add_indices = get_all_dummy_indices_safely(i->rest);
add1_dummy_indices.insert(add1_dummy_indices.end(), add_indices.begin(), add_indices.end());
}
for (epvector::const_iterator i=add2begin; i!=add2end; ++i) {
add_indices = get_all_dummy_indices_safely(i->rest);
add2_dummy_indices.insert(add2_dummy_indices.end(), add_indices.begin(), add_indices.end());
}
sort(add1_dummy_indices.begin(), add1_dummy_indices.end(), ex_is_less());
sort(add2_dummy_indices.begin(), add2_dummy_indices.end(), ex_is_less());
dummy_subs = rename_dummy_indices_uniquely(add1_dummy_indices, add2_dummy_indices);
}
// Multiply explicitly all non-numeric terms of add1 and add2:
for (epvector::const_iterator i2=add2begin; i2!=add2end; ++i2) {
// We really have to combine terms here in order to compactify
// the result. Otherwise it would become waayy tooo bigg.
numeric oc(*_num0_p);
epvector distrseq2;
distrseq2.reserve(add1.seq.size());
const ex i2_new = (skip_idx_rename || (dummy_subs.op(0).nops() == 0) ?
i2->rest :
i2->rest.subs(ex_to<lst>(dummy_subs.op(0)),
ex_to<lst>(dummy_subs.op(1)), subs_options::no_pattern));
for (epvector::const_iterator i1=add1begin; i1!=add1end; ++i1) {
// Don't push_back expairs which might have a rest that evaluates to a numeric,
// since that would violate an invariant of expairseq:
const ex rest = (new mul(i1->rest, i2_new))->setflag(status_flags::dynallocated);
if (is_exactly_a<numeric>(rest)) {
oc += ex_to<numeric>(rest).mul(ex_to<numeric>(i1->coeff).mul(ex_to<numeric>(i2->coeff)));
} else {
distrseq2.push_back(expair(rest, ex_to<numeric>(i1->coeff).mul_dyn(ex_to<numeric>(i2->coeff))));
}
}
tmp_accu += (new add(distrseq2, oc))->setflag(status_flags::dynallocated);
}
last_expanded = tmp_accu;
} else {
if (!last_expanded.is_equal(_ex1))
non_adds.push_back(split_ex_to_pair(last_expanded));
last_expanded = cit->rest;
}
} else {
non_adds.push_back(*cit);
}
}
// Now the only remaining thing to do is to multiply the factors which
// were not sums into the "last_expanded" sum
if (is_exactly_a<add>(last_expanded)) {
size_t n = last_expanded.nops();
exvector distrseq;
distrseq.reserve(n);
exvector va;
if (! skip_idx_rename) {
va = get_all_dummy_indices_safely(mul(non_adds));
sort(va.begin(), va.end(), ex_is_less());
}
for (size_t i=0; i<n; ++i) {
epvector factors = non_adds;
if (skip_idx_rename)
factors.push_back(split_ex_to_pair(last_expanded.op(i)));
else
factors.push_back(split_ex_to_pair(rename_dummy_indices_uniquely(va, last_expanded.op(i))));
ex term = (new mul(factors, overall_coeff))->setflag(status_flags::dynallocated);
if (can_be_further_expanded(term)) {
distrseq.push_back(term.expand());
} else {
if (options == 0)
ex_to<basic>(term).setflag(status_flags::expanded);
distrseq.push_back(term);
}
}
return ((new add(distrseq))->
setflag(status_flags::dynallocated | (options == 0 ? status_flags::expanded : 0)));
}
non_adds.push_back(split_ex_to_pair(last_expanded));
ex result = (new mul(non_adds, overall_coeff))->setflag(status_flags::dynallocated);
if (can_be_further_expanded(result)) {
return result.expand();
} else {
if (options == 0)
ex_to<basic>(result).setflag(status_flags::expanded);
return result;
}
}
//////////
// new virtual functions which can be overridden by derived classes
//////////
// none
//////////
// non-virtual functions in this class
//////////
/** Member-wise expand the expairs representing this sequence. This must be
* overridden from expairseq::expandchildren() and done iteratively in order
* to allow for early cancallations and thus safe memory.
*
* @see mul::expand()
* @return pointer to epvector containing expanded representation or zero
* pointer, if sequence is unchanged. */
std::auto_ptr<epvector> mul::expandchildren(unsigned options) const
{
const epvector::const_iterator last = seq.end();
epvector::const_iterator cit = seq.begin();
while (cit!=last) {
const ex & factor = recombine_pair_to_ex(*cit);
const ex & expanded_factor = factor.expand(options);
if (!are_ex_trivially_equal(factor,expanded_factor)) {
// something changed, copy seq, eval and return it
std::auto_ptr<epvector> s(new epvector);
s->reserve(seq.size());
// copy parts of seq which are known not to have changed
epvector::const_iterator cit2 = seq.begin();
while (cit2!=cit) {
s->push_back(*cit2);
++cit2;
}
// copy first changed element
s->push_back(split_ex_to_pair(expanded_factor));
++cit2;
// copy rest
while (cit2!=last) {
s->push_back(split_ex_to_pair(recombine_pair_to_ex(*cit2).expand(options)));
++cit2;
}
return s;
}
++cit;
}
return std::auto_ptr<epvector>(0); // nothing has changed
}
GINAC_BIND_UNARCHIVER(mul);
} // namespace GiNaC
|
jorgeecardona/ginac
|
ginac/mul.cpp
|
C++
|
gpl-2.0
| 35,573
|
jQuery(document).ready(function(){
// open new window for 'popup' class element or external links
$('a').each(function(i, elem) {
if ($(elem).hasClass('popup') ||
elem.href.indexOf('//') >= 0 && elem.href.indexOf('//'+location.host) < 0) {
$(elem).on('click keypress', function(event) {
window.open($(this).attr('href'));
event.preventDefault();
});
}
});
// open link on click 'clickable' class element
$('.clickable').each(function() {
var elem = $(this);
var href = elem.children('a').attr('href');
if (href) {
elem.on('click', function(e) {
location.href = href;
e.stopPropagation();
});
}
});
});
|
yh1224/ingressevents
|
app/assets/javascripts/main.js
|
JavaScript
|
gpl-2.0
| 727
|
/*
* Created on Aug 7, 2008
* Created by Paul Gardner
*
* Copyright 2008 Vuze, Inc. All rights reserved.
*
* This program 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; version 2 of the License only.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
package com.aelitis.azureus.core.subs.impl;
import com.aelitis.azureus.core.metasearch.Result;
import com.aelitis.azureus.core.subs.SubscriptionResult;
import com.aelitis.azureus.util.JSONUtils;
import org.gudy.azureus2.core3.util.Base32;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.core3.util.DisplayFormatters;
import org.gudy.azureus2.core3.util.SHA1Simple;
import org.gudy.azureus2.plugins.utils.search.SearchResult;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class
SubscriptionResultImpl
implements SubscriptionResult
{
final private SubscriptionHistoryImpl history;
private byte[] key1;
private byte[] key2;
private boolean read;
private boolean deleted;
private String result_json;
protected
SubscriptionResultImpl(
SubscriptionHistoryImpl _history,
Result result )
{
history = _history;
Map map = result.toJSONMap();
result_json = JSONUtils.encodeToJSON( map );
read = false;
String key1_str = result.getEngine().getId() + ":" + result.getName();
try{
byte[] sha1 = new SHA1Simple().calculateHash( key1_str.getBytes( "UTF-8" ));
key1 = new byte[10];
System.arraycopy( sha1, 0, key1, 0, 10 );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
String uid = result.getUID();
if ( uid != null && uid.length() > 0 ){
String key2_str = result.getEngine().getId() + ":" + uid;
try{
byte[] sha1 = new SHA1Simple().calculateHash( key2_str.getBytes( "UTF-8" ));
key2 = new byte[10];
System.arraycopy( sha1, 0, key2, 0, 10 );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
}
protected
SubscriptionResultImpl(
SubscriptionHistoryImpl _history,
Map map )
{
history = _history;
key1 = (byte[])map.get( "key" );
key2 = (byte[])map.get( "key2" );
read = ((Long)map.get( "read")).intValue()==1;
Long l_deleted = (Long)map.get( "deleted" );
if ( l_deleted != null ){
deleted = true;
}else{
try{
result_json = new String((byte[])map.get( "result_json" ), "UTF-8" );
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
}
protected boolean
updateFrom(
SubscriptionResultImpl other )
{
if ( deleted ){
return( false );
}
if ( getJSON().equals( other.getJSON())){
return( false );
}else{
key2 = other.getKey2();
result_json = other.getJSON();
return( true );
}
}
public String
getID()
{
return( Base32.encode( key1 ));
}
protected byte[]
getKey1()
{
return( key1 );
}
protected byte[]
getKey2()
{
return( key2 );
}
public boolean
getRead()
{
return( read );
}
public void
setRead(
boolean _read )
{
if ( read != _read ){
read = _read;
history.updateResult( this );
}
}
protected void
setReadInternal(
boolean _read )
{
read = _read;
}
public void
delete()
{
if ( !deleted ){
deleted = true;
history.updateResult( this );
}
}
protected void
deleteInternal()
{
deleted = true;
}
public boolean
isDeleted()
{
return( deleted );
}
protected Map
toBEncodedMap()
{
Map map = new HashMap();
map.put( "key", key1 );
if ( key2 != null ){
map.put( "key2", key2 );
}
map.put( "read", new Long(read?1:0));
if ( deleted ){
map.put( "deleted", new Long(1));
}else{
try{
map.put( "result_json", result_json.getBytes( "UTF-8" ));
}catch( Throwable e ){
Debug.printStackTrace(e);
}
}
return( map );
}
public Map
toJSONMap()
{
Map map = JSONUtils.decodeJSON( result_json );
map.put( "subs_is_read", new Boolean( read ));
map.put( "subs_id", getID());
Result.adjustRelativeTerms( map );
// migration - trim digits
String size = (String)map.get( "l" );
if ( size != null ){
size = DisplayFormatters.trimDigits( size, 3 );
map.put( "l", size );
}
return( map );
}
private String
getJSON()
{
return( result_json );
}
public String
getDownloadLink()
{
Map map = toJSONMap();
String link = (String)map.get( "dbl" );
if ( link == null ){
link = (String)map.get( "dl" );
}
return( link );
}
public String
getPlayLink()
{
return((String)toJSONMap().get( "pl" ));
}
public String
getAssetHash()
{
return((String)toJSONMap().get( "h" ));
}
public Map<Integer,Object>
toPropertyMap()
{
Map map = toJSONMap();
Map<Integer,Object> result = new HashMap<Integer, Object>();
String title = (String)map.get( "n" );
result.put( SearchResult.PR_UID, getID());
result.put( SearchResult.PR_NAME, title );
String pub_date = (String)map.get( "ts" );
if ( pub_date != null ){
result.put( SearchResult.PR_PUB_DATE, new Date( Long.parseLong( pub_date )));
}
String size = (String)map.get( "lb" );
if ( size != null ){
result.put( SearchResult.PR_SIZE, Long.parseLong( size ));
}
String link = (String)map.get( "dbl" );
if ( link == null ){
link = (String)map.get( "dl" );
}
if ( link != null ){
result.put( SearchResult.PR_DOWNLOAD_LINK, link );
}
String hash = (String)map.get( "h" );
if ( hash != null ){
result.put( SearchResult.PR_HASH, Base32.decode( hash ));
}
String seeds = (String)map.get( "s" );
if ( seeds != null ){
result.put( SearchResult.PR_SEED_COUNT, Long.parseLong(seeds) );
}
String peers = (String)map.get( "p" );
if ( peers != null ){
result.put( SearchResult.PR_LEECHER_COUNT, Long.parseLong(peers) );
}
String rank = (String)map.get( "r" );
if ( rank != null ){
result.put( SearchResult.PR_RANK, (long)(100*Float.parseFloat( rank )));
}
return( result );
}
}
|
thangbn/Direct-File-Downloader
|
src/src/com/aelitis/azureus/core/subs/impl/SubscriptionResultImpl.java
|
Java
|
gpl-2.0
| 6,643
|
/**
* @version 1.5.x
* @package ZooTemplate Project
* @email webmaster@zootemplate.com
* @copyright (C) 2011 http://www.ZooTemplate.com. All rights reserved.
*/
a {
color: #0592cc;
}
a:hover,
a:active,
a:focus {
color: #0592cc;
}
#zt-logo{
background:url('../../images/colors/blue/logo.png') no-repeat left top;
}
#zt-header {
background:#dcdcdc url("../../images/colors/blue/bg-header.png") repeat-x left bottom;
}
.button {
background:#47d0f2;
border: 1px solid #2599ca;
}
#zt-footer-menu li a {
color: #0592cc;
}
#zt-userwrap5-inner .button {
background:#0592cc !important;
border: 1px solid #2599ca !important;
}
ul#mainlevel li a:hover,
ul.menu li a:hover {
color:#0592cc;
text-decoration:none;
background:url('../../images/colors/blue/arrow-hover.png') no-repeat left 50%;
}
#zt-userwrap5-inner ul li a:hover{
color:#0592cc;
}
.rtl ul#mainlevel li a:hover,
.rtl ul.menu li a:hover {
background:url('../../images/colors/blue/arrow-hover.png') no-repeat right 50%;
}
ul.menu2 li a:hover {
background: url("../../images/colors/blue/arrow-hover.png") no-repeat scroll left 50%;
}
.rtl ul.menu2 li a:hover {
background: url("../../images/colors/blue/arrow-hover.png") no-repeat scroll right 50%;
}
a.readon2 {
background: url("../../images/readon2.png") no-repeat left top;
}
a.readon2 span {
background: url("../../images/readon2.png") no-repeat right -46px;
}
.readon3 {
background: url("../../images/colors/blue/bg-readmore2.png") no-repeat right 50%;
color: #0592cc;
}
#zt-col3 div.latestnewsitems h4 a:hover {
color: #0592cc;
}
#zt-slideshow-inner .handles .active {
background: url("../../images/colors/blue/handles-active.png") no-repeat left top;
}
a.readon {
background: url("../../images/colors/blue/readon.png") no-repeat left top;
}
a.readon span {
background: url("../../images/colors/blue/readon.png") no-repeat right -46px;
}
#menusys_mega li:hover a,
#menusys_mega li:active a,
#menusys_mega li:focus a,
#menusys_mega li a.active,
#menusys_mega li a.active:hover,
#menusys_mega li a.active:active,
#menusys_mega li a.active:focus {
background:url('../../images/colors/blue/bg-menu-active.png') no-repeat left 0;
}
#menusys_mega li:hover a .menu-title,
#menusys_mega li:active a .menu-title,
#menusys_mega li:focus a .menu-title,
#menusys_mega li a.active .menu-title,
#menusys_mega li a.active:hover .menu-title,
#menusys_mega li a.active:active .menu-title,
#menusys_mega li a.active:focus .menu-title {
background:url('../../images/colors/blue/bg-menu-active.png') no-repeat right -46px;
}
#menusys_mega .subarrowtop {
background: url("../../images/colors/blue/megamenu/arrow.png") no-repeat left top;
}
#menusys_mega .subwraptop {
background: url("../../images/colors/blue/megamenu/top-center.png") repeat-x left top;
}
#menusys_mega .subwraptop .subwraptop-left {
background: url("../../images/colors/blue/megamenu/top-left.png") no-repeat left top;
}
#menusys_mega .subwraptop .subwraptop-right {
background: url("../../images/colors/blue/megamenu/top-right.png") no-repeat right top;
}
#menusys_mega .subwrapcenter {
background: url("../../images/colors/blue/megamenu/mid-center.png") repeat-x left top #35b7e9;
}
#menusys_mega .subwrapbottom .subwrapbottom-left {
background: url("../../images/colors/blue/megamenu/bot-left.png") no-repeat left top;
}
#menusys_mega .subwrapbottom .subwrapbottom-right {
background: url("../../images/colors/blue/megamenu/bot-right.png") no-repeat right top;
}
#menusys_mega .subwrapbottom {
background: url("../../images/colors/blue/megamenu/bot-center.png") repeat-x left top;
}
#menusys_mega .megacol ul li {
background: url("../../images/colors/blue/megamenu/bg-list-button.png") repeat-x left bottom;
}
#menusys_mega .mega-group .no-image{
background: url("../../images/colors/blue/megamenu/bg-list-button.png") repeat-x left bottom;
}
#menusys_mega .megacol ul li a span.no-image {
background: url("../../images/colors/blue/megamenu/arrow2.png") no-repeat 0 50%;
}
#menusys_mega .megacol ul li a:hover span.no-image,
#menusys_mega .megacol ul li a:active span.no-image,
#menusys_mega .megacol ul li a:focus span.no-image,
#menusys_mega .megacol ul li a.active span.no-image,
#menusys_mega .megacol ul li a.active:hover span.no-image,
#menusys_mega .megacol ul li a.active:active span.no-image,
#menusys_mega .megacol ul li a.active:focus span.no-image {
background: url("../../images/colors/blue/megamenu/arrow2-hover.png") no-repeat left 50%;
}
#menusys_mega div.items .item {
background: url("../../images/colors/blue/megamenu/bg-list-button.png") repeat-x left bottom;
}
#menusys_mega div.items .item:hover {
background: url("../../images/colors/blue/megamenu/bg-list-button.png") repeat-x left bottom #43bceb;
}
#menusys_mega div.items .item .caption {
background:#9ADBF4;
}
/*right to left*/
.rtl #menusys_mega .megacol ul li a span.no-image {
background: url("../../images/colors/blue/megamenu/arrow2.png") no-repeat right 50%;
}
.rtl #menusys_mega .megacol ul li a:hover span.no-image,
.rtl #menusys_mega .megacol ul li a:active span.no-image,
.rtl #menusys_mega .megacol ul li a:focus span.no-image,
.rtl #menusys_mega .megacol ul li a.active span.no-image,
.rtl #menusys_mega .megacol ul li a.active:hover span.no-image,
.rtl #menusys_mega .megacol ul li a.active:active span.no-image,
.rtl #menusys_mega .megacol ul li a.active:focus span.no-image{
background:url("../../images/colors/blue/megamenu/arrow2-hover.png") no-repeat right 50%;
}
#zt-slideshow-inner .jvcarousel_mtitle {
color: #0D9FDC;
}
#zt-col1 .free {
background: url("../../images/colors/blue/bg-free.png") no-repeat left top;
}
|
yuri12015/leluan
|
templates/zt_meda25/css/colors/blue.css
|
CSS
|
gpl-2.0
| 5,685
|
<?php
/**
* PHPMailer SPL autoloader.
* PHP Version 5
* @package PHPMailer
* @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project
* @author Marcus Bointon (Synchro/coolbru) <phpmailer@synchromedia.co.uk>
* @author Jim Jagielski (jimjag) <jimjag@gmail.com>
* @author Andy Prevost (codeworxtech) <codeworxtech@users.sourceforge.net>
* @author Brent R. Matzelle (original founder)
* @copyright 2012 - 2014 Marcus Bointon
* @copyright 2010 - 2012 Jim Jagielski
* @copyright 2004 - 2009 Andy Prevost
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
* @note This program is distributed in the hope that it will be useful - WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* PHPMailer SPL autoloader.
* @param string $classname The name of the class to load
*/
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
function PHPMailerAutoload($classname)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
var_dump(__FILE__);
if (is_readable($filename)) {
require $filename;
}
}
|
KarelWintersky/kwLiveMap
|
backend/phpauth/PHPMailer/PHPMailerAutoload.php
|
PHP
|
gpl-2.0
| 1,708
|
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef __INCLUDE_BBU_H
#define __INCLUDE_BBU_H
#include <asm-generic/errno.h>
#include <linux/list.h>
#include <linux/types.h>
#include <filetype.h>
struct bbu_data {
#define BBU_FLAG_FORCE (1 << 0)
#define BBU_FLAG_YES (1 << 1)
unsigned long flags;
int force;
const void *image;
const char *imagefile;
const char *devicefile;
size_t len;
const char *handler_name;
const struct imd_header *imd_data;
};
struct bbu_handler {
int (*handler)(struct bbu_handler *, struct bbu_data *);
const char *name;
struct list_head list;
#define BBU_HANDLER_FLAG_DEFAULT (1 << 0)
#define BBU_HANDLER_CAN_REFRESH (1 << 1)
/*
* The lower 16bit are generic flags, the upper 16bit are reserved
* for handler specific flags.
*/
unsigned long flags;
/* default device file, can be overwritten on the command line */
const char *devicefile;
};
int bbu_force(struct bbu_data *, const char *fmt, ...)
__attribute__ ((format(__printf__, 2, 3)));
int bbu_confirm(struct bbu_data *);
int barebox_update(struct bbu_data *, struct bbu_handler *);
struct bbu_handler *bbu_find_handler_by_name(const char *name);
struct bbu_handler *bbu_find_handler_by_device(const char *devicepath);
void bbu_handlers_list(void);
int bbu_handlers_iterate(int (*fn)(struct bbu_handler *, void *), void *);
#ifdef CONFIG_BAREBOX_UPDATE
int bbu_register_handler(struct bbu_handler *);
int bbu_register_std_file_update(const char *name, unsigned long flags,
const char *devicefile, enum filetype imagetype);
#else
static inline int bbu_register_handler(struct bbu_handler *unused)
{
return -EINVAL;
}
static inline int bbu_register_std_file_update(const char *name, unsigned long flags,
const char *devicefile, enum filetype imagetype)
{
return -ENOSYS;
}
#endif
#if defined(CONFIG_BAREBOX_UPDATE_IMX_NAND_FCB)
int imx6_bbu_nand_register_handler(const char *name, unsigned long flags);
int imx28_bbu_nand_register_handler(const char *name, unsigned long flags);
#else
static inline int imx6_bbu_nand_register_handler(const char *name, unsigned long flags)
{
return -ENOSYS;
}
static inline int imx28_bbu_nand_register_handler(const char *name, unsigned long flags)
{
return -ENOSYS;
}
#endif
#endif /* __INCLUDE_BBU_H */
|
masahir0y/barebox-yamada
|
include/bbu.h
|
C
|
gpl-2.0
| 2,264
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Source code</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<div class="sourceContainer">
<pre><span class="sourceLineNo">001</span>/* ===========================================================<a name="line.1"></a>
<span class="sourceLineNo">002</span> * JFreeChart : a free chart library for the Java(tm) platform<a name="line.2"></a>
<span class="sourceLineNo">003</span> * ===========================================================<a name="line.3"></a>
<span class="sourceLineNo">004</span> *<a name="line.4"></a>
<span class="sourceLineNo">005</span> * (C) Copyright 2000-2011, by Object Refinery Limited and Contributors.<a name="line.5"></a>
<span class="sourceLineNo">006</span> *<a name="line.6"></a>
<span class="sourceLineNo">007</span> * Project Info: http://www.jfree.org/jfreechart/index.html<a name="line.7"></a>
<span class="sourceLineNo">008</span> *<a name="line.8"></a>
<span class="sourceLineNo">009</span> * This library is free software; you can redistribute it and/or modify it<a name="line.9"></a>
<span class="sourceLineNo">010</span> * under the terms of the GNU Lesser General Public License as published by<a name="line.10"></a>
<span class="sourceLineNo">011</span> * the Free Software Foundation; either version 2.1 of the License, or<a name="line.11"></a>
<span class="sourceLineNo">012</span> * (at your option) any later version.<a name="line.12"></a>
<span class="sourceLineNo">013</span> *<a name="line.13"></a>
<span class="sourceLineNo">014</span> * This library is distributed in the hope that it will be useful, but<a name="line.14"></a>
<span class="sourceLineNo">015</span> * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY<a name="line.15"></a>
<span class="sourceLineNo">016</span> * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public<a name="line.16"></a>
<span class="sourceLineNo">017</span> * License for more details.<a name="line.17"></a>
<span class="sourceLineNo">018</span> *<a name="line.18"></a>
<span class="sourceLineNo">019</span> * You should have received a copy of the GNU Lesser General Public<a name="line.19"></a>
<span class="sourceLineNo">020</span> * License along with this library; if not, write to the Free Software<a name="line.20"></a>
<span class="sourceLineNo">021</span> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,<a name="line.21"></a>
<span class="sourceLineNo">022</span> * USA.<a name="line.22"></a>
<span class="sourceLineNo">023</span> *<a name="line.23"></a>
<span class="sourceLineNo">024</span> * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. <a name="line.24"></a>
<span class="sourceLineNo">025</span> * Other names may be trademarks of their respective owners.]<a name="line.25"></a>
<span class="sourceLineNo">026</span> *<a name="line.26"></a>
<span class="sourceLineNo">027</span> * ----------------<a name="line.27"></a>
<span class="sourceLineNo">028</span> * DatasetTags.java<a name="line.28"></a>
<span class="sourceLineNo">029</span> * ----------------<a name="line.29"></a>
<span class="sourceLineNo">030</span> * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.<a name="line.30"></a>
<span class="sourceLineNo">031</span> *<a name="line.31"></a>
<span class="sourceLineNo">032</span> * Original Author: David Gilbert (for Object Refinery Limited);<a name="line.32"></a>
<span class="sourceLineNo">033</span> * Contributor(s): -;<a name="line.33"></a>
<span class="sourceLineNo">034</span> *<a name="line.34"></a>
<span class="sourceLineNo">035</span> * Changes<a name="line.35"></a>
<span class="sourceLineNo">036</span> * -------<a name="line.36"></a>
<span class="sourceLineNo">037</span> * 23-Jan-2003 : Version 1 (DG);<a name="line.37"></a>
<span class="sourceLineNo">038</span> *<a name="line.38"></a>
<span class="sourceLineNo">039</span> */<a name="line.39"></a>
<span class="sourceLineNo">040</span><a name="line.40"></a>
<span class="sourceLineNo">041</span>package org.jfree.data.xml;<a name="line.41"></a>
<span class="sourceLineNo">042</span><a name="line.42"></a>
<span class="sourceLineNo">043</span>/**<a name="line.43"></a>
<span class="sourceLineNo">044</span> * Constants for the tags that identify the elements in the XML files.<a name="line.44"></a>
<span class="sourceLineNo">045</span> */<a name="line.45"></a>
<span class="sourceLineNo">046</span>public interface DatasetTags {<a name="line.46"></a>
<span class="sourceLineNo">047</span><a name="line.47"></a>
<span class="sourceLineNo">048</span> /** The 'PieDataset' element name. */<a name="line.48"></a>
<span class="sourceLineNo">049</span> public static final String PIEDATASET_TAG = "PieDataset";<a name="line.49"></a>
<span class="sourceLineNo">050</span><a name="line.50"></a>
<span class="sourceLineNo">051</span> /** The 'CategoryDataset' element name. */<a name="line.51"></a>
<span class="sourceLineNo">052</span> public static final String CATEGORYDATASET_TAG = "CategoryDataset";<a name="line.52"></a>
<span class="sourceLineNo">053</span><a name="line.53"></a>
<span class="sourceLineNo">054</span> /** The 'Series' element name. */<a name="line.54"></a>
<span class="sourceLineNo">055</span> public static final String SERIES_TAG = "Series";<a name="line.55"></a>
<span class="sourceLineNo">056</span><a name="line.56"></a>
<span class="sourceLineNo">057</span> /** The 'Item' element name. */<a name="line.57"></a>
<span class="sourceLineNo">058</span> public static final String ITEM_TAG = "Item";<a name="line.58"></a>
<span class="sourceLineNo">059</span><a name="line.59"></a>
<span class="sourceLineNo">060</span> /** The 'Key' element name. */<a name="line.60"></a>
<span class="sourceLineNo">061</span> public static final String KEY_TAG = "Key";<a name="line.61"></a>
<span class="sourceLineNo">062</span><a name="line.62"></a>
<span class="sourceLineNo">063</span> /** The 'Value' element name. */<a name="line.63"></a>
<span class="sourceLineNo">064</span> public static final String VALUE_TAG = "Value";<a name="line.64"></a>
<span class="sourceLineNo">065</span><a name="line.65"></a>
<span class="sourceLineNo">066</span>}<a name="line.66"></a>
</pre>
</div>
</body>
</html>
|
jclazzarim/TrabalhoPID2013
|
Trabalho PID2013/libs/jfreechart-1.0.14-javadocs/src-html/org/jfree/data/xml/DatasetTags.html
|
HTML
|
gpl-2.0
| 6,507
|
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Clippers lose by 3 against Chris Paul and the Grizzlies, 87-90</title>
<link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<body>
<h1>Clippers lose by 3 against Chris Paul and the Grizzlies, 87-90</h1>
</br>
<h2 style="color:gray">by NBANLP Recap Generator</h2>
</br></br>
<img src="../img/12/01.jpg" alt="No image loaded" align="right" style="height:50%; width:50%;margin-left:20px;margin-bottom:20px;">
<p>Chris Paul contributed well to the Clippers total, recording 26 points. Mike Conley had a great game, scoring 18 points for the Grizzlies. Chris Paul recorded 26 points and 10 assists in a great overall game.</p>
<p>Chris made contributions in scoring with 26 points for the Clippers. Paul got 10 assists and 4 rebounds for the Clippers.</p>
<p>Mike made contributions in scoring with 18 points for the Grizzlies. Conley contributed 7 assists and 3 rebounds.</p>
<p>Chris led the Clippers with 26 points, 10 assists, and 4 rebounds.</p>
<p>This result puts Clippers at 37-20 for the season, while the Grizzlies are 41-14. The Grizzlies continue their great streak, winning 2 of 2.</p>
<p>Jeff Green and Marc Gasol combined for 26 points. Each scoring 14 and 12 points respectively. Green contributed 2 assists and 6 rebounds for the Grizzlies. Gasol contributed 4 assists and 6 rebounds for the Grizzlies.
Zach Randolph put in 7 points. Randolph contributed 2 assists and 10 rebounds for the Grizzlies.
Jamal Crawford and DeAndre Jordan totaled 22 points for the Clippers, putting up 15 and 7 points respectively. Crawford contributed 2 assists and 3 rebounds for the Clippers. Jordan recorded 1 assists and 17 rebounds for the Clippers.</p>
</body>
</html>
|
jacobbustamante/NBANLPRecap
|
web/2014_season/2015022312.html
|
HTML
|
gpl-2.0
| 1,807
|
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://lammps.sandia.gov/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(zbl/gpu,PairZBLGPU)
#else
#ifndef LMP_PAIR_ZBL_GPU_H
#define LMP_PAIR_ZBL_GPU_H
#include "pair_zbl.h"
namespace LAMMPS_NS {
class PairZBLGPU : public PairZBL {
public:
PairZBLGPU(LAMMPS *lmp);
~PairZBLGPU();
void cpu_compute(int, int, int, int, int *, int *, int **);
void compute(int, int);
void init_style();
double memory_usage();
enum { GPU_FORCE, GPU_NEIGH, GPU_HYB_NEIGH };
private:
int gpu_mode;
double cpu_time;
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: Insufficient memory on accelerator
There is insufficient memory on one of the devices specified for the gpu
package
E: Cannot use newton pair with zbl/gpu pair style
Self-explanatory.
*/
|
rbberger/lammps
|
src/GPU/pair_zbl_gpu.h
|
C
|
gpl-2.0
| 1,348
|
;****************************************************************************
;*
;* SciTech OS Portability Manager Library
;*
;* ========================================================================
;*
;* Copyright (C) 1991-2004 SciTech Software, Inc. All rights reserved.
;*
;* This file may be distributed and/or modified under the terms of the
;* GNU General Public License version 2.0 as published by the Free
;* Software Foundation and appearing in the file LICENSE.GPL included
;* in the packaging of this file.
;*
;* Licensees holding a valid Commercial License for this product from
;* SciTech Software, Inc. may use this file in accordance with the
;* Commercial License Agreement provided with the Software.
;*
;* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
;* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
;* PURPOSE.
;*
;* See http://www.scitechsoft.com/license/ for information about
;* the licensing options available and how to purchase a Commercial
;* License Agreement.
;*
;* Contact license@scitechsoft.com if any conditions of this licensing
;* are not clear to you, or you have questions about licensing options.
;*
;* ========================================================================
;*
;* Language: NASM
;* Environment: IBM PC (MS DOS)
;*
;* Description: Uses the 8253 timer and the BIOS time-of-day count to time
;* the performance of code that takes less than an hour to
;* execute.
;*
;* The routines in this package only works with interrupts
;* enabled, and in fact will explicitly turn interrupts on
;* in order to ensure we get accurate results from the timer.
;*
;* Externally 'C' callable routines:
;*
;* LZ_timerOn: Saves the BIOS time of day count and starts the
;* long period Zen Timer.
;*
;* LZ_timerLap: Latches the current count, and keeps the timer running
;*
;* LZ_timerOff: Stops the long-period Zen Timer and saves the timer
;* count and the BIOS time of day count.
;*
;* LZ_timerCount: Returns an unsigned long representing the timed count
;* in microseconds. If more than an hour passed during
;* the timing interval, LZ_timerCount will return the
;* value 0xFFFFFFFF (an invalid count).
;*
;* Note: If either more than an hour passes between calls to LZ_timerOn
;* and LZ_timerOff, an error is reported. For timing code that takes
;* more than a few minutes to execute, use the low resolution
;* Ultra Long Period Zen Timer code, which should be accurate
;* enough for most purposes.
;*
;* Note: Each block of code being timed should ideally be run several
;* times, with at least two similar readings required to
;* establish a true measurement, in order to eliminate any
;* variability caused by interrupts.
;*
;* Note: Interrupts must not be disabled for more than 54 ms at a
;* stretch during the timing interval. Because interrupts are
;* enabled, key, mice, and other devices that generate interrupts
;* should not be used during the timing interval.
;*
;* Note: Any extra code running off the timer interrupt (such as
;* some memory resident utilities) will increase the time
;* measured by the Zen Timer.
;*
;* Note: These routines can introduce inaccuracies of up to a few
;* tenths of a second into the system clock count for each
;* code section being timed. Consequently, it's a good idea to
;* reboot at the conclusion of timing sessions. (The
;* battery-backed clock, if any, is not affected by the Zen
;* timer.)
;*
;* All registers and all flags are preserved by all routines, except
;* interrupts which are always turned on
;*
;****************************************************************************
include "scitech.mac"
;****************************************************************************
;
; Equates used by long period Zen Timer
;
;****************************************************************************
; Base address of 8253 timer chip
BASE_8253 equ 40h
; The address of the timer 0 count registers in the 8253
TIMER_0_8253 equ BASE_8253 + 0
; The address of the mode register in the 8253
MODE_8253 equ BASE_8253 + 3
; The address of the BIOS timer count variable in the BIOS data area.
TIMER_COUNT equ 6Ch
; Macro to delay briefly to ensure that enough time has elapsed between
; successive I/O accesses so that the device being accessed can respond
; to both accesses even on a very fast PC.
%macro DELAY 0
jmp short $+2
jmp short $+2
jmp short $+2
%endmacro
header _lztimer
begdataseg _lztimer
cextern _ZTimerBIOSPtr,DPTR
StartBIOSCount dd 0 ; Starting BIOS count dword
EndBIOSCount dd 0 ; Ending BIOS count dword
EndTimedCount dw 0 ; Timer 0 count at the end of timing period
enddataseg _lztimer
begcodeseg _lztimer ; Start of code segment
;----------------------------------------------------------------------------
; void LZ_timerOn(void);
;----------------------------------------------------------------------------
; Starts the Long period Zen timer counting.
;----------------------------------------------------------------------------
cprocstart LZ_timerOn
; Set the timer 0 of the 8253 to mode 2 (divide-by-N), to cause
; linear counting rather than count-by-two counting. Also stops
; timer 0 until the timer count is loaded, except on PS/2 computers.
mov al,00110100b ; mode 2
out MODE_8253,al
; Set the timer count to 0, so we know we won't get another timer
; interrupt right away. Note: this introduces an inaccuracy of up to 54 ms
; in the system clock count each time it is executed.
DELAY
sub al,al
out TIMER_0_8253,al ; lsb
DELAY
out TIMER_0_8253,al ; msb
; Store the timing start BIOS count
use_es
ifdef flatmodel
mov ebx,[_ZTimerBIOSPtr]
else
les bx,[_ZTimerBIOSPtr]
endif
cli ; No interrupts while we grab the count
mov eax,[_ES _bx+TIMER_COUNT]
sti
mov [StartBIOSCount],eax
unuse_es
; Set the timer count to 0 again to start the timing interval.
mov al,00110100b ; set up to load initial
out MODE_8253,al ; timer count
DELAY
sub al,al
out TIMER_0_8253,al ; load count lsb
DELAY
out TIMER_0_8253,al ; load count msb
ret
cprocend
;----------------------------------------------------------------------------
; void LZ_timerOff(void);
;----------------------------------------------------------------------------
; Stops the long period Zen timer and saves count.
;----------------------------------------------------------------------------
cprocstart LZ_timerOff
; Latch the timer count.
mov al,00000000b ; latch timer 0
out MODE_8253,al
cli ; Stop the BIOS count
; Read the BIOS count. (Since interrupts are disabled, the BIOS
; count won't change).
use_es
ifdef flatmodel
mov ebx,[_ZTimerBIOSPtr]
else
les bx,[_ZTimerBIOSPtr]
endif
mov eax,[_ES _bx+TIMER_COUNT]
mov [EndBIOSCount],eax
unuse_es
; Read out the count we latched earlier.
in al,TIMER_0_8253 ; least significant byte
DELAY
mov ah,al
in al,TIMER_0_8253 ; most significant byte
xchg ah,al
neg ax ; Convert from countdown remaining
; to elapsed count
mov [EndTimedCount],ax
sti ; Let the BIOS count continue
ret
cprocend
;----------------------------------------------------------------------------
; unsigned long LZ_timerLap(void)
;----------------------------------------------------------------------------
; Latches the current count and converts it to a microsecond timing value,
; but leaves the timer still running. We dont check for and overflow,
; where the time has gone over an hour in this routine, since we want it
; to execute as fast as possible.
;----------------------------------------------------------------------------
cprocstart LZ_timerLap
push ebx ; Save EBX for 32 bit code
; Latch the timer count.
mov al,00000000b ; latch timer 0
out MODE_8253,al
cli ; Stop the BIOS count
; Read the BIOS count. (Since interrupts are disabled, the BIOS
; count wont change).
use_es
ifdef flatmodel
mov ebx,[_ZTimerBIOSPtr]
else
les bx,[_ZTimerBIOSPtr]
endif
mov eax,[_ES _bx+TIMER_COUNT]
mov [EndBIOSCount],eax
unuse_es
; Read out the count we latched earlier.
in al,TIMER_0_8253 ; least significant byte
DELAY
mov ah,al
in al,TIMER_0_8253 ; most significant byte
xchg ah,al
neg ax ; Convert from countdown remaining
; to elapsed count
mov [EndTimedCount],ax
sti ; Let the BIOS count continue
; See if a midnight boundary has passed and adjust the finishing BIOS
; count by the number of ticks in 24 hours. We wont be able to detect
; more than 24 hours, but at least we can time across a midnight
; boundary
mov eax,[EndBIOSCount] ; Is end < start?
cmp eax,[StartBIOSCount]
jae @@CalcBIOSTime ; No, calculate the time taken
; Adjust the finishing time by adding the number of ticks in 24 hours
; (1573040).
add [DWORD EndBIOSCount],1800B0h
; Convert the BIOS time to microseconds
@@CalcBIOSTime:
mov ax,[EndBIOSCount]
sub ax,[StartBIOSCount]
mov dx,54925 ; Number of microseconds each
; BIOS count represents.
mul dx
mov bx,ax ; set aside BIOS count in
mov cx,dx ; microseconds
; Convert timer count to microseconds
push _si
mov ax,[EndTimedCount]
mov si,8381
mul si
mov si,10000
div si ; * 0.8381 = * 8381 / 10000
pop _si
; Add the timer and BIOS counts together to get an overall time in
; microseconds.
add ax,bx
adc cx,0
ifdef flatmodel
shl ecx,16
mov cx,ax
mov eax,ecx ; EAX := timer count
else
mov dx,cx
endif
pop ebx ; Restore EBX for 32 bit code
ret
cprocend
;----------------------------------------------------------------------------
; unsigned long LZ_timerCount(void);
;----------------------------------------------------------------------------
; Returns an unsigned long representing the net time in microseconds.
;
; If an hour has passed while timing, we return 0xFFFFFFFF as the count
; (which is not a possible count in itself).
;----------------------------------------------------------------------------
cprocstart LZ_timerCount
push ebx ; Save EBX for 32 bit code
; See if a midnight boundary has passed and adjust the finishing BIOS
; count by the number of ticks in 24 hours. We wont be able to detect
; more than 24 hours, but at least we can time across a midnight
; boundary
mov eax,[EndBIOSCount] ; Is end < start?
cmp eax,[StartBIOSCount]
jae @@CheckForHour ; No, check for hour passing
; Adjust the finishing time by adding the number of ticks in 24 hours
; (1573040).
add [DWORD EndBIOSCount],1800B0h
; See if more than an hour passed during timing. If so, notify the user.
@@CheckForHour:
mov ax,[StartBIOSCount+2]
cmp ax,[EndBIOSCount+2]
jz @@CalcBIOSTime ; Hour count didn't change, so
; everything is fine
inc ax
cmp ax,[EndBIOSCount+2]
jnz @@TestTooLong ; Two hour boundaries passed, so the
; results are no good
mov ax,[EndBIOSCount]
cmp ax,[StartBIOSCount]
jb @@CalcBIOSTime ; a single hour boundary passed. That's
; OK, so long as the total time wasn't
; more than an hour.
; Over an hour elapsed passed during timing, which renders
; the results invalid. Notify the user. This misses the case where a
; multiple of 24 hours has passed, but we'll rely on the perspicacity of
; the user to detect that case :-).
@@TestTooLong:
ifdef flatmodel
mov eax,0FFFFFFFFh
else
mov ax,0FFFFh
mov dx,0FFFFh
endif
jmp short @@Done
; Convert the BIOS time to microseconds
@@CalcBIOSTime:
mov ax,[EndBIOSCount]
sub ax,[StartBIOSCount]
mov dx,54925 ; Number of microseconds each
; BIOS count represents.
mul dx
mov bx,ax ; set aside BIOS count in
mov cx,dx ; microseconds
; Convert timer count to microseconds
push _si
mov ax,[EndTimedCount]
mov si,8381
mul si
mov si,10000
div si ; * 0.8381 = * 8381 / 10000
pop _si
; Add the timer and BIOS counts together to get an overall time in
; microseconds.
add ax,bx
adc cx,0
ifdef flatmodel
shl ecx,16
mov cx,ax
mov eax,ecx ; EAX := timer count
else
mov dx,cx
endif
@@Done: pop ebx ; Restore EBX for 32 bit code
ret
cprocend
cprocstart LZ_disable
cli
ret
cprocend
cprocstart LZ_enable
sti
ret
cprocend
endcodeseg _lztimer
END
|
OS2World/DEV-UTIL-SNAP
|
src/pm/dos/_lztimer.asm
|
Assembly
|
gpl-2.0
| 14,549
|
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
string s1;
int x;
cout << "\n Enter something: ";
cin >> s1;
cout << atoi(s1.c_str());
cout << endl;
return 0;
}
|
DragonFerocity/Data-Structures
|
cs1510/Misc/atoiTest.cpp
|
C++
|
gpl-2.0
| 225
|
jQuery(document).ready(function(jQuery){
jQuery( '.ninja-forms-mp-page' ).each( function() {
if ( jQuery( this ).is( ":visible" ) ) {
var page = jQuery( this ).attr( 'rel' );
jQuery( this ).parent().parent().find( "[name='_current_page']" ).val( page );
}
});
jQuery(".ninja-forms-form").on("submitResponse", function(e, response){
var form_id = response.form_id;
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
if ( typeof mp_settings !== 'undefined' ) {
return ninja_forms_mp_confirm_error_check( response );
}
return true;
});
jQuery(".ninja-forms-form").on("submitResponse", function(e, response){
var form_id = response.form_id;
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
var action = jQuery( document ).data( 'submit_action' );
if ( typeof mp_settings !== 'undefined' && action == 'submit' ) {
return ninja_forms_error_change_page( response );
}
return true;
});
jQuery(".ninja-forms-form").on("beforeSubmit", function(e, formData, jqForm, options){
// if ( jQuery( document ).data( 'mp_submit' ) == 1 ) {
// jQuery( document ).data( 'submit_action', 'mp_submit' );
// jQuery( document ).data( 'mp_submit', 0 );
// }
var form_id = jQuery(jqForm).find("#_form_id").val();
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
if ( typeof mp_settings !== 'undefined' ) {
return ninja_forms_before_submit_update_progressbar( formData, jqForm, options );
}
return true;
});
jQuery(document).on( 'click', '.ninja-forms-mp-confirm-nav', function(e){
var form_id = ninja_forms_get_form_id( this );
jQuery("#ninja_forms_form_" + form_id + "_all_fields_wrap").show();
jQuery("#ninja_forms_form_" + form_id + "_mp_breadcrumbs").show();
jQuery("#ninja_forms_form_" + form_id + "_progress_bar").show();
jQuery("#ninja_forms_form_" + form_id + "_save_progress").show();
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
js_transition = mp_settings.js_transition;
if( js_transition == 1 ){
e.preventDefault();
var current_page = jQuery("[name='_current_page']").val();
current_page = parseInt(current_page);
var page_count = mp_settings.page_count;
var effect = mp_settings.effect;
var new_page = jQuery(this).attr("rel");
var dir = '';
//Check to see if the new page should be shown
new_page = ninja_forms_mp_page_loop( form_id, new_page, current_page, dir );
if( current_page != new_page ){
ninja_forms_mp_change_page( form_id, current_page, new_page, effect );
ninja_forms_update_progressbar( form_id, new_page );
}
}
jQuery("#ninja_forms_form_" + form_id + "_confirm_response").remove();
jQuery("#ninja_forms_form_" + form_id + "_mp_confirm").val(0);
});
jQuery( document ).on( 'click', '.ninja-forms-mp-nav', function( e ){
//jQuery( document ).data( 'mp_submit', 1 );
var form_id = ninja_forms_get_form_id(this);
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
js_transition = mp_settings.js_transition;
if( js_transition == 1 ){
e.preventDefault();
var current_page = jQuery("[name='_current_page']").val();
current_page = parseInt(current_page);
var page_count = mp_settings.page_count;
var effect = mp_settings.effect;
if( this.name == '_next' ){
var new_page = current_page + 1;
var dir = 'next';
}else if( this.name == '_prev' ){
var new_page = current_page - 1;
var dir = 'prev';
}else{
var new_page = jQuery(this).attr("rel");
}
//Check to see if the new page should be shown
new_page = ninja_forms_mp_page_loop( form_id, new_page, current_page, dir );
if( current_page != new_page ){
if ( typeof tinyMCE !== 'undefined' ) {
// Remove any tinyMCE editor
for( i in tinyMCE.editors ) {
if ( typeof tinyMCE.editors[i].id !== 'undefined' ) {
tinyMCE.editors[i].remove();
}
}
}
ninja_forms_mp_change_page( form_id, current_page, new_page, effect );
ninja_forms_update_progressbar( form_id, new_page );
}
}
});
jQuery(document).on( 'mp_page_change.scroll', function( e, form_id, new_page, old_page ) {
ninja_forms_init_tinyMCE();
ninja_forms_scroll_to_top( form_id );
});
});
function ninja_forms_scroll_to_top( form_id ) {
jQuery('html, body').animate({
scrollTop: jQuery("#ninja_forms_form_" + form_id + "_wrap").offset().top - 300
}, 1000);
}
function ninja_forms_error_change_page(response){
var form_id = response.form_id;
var errors = response.errors;
if( errors != false && typeof response.errors['confirm-submit'] === 'undefined'){
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
var extras = response.extras;
var error_page = extras["_current_page"];
var current_page = jQuery("[name='_current_page']").val();
current_page = parseInt(current_page);
var page_count = mp_settings.page_count;
var effect = mp_settings.effect;
if( error_page != page_count ){
ninja_forms_mp_change_page( form_id, current_page, error_page, effect );
}
ninja_forms_update_progressbar( form_id, error_page );
}
// Show previously hidden response message in order to show errors
jQuery("#ninja_forms_form_" + form_id + "_response_msg").css('display', 'block');
return true;
}
function ninja_forms_mp_change_page( form_id, current_page, new_page, effect ){
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
var effect_direction = mp_settings.direction;
var page_count = mp_settings.page_count;
if( current_page > new_page ){
direction = 'prev';
}else{
direction = 'next';
}
if( effect_direction == 'ltr' ){
if( direction == 'next' ){
var direction_in = 'left';
var direction_out = 'right';
}else{
var direction_in = 'right';
var direction_out = 'left';
}
}else if( effect_direction == 'rtl' ){
if( direction == 'next' ){
var direction_in = 'right';
var direction_out = 'left';
}else{
var direction_in = 'left';
var direction_out = 'right';
}
}else if( effect_direction == 'ttb' ){
if( direction == 'next' ){
var direction_in = 'up';
var direction_out = 'down';
}else{
var direction_in = 'down';
var direction_out = 'up';
}
}else if( effect_direction == 'btt' ){
if( direction == 'next' ){
var direction_in = 'down';
var direction_out = 'up';
}else{
var direction_in = 'up';
var direction_out = 'down';
}
}
jQuery("[name='_current_page']").val(new_page);
if( new_page == 1 ){
jQuery("#ninja_forms_form_" + form_id + "_mp_prev").hide();
jQuery("#ninja_forms_form_" + form_id + "_mp_next").show();
}else if( new_page < page_count ){
jQuery("#ninja_forms_form_" + form_id + "_mp_prev").show();
jQuery("#ninja_forms_form_" + form_id + "_mp_next").show();
}else{
jQuery("#ninja_forms_form_" + form_id + "_mp_prev").show();
jQuery("#ninja_forms_form_" + form_id + "_mp_next").hide();
}
jQuery(".ninja-forms-form-" + form_id + "-mp-page-list-active").addClass("ninja-forms-form-" + form_id + "-mp-page-list-inactive");
jQuery(".ninja-forms-form-" + form_id + "-mp-page-list-active").removeClass("ninja-forms-form-" + form_id + "-mp-page-list-active");
jQuery(".ninja-forms-form-" + form_id + "-mp-page-list-inactive[rel=" + new_page + "]").addClass("ninja-forms-form-" + form_id + "-mp-page-list-active");
jQuery(".ninja-forms-form-" + form_id + "-mp-page-list-inactive[rel=" + new_page + "]").removeClass("ninja-forms-form-" + form_id + "-mp-page-list-inactive");
jQuery("[name='_mp_page_" + new_page + "']").addClass("ninja-forms-form-" + form_id + "-mp-breadcrumb-active");
jQuery("[name='_mp_page_" + new_page + "']").addClass("ninja-forms-mp-breadcrumb-active");
jQuery("[name='_mp_page_" + new_page + "']").removeClass("ninja-forms-form-" + form_id + "-mp-breadcrumb-inactive");
jQuery("[name='_mp_page_" + new_page + "']").removeClass("ninja-forms-mp-breadcrumb-inactive");
jQuery("[name='_mp_page_" + current_page + "']").addClass("ninja-forms-form-" + form_id + "-mp-breadcrumb-inactive");
jQuery("[name='_mp_page_" + current_page + "']").addClass("ninja-forms-mp-breadcrumb-inactive");
jQuery("[name='_mp_page_" + current_page + "']").removeClass("ninja-forms-form-" + form_id + "-mp-breadcrumb-active");
jQuery("[name='_mp_page_" + current_page + "']").removeClass("ninja-forms-mp-breadcrumb-active");
var field_id = jQuery(".ninja-forms-form-" + form_id + "-mp-page-show[rel=" + new_page + "]").prop("id");
// Hide any response messages we might have.
jQuery( "#ninja_forms_form_" + form_id + "_response_msg").hide();
// Disable button clicks.
jQuery( ":submit" ).attr( 'disabled', true );
// run the effect
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + current_page).hide( effect, { direction: direction_out }, 300, function(){
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + new_page).show( effect, { direction: direction_in }, 200, function() {
jQuery(document).triggerHandler( 'mp_page_change', [ form_id, new_page, current_page ] );
// Enable navigation button clicks.
jQuery( ":submit" ).attr( 'disabled', false );
});
});
ninja_forms_toggle_nav( form_id, field_id );
}
function ninja_forms_before_submit_update_progressbar(formData, jqForm, options){
var form_id = jQuery(jqForm).prop("id").replace("ninja_forms_form_", "" );
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
js_transition = mp_settings.js_transition
if ( js_transition == 1 ) {
var current_page = jQuery("[name='_current_page']").val();
current_page = parseInt(current_page);
current_page++;
ninja_forms_update_progressbar( form_id, current_page );
}
}
function ninja_forms_update_progressbar( form_id, current_page ){
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
var page_count = mp_settings.page_count;
if( current_page == 1 ){
var percent = 0;
}else if( current_page == ( page_count + 1 ) ){
percent = 100;
}else{
current_page--;
var percent = current_page / page_count;
percent = Math.ceil( percent * 100 );
}
jQuery("#ninja_forms_form_" + form_id + "_progress_bar").find("span").css( "width", percent + "%" );
}
function ninja_forms_hide_mp_page( pass, target_field, element ){
var form_id = ninja_forms_get_form_id(element);
var page = jQuery("#ninja_forms_field_" + target_field).attr("rel");
if( pass ){
// Check to see if we are on the confirmation page. If we are, show or hide the page rather than the breadcrumb.
if ( jQuery("#mp_confirm_page").val() == 1 ) {
// This is the confirm page, hide the whole page.
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + page).hide();
} else {
//Hide the breadcrumb button for this page.
jQuery("#ninja_forms_field_" + target_field + "_breadcrumb" ).hide();
}
//Set the page visibility value to hidden, or 0.
jQuery("#ninja_forms_field_" + target_field).val(0);
}else{
// Check to see if we are on the confirmation page. If we are, show or hide the page rather than the breadcrumb.
if ( jQuery("#mp_confirm_page").val() == 1 ) {
// This is the confirm page, hide the whole page.
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + page).show();
} else {
//Show the breadcrumb button for this page.
jQuery("#ninja_forms_field_" + target_field + "_breadcrumb" ).show();
}
//Set the page visiblity value to visible, or 1.
jQuery("#ninja_forms_field_" + target_field).val(1);
}
ninja_forms_toggle_nav( form_id, target_field );
}
function ninja_forms_show_mp_page( pass, target_field, element ){
var form_id = ninja_forms_get_form_id(element);
var page = jQuery("#ninja_forms_field_" + target_field).attr("rel");
//console.log('page: ' + page + ' pass: ' + pass );
if( pass ){
// Check to see if we are on the confirmation page. If we are, show or hide the page rather than the breadcrumb.
if ( jQuery("#mp_confirm_page").val() == 1 ) {
// This is the confirm page, hide the whole page.
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + page).show();
} else {
//Hide the breadcrumb button for this page.
jQuery("#ninja_forms_field_" + target_field + "_breadcrumb" ).show();
}
//Set the page visiblity value to visible, or 1.
jQuery("#ninja_forms_field_" + target_field).val(1);
}else{
// Check to see if we are on the confirmation page. If we are, show or hide the page rather than the breadcrumb.
if ( jQuery("#mp_confirm_page").val() == 1 ) {
// This is the confirm page, hide the whole page.
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + page).hide();
} else {
//Hide the breadcrumb button for this page.
jQuery("#ninja_forms_field_" + target_field + "_breadcrumb" ).hide();
}
//Set the page visibility value to hidden, or 0.
jQuery("#ninja_forms_field_" + target_field).val(0);
}
ninja_forms_toggle_nav( form_id, target_field );
}
function ninja_forms_toggle_nav( form_id, target_field ){
if(jQuery(".ninja-forms-form-" + form_id + "-mp-page-list-inactive").length == 0){
//Hide both the next and previous buttons
jQuery("#ninja_forms_form_" + form_id + "_mp_next").hide();
jQuery("#ninja_forms_form_" + form_id + "_mp_prev").hide();
}else{
//Check to see if all the breadcrumbs before this one have been disabled. If they have, remove the previous button.
if( jQuery(".ninja-forms-form-" + form_id + "-mp-page-list-active").parent().prevAll().find(".ninja-forms-form-" + form_id + "-mp-page-list-inactive[value=1]").length == 0){
jQuery("#ninja_forms_form_" + form_id + "_mp_prev").hide();
}else{
jQuery("#ninja_forms_form_" + form_id + "_mp_prev").show();
}
//Check to see if all the breadcrumbs after this one have been disabled. If they have, remove the next button.
if( jQuery(".ninja-forms-form-" + form_id + "-mp-page-list-active").parent().nextAll().find(".ninja-forms-form-" + form_id + "-mp-page-list-inactive[value=1]").length == 0){
jQuery("#ninja_forms_form_" + form_id + "_mp_next").hide();
}else{
jQuery("#ninja_forms_form_" + form_id + "_mp_next").show();
}
}
}
//Function to check whether or not a page should be shown.
function ninja_forms_mp_check_page_conditional( form_id, page ){
if(jQuery(".ninja-forms-form-" + form_id + "-mp-page-show[rel=" + page + "]").val() == 1 ){
return true;
}else{
return false;
}
}
//Function to set the hidden page visibilty element 1
function ninja_forms_mp_set_page_show( form_id, page ){
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + page + "_show").val(1);
}
//Function to set the hidden page visibilty element to 0
function ninja_forms_mp_set_page_hide( form_id, page ){
jQuery("#ninja_forms_form_" + form_id + "_mp_page_" + page + "_show").val(0);
}
//Function to get the page number by element
function ninja_forms_mp_get_page( element ){
var page = jQuery(element).closest('.ninja-forms-mp-page').attr("rel");
return page
}
//Function that loops through all the pages until it finds one that should be shown.
function ninja_forms_mp_page_loop( form_id, new_page, current_page, dir ){
if( typeof window['ninja_forms_form_' + form_id + '_page_loop'] === 'undefined'){
window['ninja_forms_form_' + form_id + '_page_loop'] = 1;
}
var mp_settings = window['ninja_forms_form_' + form_id + '_mp_settings'];
var show = ninja_forms_mp_check_page_conditional( form_id, new_page );
if( !show && window['ninja_forms_form_' + form_id + '_page_loop'] <= mp_settings.page_count ){
if( new_page == mp_settings.page_count ){
dir = 'prev';
}
//If our new page is less than the page count, increase it by one and check for visibility.
if( mp_settings.page_count > 1 ){
if( dir == 'next' ){
if( new_page < mp_settings.page_count ){
current_page++;
new_page++;
}
}else{
current_page--;
new_page = current_page;
}
window['ninja_forms_form_' + form_id + '_page_loop']++;
//This page shouldn't be shown, so loop through the rest of the pages until we find one that should be shown.
new_page = ninja_forms_mp_page_loop( form_id, new_page, current_page, dir );
}else{
new_page = 1;
}
}
window['ninja_forms_form_' + form_id + '_page_loop'] = 1;
return new_page;
}
function ninja_forms_mp_confirm_error_check(response){
if(typeof response.errors['confirm-submit'] !== 'undefined'){
jQuery("#ninja_forms_form_" + response.form_id + "_all_fields_wrap").remove();
jQuery("#ninja_forms_form_" + response.form_id + "_mp_breadcrumbs").hide();
jQuery("#ninja_forms_form_" + response.form_id + "_progress_bar").hide();
jQuery("#ninja_forms_form_" + response.form_id + "_save_progress").hide();
jQuery("#ninja_forms_form_" + response.form_id + "_mp_nav_wrap").hide();
jQuery("#ninja_forms_form_" + response.form_id + "_mp_confirm").val(1);
jQuery("#ninja_forms_form_" + response.form_id).prepend('<div id="ninja_forms_form_' + response.form_id + '_confirm_response">' + response.errors['confirm-submit-msg']['msg'] + '</div>');
ninja_forms_scroll_to_top( response.form_id );
}
return true;
}
function ninja_forms_init_tinyMCE() {
if ( typeof tinyMCE !== 'undefined' ) {
// Remove any tinyMCE editors
var init, edId, qtId, firstInit, wrapper;
if ( typeof tinyMCEPreInit !== 'undefined' ) {
for ( edId in tinyMCEPreInit.mceInit ) {
if ( firstInit ) {
init = tinyMCEPreInit.mceInit[edId] = tinymce.extend( {}, firstInit, tinyMCEPreInit.mceInit[edId] );
} else {
init = firstInit = tinyMCEPreInit.mceInit[edId];
}
wrapper = tinymce.DOM.select( '#wp-' + edId + '-wrap' )[0];
if ( ( tinymce.DOM.hasClass( wrapper, 'tmce-active' ) || ! tinyMCEPreInit.qtInit.hasOwnProperty( edId ) ) &&
! init.wp_skip_init ) {
try {
tinymce.init( init );
if ( ! window.wpActiveEditor ) {
window.wpActiveEditor = edId;
}
} catch(e){}
}
}
}
if ( typeof quicktags !== 'undefined' ) {
for ( qtId in tinyMCEPreInit.qtInit ) {
try {
quicktags( tinyMCEPreInit.qtInit[qtId] );
if ( ! window.wpActiveEditor ) {
window.wpActiveEditor = qtId;
}
} catch(e){};
}
}
if ( typeof jQuery !== 'undefined' ) {
jQuery('.wp-editor-wrap').on( 'click.wp-editor', function() {
if ( this.id ) {
window.wpActiveEditor = this.id.slice( 3, -5 );
}
});
} else {
for ( qtId in tinyMCEPreInit.qtInit ) {
document.getElementById( 'wp-' + qtId + '-wrap' ).onclick = function() {
window.wpActiveEditor = this.id.slice( 3, -5 );
}
}
}
}
}
|
vietlq57/XPOS
|
ninja-forms-multi-part/js/dev/ninja-forms-mp-display.js
|
JavaScript
|
gpl-2.0
| 18,662
|
#!/bin/bash
#
# This script intents to provide a tool
# to send secure (PGP-encrypted) mail.
#
# It can be used to write script that reports via mail.
set -e
WORK_DIR=$(mktemp -d)
# File that contains the whole mail that will passed to sendmail
MAIL_FILE=$WORK_DIR/mail
# File that contains the content and attachments of the mail.
# This file will be encrypted before being sent
CONTENT_MAIL_FILE=$WORK_DIR/content_mail
# Encrypted content
ENCRYPTED_MAIL_FILE=$WORK_DIR/encrypted_mail
touch $ENCRYPTED_MAIL_FILE
PGP_BOUNDARY=qwerty1234_pgp
CONTENT_BOUNDARY=qwerty1243_mail
ASSUME_YES=0
SIGNING_KEY_PASSPHRASE=''
SUBJECT=''
RECIPIENT=''
BODY_FILE=''
FROM=''
ATTACHMENTS=()
SCRIPT_DIR=`dirname "$0"`
source $SCRIPT_DIR/config.sh
source $SCRIPT_DIR/tools.sh
## Print usage and die
## $1 is status code
function usage()
{
echo "Usage: ${0} -r=|--recipient= -f=|--from= -b=|--body= -rk|--recipient-key= \
[-s=|--subject=] [=-p|--passphrase=] [--assume-yes] -- [Attachment file]*"
echo "Recipient of the mail. Only is supported."
echo "Sender of the mail. Must be set"
echo "Path to the file containing the plain/text body of the mail"
echo "GPG key id of recipient"
echo "Passphrase of our signing key"
echo "Subject of mail. This will NOT be encrypted"
echo "If --assume-yes is set, will not ask for confirmation and expect passphrase\
to be set too"
echo "Path to attachements files"
die $1
}
## Write base mail header to the mail file, erasing
## any previous content.
## Thoses state that our mail is a encrypted pgp mail.
function write_clear_header()
{
printf '%s\n' "Subject: ${SUBJECT}
Mime-Version: 1.0
From: ${FROM}
To: ${RECIPIENT}
Content-Type: multipart/encrypted; boundary=$PGP_BOUNDARY; protocol=application/pgp-encrypted;
Content-Transfer-Encoding: 7bit
Content-Description: OpenPGP encrypted message
This is an OpenPGP/MIME encrypted message (RFC 2440 and 3156)
--${PGP_BOUNDARY}
Content-Transfer-Encoding: 7bit
Content-Type: application/pgp-encrypted
Content-Description: PGP/MIME Versions Identification
Version: 1
--${PGP_BOUNDARY}
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-Type: application/octet-stream
Content-Description: OpenPGP encrypted message
" > $MAIL_FILE
}
## Write the body of the mail
## $1 is the path to the file to include in the body.
## It must be a text file.
function write_body()
{
[ -r $1 ] || fail "Body file is not readable: $1"
printf '%s\n' "Content-Type: multipart/mixed; boundary=${CONTENT_BOUNDARY}
--${CONTENT_BOUNDARY}
Content-Type: text/plain; charset=UTF-8
Content-Disposition: inline
" >> $CONTENT_MAIL_FILE
cat $1 >> $CONTENT_MAIL_FILE
}
# Add attachment (will encode in base64) to the CLEAR_MAIL file
# $1 is path to the file
function add_attachment()
{
[ -r $1 ] || fail "attachment file is not readable: $1"
filename="${1##*/}"
printf '%s\n' "--${CONTENT_BOUNDARY}
Content-Type:`file --mime-type $1 | cut -d':' -f2`
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=\"${filename}\"
X-Attachment-Id: f_`uuidgen | cut -d'-' -f1`
" >> $CONTENT_MAIL_FILE
base64 $1 >> $CONTENT_MAIL_FILE
}
## Encrypt $1 and write to $2
function encrypt()
{
[ -r $1 ] || fail "Source file not readable: $1"
[ -w $2 ] || fail "Dest file not writable: $2"
if [ $ASSUME_YES -eq 1 ] || [ ! -z $SIGNING_KEY_PASSPHRASE ] ; then
cat $1 | gpg --batch --yes --passphrase=$SIGNING_KEY_PASSPHRASE --encrypt --sign \
--armor --recipient $RECIPIENT_KEY > $2 || fail "Failed to encrypt/sign"
else
cat $1 | gpg --encrypt --sign --armor --recipient $RECIPIENT_KEY > $2 || fail "Failed to encrypt/sign"
fi
}
## Build the mail and write the result to $MAIL_FILE
function compose_mail()
{
write_clear_header
write_body $BODY_FILE
for attachment in ${ATTACHMENTS[@]}; do
add_attachment $attachment
done
echo "--${CONTENT_BOUNDARY}--" >> $CONTENT_MAIL_FILE
encrypt $CONTENT_MAIL_FILE $ENCRYPTED_MAIL_FILE;
cat $ENCRYPTED_MAIL_FILE >> $MAIL_FILE;
echo "--${PGP_BOUNDARY}--" >> $MAIL_FILE
}
## Send the mail
function send_mail()
{
if [ ! -z $USE_SSMTP ] && [ $USE_SSMTP = '1' ]; then
echo "Sending mail with SSMTP..."
ssmtp -t -oi < $MAIL_FILE
else
echo "Sending mail with Sendmail..."
sendmail -t -oi < $MAIL_FILE
fi
}
## Prints what's about to be done and ask for user confirmation
## unless ASSUME_YES is set to 1.
function confirm()
{
if [ $ASSUME_YES -eq 1 ] ; then
echo "Skipping confirmation"
return 0;
fi
printf "%s\n" "Mail info:
to: $RECIPIENT
from: $FROM
subject: $SUBJECT
body-file: $BODY_FILE
attachments:"
for attachment in ${ATTACHMENTS[@]}
do
echo -e "\t\t" $attachment
done
echo -n "Proceed? (y/N)"
read proceed
if [ ! $? -eq 0 ]; then return 1; fi
if [ $proceed != "y" ] && [ $proceed != "Y" ]; then return 1; fi
echo "Proceeding..."
return 0
}
for i in "$@"
do
case $i in
-r=*|--subject=*)
RECIPIENT="${i#*=}"
shift
;;
-rk=*|--recipient-key=*)
RECIPIENT_KEY="${i#*=}"
shift
;;
-s=*|--subject=*)
SUBJECT="${i#*=}"
shift
;;
-b=*|--body=*)
BODY_FILE="${i#*=}"
shift
;;
-p=*|--passphrase=*)
SIGNING_KEY_PASSPHRASE="${i#*=}"
shift
;;
-f=*|--from=*)
FROM="${i#*=}"
shift
;;
--assume-yes)
ASSUME_YES=1
shift
;;
-h|\?|--help)
usage 0;
;;
--)
read_attachment_files=1
;;
*)
## unkown option or attachment file
[ $read_attachment_files -eq 1 ] || usage 1
ATTACHMENTS+=($i)
;;
esac
done
[ ! -z $RECIPIENT ] || fail "Recipient must be set";
[ ! -z $FROM ] || fail "Sender must be set";
[ ! -z $BODY_FILE ] || fail "Body file must be set";
[ ! -z $RECIPIENT_KEY ] || fail "Recipient key must be set";
compose_mail
confirm || { echo "Canceled by user"; die 0 ; }
send_mail
echo "Looks like everything went well"
die 0
|
xaqq/scripts
|
secure_mail.sh
|
Shell
|
gpl-2.0
| 5,914
|
<?php
class WPestate_Facebook_Widget extends WP_Widget {
function WPestate_Facebook_Widget()
{
$widget_ops = array('classname' => 'facebook_widget_like', 'description' => 'Insert a Facebook Like Box.');
$control_ops = array('id_base' => 'wpestate_facebook_widget');
parent::__construct('wpestate_facebook_widget', 'Wp Estate: Facebook Box', $widget_ops, $control_ops);
}
function form($instance)
{
$defaults = array('title' =>'Find us on Facebook', 'url' => '', 'box_width' => '373', 'color_theme' => 'light', 'faces' => 'on', 'stream' => false, 'header' => false);
$instance = wp_parse_args((array) $instance, $defaults);
$theme_light=$theme_dark='';
if ($instance['color_theme']=='light'){
$theme_light='selected="selected"';
}
if ($instance['color_theme']=='dark'){
$theme_dark='selected="selected"';
}
$display='<p><label for="'.$this->get_field_id('title').'">Title:</label>
<input id="'.$this->get_field_id('title').'" name="'.$this->get_field_name('title').'" value="'.$instance['title'].'" />
</p><p>
<label for="'.$this->get_field_id('url').'">Facebook Page URL:</label>
</p><p>
<input id="'.$this->get_field_id('url').'" name="'.$this->get_field_name('url').'" value="'.$instance['url'].'" />
</p><p>
<label for="'.$this->get_field_id('box_width').'">Width:</label>
</p><p>
<input id="'.$this->get_field_id('box_width').'" name="'.$this->get_field_name('box_width').'" value="'.$instance['box_width'].'" />
</p><p>
<label for="'.$this->get_field_id('color_theme').'">Color Scheme:</label>
</p><p>
<select id="'.$this->get_field_id('color_theme').'" name="'.$this->get_field_name('color_theme').'">
<option value="light" '.$theme_light.'>light</option>
<option value="dark" '.$theme_dark.'>dark</option>
</select>
</p><p>
<label for="'.$this->get_field_id('faces').'">Show faces</label>
</p><p>
<input type="checkbox" id="'.$this->get_field_id('faces').'" name="'.$this->get_field_name('faces').'" '.checked($instance['faces'],'on',false).' />
</p><p>
<label for="'.$this->get_field_id('stream').'">Show stream</label>
</p><p>
<input type="checkbox" id="'.$this->get_field_id('stream').'" name="'.$this->get_field_name('stream').'" '.checked($instance['stream'],'on',false).'/>
</p>';
print $display;
}
function update($new_instance, $old_instance)
{
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['url'] = $new_instance['url'];
$instance['box_width'] = $new_instance['box_width'];
$instance['color_theme'] = $new_instance['color_theme'];
$instance['faces'] = $new_instance['faces'];
$instance['stream'] = $new_instance['stream'];
$instance['header'] = $new_instance['header'];
return $instance;
}
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_title', $instance['title']);
$page_url = $instance['url'];
$box_width = $instance['box_width'];
$color_theme = $instance['color_theme'];
$box_height = '75';
$box_height_extra='75';
$color_scheme='';
if( isset($instance['faces']) ){
$faces='true';
$box_height = '260';
$box_height_extra='360';
}else{
$faces='false';
}
if( isset($instance['stream']) ){
if ($faces=='false'){
$stream='true';
$box_height = '360';
$box_height_extra='425';
}else{
$stream='true';
$box_height = '600';
$box_height_extra='690';
}
}else{
$stream='false';
}
if( isset($instance['header']) ){
$header='true';
// $box_height = '600';
// $box_height_extra='690';
}else{
$header='false';
}
print $before_widget;
if($title) {
print $before_title.$title.$after_title;
}
if($page_url){
$display='<iframe id="facebook_wid" src="http://www.facebook.com/plugins/likebox.php?href='.urlencode($page_url).'&width='.$box_width.'&height='.$box_height.'&colorscheme='.$color_scheme.'&show_faces='.$faces.'&stream='.$stream.'&header='.$header.'&" style="border:none; overflow:hidden; width:'.$box_width.'px; height:'.$box_height.'px;background-color:white;" ></iframe>';
}
print $display;
print $after_widget;
}
}
?>
|
riddya85/rentail_upwrk
|
wp-content/themes/wprentals/libs/widgets/facebook.php
|
PHP
|
gpl-2.0
| 4,294
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using unirest_net.http;
using unirest_net.request;
namespace ContactsViewer.Services.Validation
{
/// <summary>
/// Validator.cs
/// This class aids the process of validating
/// different fields, especially those requiring
/// calls to outside APIs.
/// </summary>
public static class Validator
{
#region Constants
// // Validation values.
public const string EMAIL_VALIDATION_URI = "https://pozzad-email-validator.p.mashape.com/emailvalidator/validateEmail/";
public const string EMAIL_VALIDATION_API_KEY_TYPE = "X-Mashape-Key";
public const string EMAIL_VALIDATION_API_KEY = "cmDL0lmrTbmsh8SbKkDD4LWEpCgNp1ONnCOjsn9xRzlbEk5Jrz";
public const int MAX_TEXT_LENGTH = 50;
#endregion
#region Methods
/// <summary>
/// ValidateEmail (string)
/// This method takes an email address as a parameter
/// and makes a call to the pozzad-email-validator
/// API (free) through Mashape.
/// </summary>
/// <param name="email">Email address in the field.</param>
/// <returns>True if valid, false if invalid.</returns>
public static bool ValidateEmail(string email)
{
if ((email != null) && (email.Length >= 3) && (email.Contains("@"))) // a minimal of 3 characters is necessary for an email address.
{
string uri = EMAIL_VALIDATION_URI + email;
string key_type = EMAIL_VALIDATION_API_KEY_TYPE;
string api_key = EMAIL_VALIDATION_API_KEY;
// Craft HttpRequest.
unirest_net.request.HttpRequest emailValidation = Unirest.get(uri)
.header(key_type, api_key)
.header("accept", "application/json");
// Get the response.
HttpResponse<string> response = emailValidation.asJson<string>();
dynamic dynObj = Newtonsoft.Json.JsonConvert.DeserializeObject(response.Body.ToString());
bool validity;
var isValid = dynObj.isValid;
if (isValid == null)
{
validity = false;
}
else
{
validity = true;
}
Boolean.TryParse((string)isValid, out validity);
return validity;
}
else
{
return false;
}
}
public static bool ValidatePassword(string password)
{
if (string.IsNullOrEmpty(password.Trim()))
{
return false;
}
else if (password.Trim().Length < 6)
{
return false;
}
else
{
return true;
}
}
// Ensures the text field does not have too many characters
// Nor too little.
public static bool ValidateTextField(string entry)
{
if (entry.Trim().Length > MAX_TEXT_LENGTH)
{
return false;
}
return true;
}
#endregion
}
}
|
rimij405/ContactsViewer
|
ContactConnectionApplication/ContactConnectionApplication/Services/Validation/Validator.cs
|
C#
|
gpl-2.0
| 2,625
|
<?php
/**
* @package Joomla.Administrator
* @subpackage com_websitetemplatepro
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* websitetemplatepro list controller class.
*
* @package Joomla.Administrator
* @subpackage com_websitetemplatepro
* @since 1.6
*/
class websitetemplateproControllerlistraovat extends JControllerAdmin
{
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'raovat', $prefix = 'websitetemplateproModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
}
|
cuongnd/test_pro
|
components/website/website_websitetemplatepro/com_websitetemplatepro/controllers/listraovat.php
|
PHP
|
gpl-2.0
| 1,036
|
/*
* USE - UML based specification environment
* Copyright (C) 1999-2004 Mark Richters, University of Bremen
*
* This program 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 2 of the
* License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
// $Id: MAssociationImpl.java 2781 2011-12-12 16:48:51Z green $
package org.tzi.use.uml.mm;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* An association connects two or more classes.
*
* @version $ProjectVersion: 0.393 $
* @author Mark Richters
*/
class MAssociationImpl extends MModelElementImpl implements MAssociation {
private List<MAssociationEnd> fAssociationEnds;
private int fPositionInModel;
private Set<MAssociation> subsets = new HashSet<MAssociation>();
private Set<MAssociation> subsettedBy = new HashSet<MAssociation>();
private Set<MAssociation> redefines = new HashSet<MAssociation>();
private Set<MAssociation> redefinedBy = new HashSet<MAssociation>();
private boolean isUnion;
/**
* The association is called reflexive if any participating class
* occurs more than once, e.g. R(C,C) is reflexive but also
* R(C,D,C).
*/
private boolean fIsReflexive = false;
/**
* Creates a new association. Connections to classes are
* established by adding association ends. The kind of association
* will be automatically determined by the kind of association
* ends.
*/
MAssociationImpl(String name) {
super(name);
fAssociationEnds = new ArrayList<MAssociationEnd>(2);
}
/**
* Adds an association end.
*
* @exception MInvalidModel trying to add another composition
* or aggregation end.
*/
public void addAssociationEnd(MAssociationEnd aend) throws MInvalidModelException {
if (aend.aggregationKind() != MAggregationKind.NONE )
if (this.aggregationKind() != MAggregationKind.NONE )
throw new MInvalidModelException(
"Trying to add another composition " +
"or aggregation end (`" + aend.name() +
"') to association `" + name() + "'.");
// duplicate role names are ambiguos if they (1) refer to the
// same class, or (2) are used in n-ary associations with n > 2
String rolename = aend.name();
for (MAssociationEnd aend2 : fAssociationEnds) {
if (rolename.equals(aend2.name()) )
if (fAssociationEnds.size() >= 2 || aend.cls().equals(aend2.cls()) )
throw new MInvalidModelException(
"Ambiguous role name `" + rolename + "'.");
// check for reflexivity
if (aend.cls().equals(aend2.cls()) )
fIsReflexive = true;
}
// Set the aggregation kind if necessary
if (this.aggregationKind == MAggregationKind.NONE)
this.aggregationKind = aend.aggregationKind();
// Does at least one end has a qualifier?
this.hasQualifiedEnds = this.hasQualifiedEnds || aend.hasQualifiers();
fAssociationEnds.add(aend);
aend.setAssociation(this);
}
/**
* Returns the list of association ends.
*
* @return The list of association ends.
*/
public List<MAssociationEnd> associationEnds() {
return fAssociationEnds;
}
/**
* Returns the lust of all rolen ames of the association ends.
* @return
*/
public List<String> roleNames() {
List<String> result = new ArrayList<String>(fAssociationEnds.size());
for (MAssociationEnd assocEnd : fAssociationEnds) {
result.add(assocEnd.name());
}
return result;
}
/**
* Returns the list of reachable navigation ends from
* this association.
*
* @return List(MAssociationEnd)
*/
public List<MNavigableElement> reachableEnds() {
return new ArrayList<MNavigableElement>(associationEnds());
}
/**
* Returns the set of association ends attached to <code>cls</code>.
*
* @return Set(MAssociationEnd)
*/
public Set<MAssociationEnd> associationEndsAt(MClass cls) {
Set<MAssociationEnd> res = new HashSet<MAssociationEnd>();
for (MAssociationEnd aend : fAssociationEnds) {
if (aend.cls().equals(cls) )
res.add(aend);
}
return res;
}
/**
* Returns the set of classes participating in this association.
*
* @return Set(MClass).
*/
public Set<MClass> associatedClasses() {
HashSet<MClass> res = new HashSet<MClass>();
for (MAssociationEnd aend : fAssociationEnds) {
res.add(aend.cls());
}
return res;
}
/**
* Returns kind of association. This operation returns aggregate
* or composition if one of the association ends is aggregate or
* composition.
*/
private int aggregationKind = MAggregationKind.NONE;
public int aggregationKind() {
return aggregationKind;
}
/**
* Returns a list of association ends which can be reached by
* navigation from the given class. Examples:
*
* <ul>
* <li>For an association R(A,B), R.navigableEndsFrom(A)
* results in (B).
*
* <li>For an association R(A,A), R.navigableEndsFrom(A) results
* in (A,A).
*
* <li>For an association R(A,B,C), R.navigableEndsFrom(A) results
* in (B,C).
*
* <li>For an association R(A,A,B), R.navigableEndsFrom(A) results
* in (A,A,B).
* </ul>
*
* This operation does not consider associations in which parents
* of <code>cls</code> take part.
*
* @return List(MAssociationEnd)
* @exception IllegalArgumentException cls is not part of this association.
*/
public List<MNavigableElement> navigableEndsFrom(MClass cls) {
List<MNavigableElement> res = new ArrayList<MNavigableElement>();
boolean partOfAssoc = false;
for (MAssociationEnd aend : fAssociationEnds) {
if (! aend.cls().equals(cls) )
res.add(aend);
else {
partOfAssoc = true;
if (fIsReflexive )
res.add(aend);
}
}
if (! partOfAssoc )
throw new IllegalArgumentException("class `" + cls.name() +
"' is not part of this association.");
return res;
}
/**
* Returns the position in the defined USE-Model.
*/
public int getPositionInModel() {
return fPositionInModel;
}
/**
* Sets the position in the defined USE-Model.
*/
public void setPositionInModel(int position) {
fPositionInModel = position;
}
/**
* Process this element with visitor.
*/
public void processWithVisitor(MMVisitor v) {
v.visitAssociation(this);
}
public boolean isAssignableFrom(MClass[] classes) {
int i=0;
for (MAssociationEnd end : fAssociationEnds) {
if (!classes[i].isSubClassOf(end.cls())) return false;
++i;
}
return true;
}
@Override
public void addSubsets(MAssociation asso) {
subsets.add(asso);
}
@Override
public Set<MAssociation> getSubsets() {
return subsets;
}
@Override
public Set<MAssociation> getSubsetsClosure() {
Set<MAssociation> result = new HashSet<MAssociation>();
for (MAssociation ass : getSubsets()) {
result.add(ass);
result.addAll(ass.getSubsetsClosure());
}
return result;
}
public void setUnion(boolean newValue) {
isUnion = newValue;
}
public boolean isUnion() {
return isUnion;
}
@Override
public void addSubsettedBy(MAssociation asso) {
this.subsettedBy.add(asso);
}
@Override
public Set<MAssociation> getSubsettedBy() {
return this.subsettedBy;
}
@Override
public Set<MAssociation> getSubsettedByClosure() {
Set<MAssociation> result = new HashSet<MAssociation>();
for (MAssociation ass : getSubsettedBy()) {
result.add(ass);
result.addAll(ass.getSubsettedByClosure());
}
return result;
}
@Override
public MAssociationEnd getAssociationEnd(MClass endCls, String rolename) {
for (MAssociationEnd end : this.associationEndsAt(endCls)) {
if (end.nameAsRolename().equals(rolename))
return end;
}
return null;
}
@Override
public void addRedefinedBy(MAssociation association) {
this.redefinedBy.add(association);
}
@Override
public Set<MAssociation> getRedefinedBy() {
return this.redefinedBy;
}
@Override
public Set<MAssociation> getRedefinedByClosure() {
Set<MAssociation> result = new HashSet<MAssociation>();
for (MAssociation ass : this.getRedefinedBy()) {
result.add(ass);
result.addAll(ass.getRedefinedByClosure());
}
return result;
}
@Override
public void addRedefines(MAssociation parentAssociation) {
this.redefines.add(parentAssociation);
}
@Override
public Set<MAssociation> getRedefines() {
return this.redefines;
}
@Override
public Set<MAssociation> getRedefinesClosure() {
Set<MAssociation> result = new HashSet<MAssociation>();
for (MAssociation ass : this.getRedefines()) {
result.add(ass);
result.addAll(ass.getRedefinesClosure());
}
return result;
}
@Override
public boolean isReadOnly() {
if (this.isUnion) return true;
for (MAssociationEnd end : fAssociationEnds) {
if (end.isDerived()) return true;
}
return false;
}
private boolean hasQualifiedEnds = false;
/* (non-Javadoc)
* @see org.tzi.use.uml.mm.MAssociation#hasQualifiedEnds()
*/
@Override
public boolean hasQualifiedEnds() {
return this.hasQualifiedEnds;
}
/* (non-Javadoc)
* @see org.tzi.use.uml.mm.MAssociation#getSourceEnd(org.tzi.use.uml.mm.MClass, org.tzi.use.uml.mm.MNavigableElement, java.lang.String)
*/
@Override
public MNavigableElement getSourceEnd(MClass srcClass,
MNavigableElement dst, String explicitRolename) {
for (MAssociationEnd end : this.associationEnds()) {
if (end.equals(dst)) continue;
if (srcClass.isSubClassOf(end.cls())) {
if (explicitRolename == null) {
return end;
} else {
if (end.nameAsRolename().equals(explicitRolename))
return end;
}
}
}
return null;
}
/* (non-Javadoc)
* @see org.tzi.use.uml.mm.MAssociation#getParentAlignedEnds(org.tzi.use.uml.mm.MAssociation)
*/
//@Override
public List<MAssociationEnd> getParentAlignedEnds(MAssociation parentAssociation) {
List<MAssociationEnd> ownEnds = new ArrayList<MAssociationEnd>(this.associationEnds());
for (MAssociationEnd parentEnd : parentAssociation.associationEnds()) {
for (MAssociationEnd end : ownEnds) {
if (end.getRedefinedEnds().isEmpty()) {
}
}
}
return null;
}
/* (non-Javadoc)
* @see org.tzi.use.uml.mm.MAssociation#getAllParentAssociations()
*/
@Override
public Set<MAssociation> getAllParentAssociations() {
return Collections.emptySet();
}
/* (non-Javadoc)
* @see org.tzi.use.uml.mm.MAssociation#isOrdered()
*/
@Override
public boolean isOrdered() {
for (MAssociationEnd e : fAssociationEnds) {
if( e.isOrdered()) return true;
}
return false;
}
}
|
vnu-dse/rtl
|
src/main/org/tzi/use/uml/mm/MAssociationImpl.java
|
Java
|
gpl-2.0
| 12,148
|
<!DOCTYPE html>
<html>
<h1>old_spice7</h1>
<p>0/3 correct and 3/3false</p><br>
<img src = "../../../BVD_M01/old_spice/old_spice7.jpg" alt = "old_spice7.html" style= " width:320px;height:240px;"> <h1> Falsely compared to: </h1><br>
<img src = "../../../BVD_M01/rug_coffee_mug/rug_coffee_mug7.jpg" alt = "BVD_M01/rug_coffee_mug/rug_coffee_mug7.jpg" style= " width:320px;height:240px;"> <img src = "../../../BVD_M01/rug_coffee_mug/rug_coffee_mug7.jpg" alt = "BVD_M01/rug_coffee_mug/rug_coffee_mug7.jpg" style= " width:320px;height:240px;"> <img src = "../../../BVD_M01/rug_coffee_mug/rug_coffee_mug7.jpg" alt = "BVD_M01/rug_coffee_mug/rug_coffee_mug7.jpg" style= " width:320px;height:240px;"> </html>
|
MarcGroef/ros-vision
|
catkin_ws/Reports/BOLD_SIFT_1CAN-10fold-10%/old_spice/old_spice7.html
|
HTML
|
gpl-2.0
| 698
|
using System.Windows.Controls;
namespace Tsukuru.SourcePawn.Views
{
public partial class CompilationFilesControl : UserControl
{
public CompilationFilesControl()
{
InitializeComponent();
}
}
}
|
anarchysteven/tsukuru
|
Tsukuru.NetCore/SourcePawn/Views/CompilationFilesControl.xaml.cs
|
C#
|
gpl-2.0
| 245
|
@echo off
..\CekaCli.exe -m=arff -i=uhs_evol3 -f=removeUnusedValues
pause
|
krystianity/ceka-cli
|
Examples/win32/4_remove_unused_values.cmd
|
Batchfile
|
gpl-2.0
| 73
|
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
namespace ControllerEmu
{
BooleanSetting::BooleanSetting(const std::string& setting_name, const std::string& ui_name,
const bool default_value, const SettingType setting_type)
: m_type(setting_type), m_name(setting_name), m_ui_name(ui_name),
m_default_value(default_value), m_value(default_value)
{
}
BooleanSetting::BooleanSetting(const std::string& setting_name, const bool default_value,
const SettingType setting_type)
: BooleanSetting(setting_name, setting_name, default_value, setting_type)
{
}
bool BooleanSetting::GetValue() const
{
return m_value;
}
void BooleanSetting::SetValue(bool value)
{
m_value = value;
}
} // namespace ControllerEmu
|
ntapiam/Ishiiruka
|
Source/Core/InputCommon/ControllerEmu/Setting/BooleanSetting.cpp
|
C++
|
gpl-2.0
| 837
|
/*
memsrc.h
flexemu, an MC6809 emulator running FLEX
Copyright (C) 2018-2022 W. Schwotzer
This program 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 2 of the License, or
any later version.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MEMSRC_INCLUDED
#define MEMSRC_INCLUDED
#include "typedefs.h"
#include "bintervl.h"
#include <vector>
template<class T>
class MemorySource
{
public:
using AddressRange = BInterval<T>;
using AddressRanges = std::vector<AddressRange>;
virtual const AddressRanges& GetAddressRanges() const = 0;
virtual void CopyTo(Byte *buffer, T address, T aSize) const = 0;
};
#endif
|
aladur/flexemu
|
src/memsrc.h
|
C
|
gpl-2.0
| 1,196
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends MY_Controller {
public function __construct() {
parent::__construct();
$this->load->model('like_dislike_model');
}
/**
* Index Page for this controller.
*
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at base_url root
*/
public function index() {
$data = array();
$data['popular'] = array();
$popularld = $this->like_dislike_model->list_best_ratio();
foreach($popularld as $popularsketch)
{
array_push($data['popular'], $this->sketch_model->getById($popularsketch->sketch));
}
$this->show_view_with_hf('home', $data);
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
|
lamottin/sketchr
|
Sketchr/application/controllers/home.php
|
PHP
|
gpl-2.0
| 798
|
/*
* Copyright (C) 2017 Nessla AB
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "OpenVpnRunner.h"
#include "LogWindow.h"
#include "platform-constants.h"
#include <QDebug>
#include <QFileInfo>
#include <QFile>
#include <QDir>
#include <QByteArray>
#include <QApplication>
#include <QProcess>
#include <QTcpServer>
#include <QTcpSocket>
#include <QApplication>
#include <QTimer>
#include <QTemporaryFile>
OpenVpnRunner::OpenVpnRunner(QObject *parent) :
QObject(parent),
m_process(new QProcess(this)),
m_managementServer(new QTcpServer(this)),
m_managementConnection(nullptr),
m_configFile(nullptr),
m_hasDisconnected(false)
{
}
OpenVpnRunner::~OpenVpnRunner()
{
QObject::disconnect(this, nullptr, nullptr, nullptr);
if (m_managementConnection && m_managementConnection->isOpen())
m_managementConnection->abort();
m_process->close();
}
bool OpenVpnRunner::connect(const QString &config, const QString &username, const QString &password)
{
emit connecting();
m_username = username;
m_password = password;
m_configFile = new QTemporaryFile(this);
m_configFile->setAutoRemove(true);
if (!m_configFile->open()) {
qCritical() << "Config File Write Error:" << m_configFile->errorString();
return false;
}
/* Presumably QTemporaryFile already sets the umask correctly and isn't totally
* dumb when it comes to safe file creation, but just in case... */
if (!m_configFile->setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner)) {
qCritical() << "Config File Permissions Error:" << m_configFile->errorString();
return false;
}
if (m_configFile->write(config.toLocal8Bit()) != config.length()) {
qCritical() << "Config File Write Error:" << "Short write.";
return false;
}
m_configFile->close();
m_process->setReadChannelMode(QProcess::MergedChannels);
QObject::connect(m_process, static_cast<void(QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished), this, [=](int, QProcess::ExitStatus) {
if (!m_hasDisconnected) {
m_hasDisconnected = true;
emit disconnected();
}
deleteLater();
});
QObject::connect(m_process, &QProcess::readyRead, this, [=]() {
while (m_process->canReadLine())
qInfo() << ("OpenVPN > " + m_process->readLine().trimmed()).data();
});
m_managementServer->setMaxPendingConnections(1);
QObject::connect(m_managementServer, &QTcpServer::newConnection, this, [=]() {
m_managementConnection = m_managementServer->nextPendingConnection();
m_managementServer->close();
managementSetup();
});
if (!m_managementServer->listen(QHostAddress::LocalHost)) {
qCritical() << "Management Listener Error:" << m_managementServer->errorString();
return false;
}
QStringList arguments;
#if defined(Q_OS_LINUX)
arguments << "/usr/sbin/openvpn";
#elif defined(Q_OS_MACOS)
arguments << QDir(qApp->applicationDirPath()).filePath("openvpn");
#endif
arguments << "--config" << QDir::toNativeSeparators(m_configFile->fileName());
arguments << "--verb" << "3";
arguments << "--management" << "127.0.0.1" << QString::number(m_managementServer->serverPort());
arguments << "--management-client";
arguments << "--management-query-passwords";
arguments << "--management-hold";
arguments << "--suppress-timestamps";
#if !defined(Q_OS_WIN)
arguments << "--log" << "/dev/stderr"; /* No stdio buffering. */
#endif
#if defined(Q_OS_LINUX)
/* Giving script-security=2 *sucks*, since it allows code execution
* from the config file. But Ubuntu users will revolt without it.
* Besides, there are plenty of other issues with OpenVPN, for example
* config files containing malicious --log entries, tricky push configs,
* and the fact that the various mitigations for these within OpenVPN
* are incomplete. So... it's probably not worse than what's already
* possible without it, but ugh. Anyway, seeing this software could
* have unsigned auto-updates, like most desktop software, RCE from the
* the perspective of the server isn't really in this threat model. So,
* we grit our teeth, and enable script-security=2. */
if (QFile::exists("/etc/openvpn/update-resolv-conf")) {
arguments << "--script-security" << "2";
arguments << "--up" << "/etc/openvpn/update-resolv-conf";
arguments << "--down" << "/etc/openvpn/update-resolv-conf";
} else if (QFile::exists("/etc/openvpn/up.sh") && QFile::exists("/etc/openvpn/down.sh")) {
arguments << "--script-security" << "2";
arguments << "--up" << "/etc/openvpn/up.sh";
arguments << "--down" << "/etc/openvpn/down.sh";
} else
arguments << "--script-security" << "1";
#else
arguments << "--script-security" << "1";
#endif
#if defined(Q_OS_LINUX)
m_process->start("/usr/bin/pkexec", arguments, QIODevice::ReadOnly);
#elif defined(Q_OS_WIN)
m_process->start(QDir(qApp->applicationDirPath()).filePath("openvpn.exe"), arguments, QIODevice::ReadOnly);
#elif defined(Q_OS_MACOS)
m_process->start(QDir(qApp->applicationDirPath()).filePath("openvpn-launcher"), arguments, QIODevice::ReadOnly);
#else
#error "Platform not supported."
#endif
if (!m_process->waitForStarted(-1)) {
qCritical() << "OpenVPN Process Error:" << m_process->errorString();
m_disconnectReason = m_process->errorString();
disconnect();
return false;
}
return true;
}
void OpenVpnRunner::disconnect()
{
if (m_managementServer->isListening())
m_managementServer->close();
if (m_managementConnection && m_managementConnection->isOpen())
m_managementConnection->abort();
if (!m_hasDisconnected) {
m_hasDisconnected = true;
emit disconnected();
}
if (m_process->state() == QProcess::NotRunning)
deleteLater();
}
QString OpenVpnRunner::escape(const QString &in)
{
QString out(in);
out.replace("\\", "\\\\").replace("\"", "\\\"");
return "\"" + out + "\"";
}
void OpenVpnRunner::managementSetup()
{
QObject::connect(m_managementConnection, &QTcpSocket::readyRead, this, &OpenVpnRunner::managmentReadLine);
m_managementConnection->write("state on\n");
m_managementConnection->write("state\n");
m_managementConnection->write("bytecount 1\n");
m_managementConnection->write("hold release\n");
}
void OpenVpnRunner::managmentReadLine()
{
while (m_managementConnection->canReadLine()) {
if (m_configFile) {
m_configFile->deleteLater();
m_configFile = nullptr;
}
const QString line = m_managementConnection->readLine().trimmed();
if (line == ">PASSWORD:Need 'Auth' username/password") {
m_managementConnection->write(QString("username Auth %1\n").arg(escape(m_username)).toLocal8Bit());
m_managementConnection->write(QString("password Auth %1\n").arg(escape(m_password)).toLocal8Bit());
} else if (line.startsWith(">PASSWORD:Verification Failed:")) {
m_disconnectReason = tr("Server connection error. Try another server.");
disconnect();
} else if (line.startsWith(">STATE:")) {
if (line.contains(",CONNECTED,SUCCESS,"))
emit connected();
else if (line.contains(",RECONNECTING,") || line.contains(",CONNECTING,"))
emit connecting();
} else if (line.startsWith(">BYTECOUNT:")) {
const QStringList colon = line.split(':');
if (colon.length() != 2)
continue;
const QStringList comma = colon[1].split(',');
if (comma.length() != 2)
continue;
emit transfer(comma[0].toLongLong(), comma[1].toLongLong());
}
}
}
|
azirevpn/azclient
|
OpenVpnRunner.cpp
|
C++
|
gpl-2.0
| 7,925
|
<?php
/**
* Register widgetized area and update sidebar with default widgets
*/
function wolf_widgets_init() {
register_sidebar( array(
'name' => __( 'Sidebar', 'wolf' ),
'id' => 'sidebar-primary',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Left Footer Sidebar', 'wolf' ),
'id' => 'sidebar-left-footer',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Center Footer Sidebar', 'wolf' ),
'id' => 'sidebar-center-footer',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
register_sidebar( array(
'name' => __( 'Right Footer Sidebar', 'wolf' ),
'id' => 'sidebar-right-footer',
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h1 class="widget-title">',
'after_title' => '</h1>',
) );
}
add_action( 'widgets_init', 'wolf_widgets_init' );
|
bradp/Wolf
|
inc/widgets.php
|
PHP
|
gpl-2.0
| 1,560
|
DROP TABLE IF EXISTS `character_stats`;
CREATE TABLE `character_stats` (
`guid` int(11) unsigned NOT NULL default '0' COMMENT 'Global Unique Identifier, Low part',
`maxhealth` int(10) UNSIGNED NOT NULL default '0',
`maxpower1` int(10) UNSIGNED NOT NULL default '0',
`maxpower2` int(10) UNSIGNED NOT NULL default '0',
`maxpower3` int(10) UNSIGNED NOT NULL default '0',
`maxpower4` int(10) UNSIGNED NOT NULL default '0',
`maxpower5` int(10) UNSIGNED NOT NULL default '0',
`maxpower6` int(10) UNSIGNED NOT NULL default '0',
`maxpower7` int(10) UNSIGNED NOT NULL default '0',
`strength` int(10) UNSIGNED NOT NULL default '0',
`agility` int(10) UNSIGNED NOT NULL default '0',
`stamina` int(10) UNSIGNED NOT NULL default '0',
`intellect` int(10) UNSIGNED NOT NULL default '0',
`spirit` int(10) UNSIGNED NOT NULL default '0',
`armor` int(10) UNSIGNED NOT NULL default '0',
`resHoly` int(10) UNSIGNED NOT NULL default '0',
`resFire` int(10) UNSIGNED NOT NULL default '0',
`resNature` int(10) UNSIGNED NOT NULL default '0',
`resFrost` int(10) UNSIGNED NOT NULL default '0',
`resShadow` int(10) UNSIGNED NOT NULL default '0',
`resArcane` int(10) UNSIGNED NOT NULL default '0',
`blockPct` float UNSIGNED NOT NULL default '0',
`dodgePct` float UNSIGNED NOT NULL default '0',
`parryPct` float UNSIGNED NOT NULL default '0',
`critPct` float UNSIGNED NOT NULL default '0',
`rangedCritPct` float UNSIGNED NOT NULL default '0',
`spellCritPct` float UNSIGNED NOT NULL default '0',
`attackPower` int(10) UNSIGNED NOT NULL default '0',
`rangedAttackPower` int(10) UNSIGNED NOT NULL default '0',
`spellPower` int(10) UNSIGNED NOT NULL default '0',
PRIMARY KEY (`guid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
avalonfr/avalon_core_v1
|
sql/old/3.3.3a/07906_characters_character_stats.sql
|
SQL
|
gpl-2.0
| 1,785
|
/*
* Copyright (C) 2006-Today Guy Deleeuw
*
* See the LICENSE file for terms of use.
*/
#ifndef WsModEditorUploader_H__
#define WsModEditorUploader_H__ 1
#include <Wt/WContainerWidget>
#include <Wt/WFileUpload>
#include <Wt/WProgressBar>
#include <WsModule/WsModule.h>
using namespace Wt;
/*!
\file WsModEditorUploader.h
\brief a wittyShare module
*/
class WsEditorUploader : public Wt::WContainerWidget, public WsOptions {
public :
/*! \brief CTor. */
WsEditorUploader(Wt::WContainerWidget* parent = 0);
~WsEditorUploader();
void load();
public slots :
void doUpload();
void doFileTooLarge(int64_t nSize);
void doUploaded();
private :
Wt::WFileUpload* m_pFU;
Wt::WText* m_label;
Wt::WText* m_destPath;
Wt::WPushButton* m_uploadOther;
};
class WsModEditorUploader : public WsModule {
public :
/*! \brief CTor. */
WsModEditorUploader();
~WsModEditorUploader();
Wt::WWidget* createContentsMenuBar(Wt::WContainerWidget* parent = 0) const;
Wt::WWidget* createContents(Wt::WContainerWidget* parent = 0) const;
WsEditorWidget* createEditor(Wt::WContainerWidget* parent = 0) const;
Wt::WWidget* createAdmin(Wt::WContainerWidget* parent = 0) const;
std::string description() const;
};
extern "C" {
// http://phoxis.org/2011/04/27/c-language-constructors-and-destructors-with-gcc/
void WsModEditorUploaderInit(void) __attribute__((constructor));
WsModEditorUploader* buildModule()
{
return new WsModEditorUploader();
}
}
#endif // ifndef WsModEditorUploader_H__
|
Wittyshare/wittyshare
|
src/WsModules/WsModEditorUploader/src/WsModEditorUploader.h
|
C
|
gpl-2.0
| 1,650
|
cmd_drivers/usb/storage/usb-libusual.o := /root/adam/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-ld -EL -r -o drivers/usb/storage/usb-libusual.o drivers/usb/storage/libusual.o drivers/usb/storage/usual-tables.o
|
DJSteve/StreakKernel
|
drivers/usb/storage/.usb-libusual.o.cmd
|
Batchfile
|
gpl-2.0
| 228
|
module.exports = function(Promotion) {
};
|
viethoang88/corner
|
common/models/promotion.js
|
JavaScript
|
gpl-2.0
| 43
|
/*
* QEMU coroutine sleep
*
* Copyright IBM, Corp. 2011
*
* Authors:
* Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
*
* This work is licensed under the terms of the GNU LGPL, version 2 or later.
* See the COPYING.LIB file in the top-level directory.
*
*/
#include "block/coroutine.h"
#include "qemu/timer.h"
typedef struct CoSleepCB {
QEMUTimer *ts;
Coroutine *co;
} CoSleepCB;
static void co_sleep_cb(void *opaque)
{
CoSleepCB *sleep_cb = opaque;
qemu_coroutine_enter(sleep_cb->co, NULL);
}
void coroutine_fn co_sleep_ns(QEMUClock *clock, int64_t ns)
{
CoSleepCB sleep_cb = {
.co = qemu_coroutine_self(),
};
sleep_cb.ts = qemu_new_timer(clock, SCALE_NS, co_sleep_cb, &sleep_cb);
qemu_mod_timer(sleep_cb.ts, qemu_get_clock_ns(clock) + ns);
qemu_coroutine_yield();
qemu_del_timer(sleep_cb.ts);
qemu_free_timer(sleep_cb.ts);
}
|
lkzhd/glusterfs-annotation
|
contrib/qemu/qemu-coroutine-sleep.c
|
C
|
gpl-2.0
| 937
|
/**********************************************************************
Freeciv - Copyright (C) 2003 - The Freeciv Project
This program 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 2, or (at your option)
any later version.
This program 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.
***********************************************************************/
#ifdef HAVE_CONFIG_H
# include "../config.hh"
#endif
#include <math.h>
#include <stdio.h>
#include <string.h>
#include "wc_intl.hh"
#include "log.hh"
#include "mem.hh"
#include "shared.hh"
#include "support.hh"
#include "city.hh"
#include "game.hh"
#include "improvement.hh"
#include "map.hh"
#include "player.hh"
#include "terrain.hh"
#include "unit.hh"
#include "database.hh"
#include "plrhand.hh"
#include "srv_main.hh"
#include "score.hh"
/* Avoid having to recalculate civ scores all the time. */
static int score_cache[MAX_NUM_PLAYERS+MAX_NUM_BARBARIANS];
static struct grouping groupings[MAX_NUM_PLAYERS];
static int num_groupings = 0;
typedef int (*compare_func_t)(const void *, const void *);
/**************************************************************************
Allocates, fills and returns a land area claim map.
Call free_landarea_map(&cmap) to free allocated memory.
**************************************************************************/
#define USER_AREA_MULT 1000
struct claim_cell {
int when;
int whom;
int know;
int cities;
};
struct claim_map {
struct claim_cell *claims;
int *player_landarea;
int *player_owndarea;
tile_t **edges;
};
/**************************************************************************
Land Area Debug...
**************************************************************************/
#define LAND_AREA_DEBUG 0
#if LAND_AREA_DEBUG >= 2
static char when_char(int when)
{
static char list[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd',
'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z'
};
return (when >= 0 && when < sizeof(list)) ? list[when] : '?';
}
/*
* Writes the map_char_expr expression for each position on the map.
* map_char_expr is provided with the variables x,y to evaluate the
* position. The 'type' argument is used for formatting by printf; for
* instance it should be "%c" for characters. The data is printed in a
* native orientation to make it easier to read.
*/
#define WRITE_MAP_DATA(type, map_char_expr) \
{ \
int nat_x, nat_y; \
for (nat_x = 0; nat_x < map.info.xsize; nat_x++) { \
printf("%d", nat_x % 10); \
} \
putchar('\n'); \
for (nat_y = 0; nat_y < map.info.ysize; nat_y++) { \
printf("%d ", nat_y % 10); \
for (nat_x = 0; nat_x < map.info.xsize; nat_x++) { \
int x, y; \
NATIVE_TO_MAP_POS(&x, &y, nat_x,nat_y); \
printf(type, map_char_expr); \
} \
printf(" %d\n", nat_y % 10); \
} \
}
/**************************************************************************
Prints the landarea map to stdout (a debugging tool).
**************************************************************************/
static void print_landarea_map(struct claim_map *pcmap, int turn)
{
int p;
if (turn == 0) {
putchar('\n');
}
if (turn == 0) {
printf("Player Info...\n");
for (p = 0; p < game.info.nplayers; p++) {
printf(".know (%d)\n ", p);
WRITE_MAP_DATA("%c",
TEST_BIT(pcmap->claims[map_pos_to_index(x, y)].know,
p) ? 'X' : '-');
printf(".cities (%d)\n ", p);
WRITE_MAP_DATA("%c",
TEST_BIT(pcmap->
claims[map_pos_to_index(x, y)].cities,
p) ? 'O' : '-');
}
}
printf("Turn %d (%c)...\n", turn, when_char (turn));
printf(".whom\n ");
WRITE_MAP_DATA((pcmap->claims[map_pos_to_index(x, y)].whom ==
32) ? "%c" : "%X",
(pcmap->claims[map_pos_to_index(x, y)].whom ==
32) ? '-' : pcmap->claims[map_pos_to_index(x, y)].whom);
printf(".when\n ");
WRITE_MAP_DATA("%c", when_char(pcmap->claims[map_pos_to_index(x, y)].when));
}
#endif
static int no_owner = MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS;
/**************************************************************************
allocate and clear claim map; determine city radii
**************************************************************************/
static void build_landarea_map_new(struct claim_map *pcmap)
{
int nbytes;
nbytes = map.info.xsize * map.info.ysize * sizeof(struct claim_cell);
pcmap->claims = (claim_cell*)wc_malloc(nbytes);
memset(pcmap->claims, 0, nbytes);
nbytes = game.info.nplayers * sizeof(int);
pcmap->player_landarea = (int*)wc_malloc(nbytes);
memset(pcmap->player_landarea, 0, nbytes);
nbytes = game.info.nplayers * sizeof(int);
pcmap->player_owndarea = (int*)wc_malloc(nbytes);
memset(pcmap->player_owndarea, 0, nbytes);
nbytes = 2 * map.info.xsize * map.info.ysize * sizeof(*pcmap->edges);
pcmap->edges = (tile_t**)wc_malloc(nbytes);
players_iterate(pplayer) {
city_list_iterate(pplayer->cities, pcity) {
map_city_radius_iterate(pcity->common.tile, tile1) {
pcmap->claims[tile1->index].cities |= (1u << pcity->common.owner);
} map_city_radius_iterate_end;
} city_list_iterate_end;
} players_iterate_end;
}
/**************************************************************************
0th turn: install starting points, counting their tiles
**************************************************************************/
static void build_landarea_map_turn_0(struct claim_map *pcmap)
{
int turn, owner;
tile_t **nextedge;
struct claim_cell *pclaim;
turn = 0;
nextedge = pcmap->edges;
whole_map_iterate(ptile) {
int i = ptile->index;
pclaim = &pcmap->claims[i];
ptile = &map.board[i];
if (is_ocean(ptile->terrain)) {
/* pclaim->when = 0; */
pclaim->whom = no_owner;
/* pclaim->know = 0; */
} else if (ptile->city) {
owner = ptile->city->common.owner;
pclaim->when = turn + 1;
pclaim->whom = owner;
*nextedge = ptile;
nextedge++;
pcmap->player_landarea[owner]++;
pcmap->player_owndarea[owner]++;
pclaim->know = ptile->u.server.known;
} else if (ptile->worked) {
owner = ptile->worked->common.owner;
pclaim->when = turn + 1;
pclaim->whom = owner;
*nextedge = ptile;
nextedge++;
pcmap->player_landarea[owner]++;
pcmap->player_owndarea[owner]++;
pclaim->know = ptile->u.server.known;
} else if (unit_list_size(ptile->units) > 0) {
owner = (unit_list_get(ptile->units, 0))->owner;
pclaim->when = turn + 1;
pclaim->whom = owner;
*nextedge = ptile;
nextedge++;
pcmap->player_landarea[owner]++;
if (TEST_BIT(pclaim->cities, owner)) {
pcmap->player_owndarea[owner]++;
}
pclaim->know = ptile->u.server.known;
} else {
/* pclaim->when = 0; */
pclaim->whom = no_owner;
pclaim->know = ptile->u.server.known;
}
} whole_map_iterate_end;
*nextedge = NULL;
#if LAND_AREA_DEBUG >= 2
print_landarea_map(pcmap, turn);
#endif
}
/**************************************************************************
expand outwards evenly from each starting point, counting tiles
**************************************************************************/
static void build_landarea_map_expand(struct claim_map *pcmap)
{
tile_t **midedge;
int turn, accum, other;
tile_t **thisedge;
tile_t **nextedge;
midedge = &pcmap->edges[map.info.xsize * map.info.ysize];
for (accum = 1, turn = 1; accum > 0; turn++) {
thisedge = ((turn & 0x1) == 1) ? pcmap->edges : midedge;
nextedge = ((turn & 0x1) == 1) ? midedge : pcmap->edges;
for (accum = 0; *thisedge; thisedge++) {
tile_t *ptile = *thisedge;
int i = ptile->index;
int owner = pcmap->claims[i].whom;
if (owner != no_owner) {
adjc_iterate(ptile, tile1) {
int j = tile1->index;
struct claim_cell *pclaim = &pcmap->claims[j];
if (TEST_BIT(pclaim->know, owner)) {
if (pclaim->when == 0) {
pclaim->when = turn + 1;
pclaim->whom = owner;
*nextedge = tile1;
nextedge++;
pcmap->player_landarea[owner]++;
if (TEST_BIT(pclaim->cities, owner)) {
pcmap->player_owndarea[owner]++;
}
accum++;
} else if (pclaim->when == turn + 1
&& pclaim->whom != no_owner
&& pclaim->whom != owner) {
other = pclaim->whom;
if (TEST_BIT(pclaim->cities, other)) {
pcmap->player_owndarea[other]--;
}
pcmap->player_landarea[other]--;
pclaim->whom = no_owner;
accum--;
}
}
} adjc_iterate_end;
}
}
*nextedge = NULL;
#if LAND_AREA_DEBUG >= 2
print_landarea_map(pcmap, turn);
#endif
}
}
/**************************************************************************
this just calls the three worker routines
**************************************************************************/
static void build_landarea_map(struct claim_map *pcmap)
{
build_landarea_map_new(pcmap);
build_landarea_map_turn_0(pcmap);
build_landarea_map_expand(pcmap);
}
/**************************************************************************
Frees and NULLs an allocated claim map.
**************************************************************************/
static void free_landarea_map(struct claim_map *pcmap)
{
if (pcmap) {
if (pcmap->claims) {
free(pcmap->claims);
pcmap->claims = NULL;
}
if (pcmap->player_landarea) {
free(pcmap->player_landarea);
pcmap->player_landarea = NULL;
}
if (pcmap->player_owndarea) {
free(pcmap->player_owndarea);
pcmap->player_owndarea = NULL;
}
if (pcmap->edges) {
free(pcmap->edges);
pcmap->edges = NULL;
}
}
}
/**************************************************************************
Returns the given player's land and settled areas from a claim map.
**************************************************************************/
static void get_player_landarea(struct claim_map *pcmap,
player_t *pplayer,
int *return_landarea,
int *return_settledarea)
{
if (pcmap && pplayer) {
#if LAND_AREA_DEBUG >= 1
printf("%-14s", pplayer->name);
#endif
if (return_landarea && pcmap->player_landarea) {
*return_landarea =
USER_AREA_MULT * pcmap->player_landarea[pplayer->player_no];
#if LAND_AREA_DEBUG >= 1
printf(" l=%d", *return_landarea / USER_AREA_MULT);
#endif
}
if (return_settledarea && pcmap->player_owndarea) {
*return_settledarea =
USER_AREA_MULT * pcmap->player_owndarea[pplayer->player_no];
#if LAND_AREA_DEBUG >= 1
printf(" s=%d", *return_settledarea / USER_AREA_MULT);
#endif
}
#if LAND_AREA_DEBUG >= 1
printf("\n");
#endif
}
}
/**************************************************************************
Calculates the civilization score for the player.
**************************************************************************/
void calc_civ_score(player_t *pplayer)
{
city_t *pcity;
int landarea = 0, settledarea = 0;
static struct claim_map cmap = { NULL, NULL, NULL,NULL };
pplayer->score.happy = 0;
pplayer->score.content = 0;
pplayer->score.unhappy = 0;
pplayer->score.angry = 0;
pplayer->score.taxmen = 0;
pplayer->score.scientists = 0;
pplayer->score.elvis = 0;
pplayer->score.wonders = 0;
pplayer->score.techs = 0;
pplayer->score.techout = 0;
pplayer->score.landarea = 0;
pplayer->score.settledarea = 0;
pplayer->score.population = 0;
pplayer->score.cities = 0;
pplayer->score.units = 0;
pplayer->score.pollution = 0;
pplayer->score.bnp = 0;
pplayer->score.mfg = 0;
pplayer->score.literacy = 0;
pplayer->score.spaceship = 0;
if (is_barbarian(pplayer)) {
if (pplayer->player_no == game.info.nplayers - 1) {
free_landarea_map(&cmap);
}
return;
}
city_list_iterate(pplayer->cities, pcity) {
int bonus;
pplayer->score.happy += pcity->common.people_happy[4];
pplayer->score.content += pcity->common.people_content[4];
pplayer->score.unhappy += pcity->common.people_unhappy[4];
pplayer->score.angry += pcity->common.people_angry[4];
pplayer->score.taxmen += pcity->common.specialists[SP_TAXMAN];
pplayer->score.scientists += pcity->common.specialists[SP_SCIENTIST];
pplayer->score.elvis += pcity->common.specialists[SP_ELVIS];
pplayer->score.population += city_population(pcity);
pplayer->score.cities++;
pplayer->score.pollution += pcity->common.pollution;
pplayer->score.techout += pcity->common.science_total;
pplayer->score.bnp += pcity->common.trade_prod;
pplayer->score.mfg += pcity->common.shield_surplus;
bonus = CLIP(0, get_city_bonus(pcity, EFFECT_TYPE_SCIENCE_BONUS), 100);
pplayer->score.literacy += (city_population(pcity) * bonus) / 100;
} city_list_iterate_end;
if (pplayer->player_no == 0) {
free_landarea_map(&cmap);
build_landarea_map(&cmap);
}
get_player_landarea(&cmap, pplayer, &landarea, &settledarea);
pplayer->score.landarea = landarea;
pplayer->score.settledarea = settledarea;
if (pplayer->player_no == game.info.nplayers - 1) {
free_landarea_map(&cmap);
}
tech_type_iterate(i) {
if (get_invention(pplayer, i)==TECH_KNOWN) {
pplayer->score.techs++;
}
} tech_type_iterate_end;
if(game.ext_info.futuretechsscore)pplayer->score.techs += pplayer->future_tech * 5 / 2;
unit_list_iterate(pplayer->units, punit) {
if (is_military_unit(punit)) {
pplayer->score.units++;
}
} unit_list_iterate_end
impr_type_iterate(i) {
if (is_wonder(i)
&& (pcity = find_city_by_id(game.info.global_wonders[i]))
&& player_owns_city(pplayer, pcity)) {
pplayer->score.wonders++;
}
} impr_type_iterate_end;
/* How much should a spaceship be worth?
* This gives 100 points per 10,000 citizens. */
if (pplayer->spaceship.state == SSHIP_ARRIVED) {
pplayer->score.spaceship += (int)(100 * pplayer->spaceship.habitation
* pplayer->spaceship.success_rate);
}
}
/**************************************************************************
Return the civilization score (a numerical value) for the player.
**************************************************************************/
int get_civ_score(const player_t *pplayer)
{
/* We used to count pplayer->score.happy here too, but this is too easily
* manipulated by players at the endyear. */
return (total_player_citizens(pplayer)
+ pplayer->score.techs * 2
+ pplayer->score.wonders * 5
+ pplayer->score.spaceship);
}
/**************************************************************************
Return the total number of citizens in the player's nation.
**************************************************************************/
int total_player_citizens(const player_t *pplayer)
{
return (pplayer->score.happy
+ pplayer->score.content
+ pplayer->score.unhappy
+ pplayer->score.angry
+ pplayer->score.scientists
+ pplayer->score.elvis
+ pplayer->score.taxmen);
}
/**************************************************************************
save a ppm file which is a representation of the map of the current turn.
this can later be turned into a animated gif.
terrain type, units, and cities are saved.
**************************************************************************/
void save_ppm(void)
{
char filename[600];
char tmpname[600];
FILE *fp;
unsigned int i, j;
/* the colors for each player. these were selected to give
* the most differentiation between all players. YMMV. */
int col[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS][3] = {
{255, 0, 0}, { 0, 128, 0}, {255, 255, 255}, {255, 255, 0},
{138, 43, 226}, {255, 140, 0}, { 0, 255, 255}, {139, 69, 19},
{21155, 211, 211}, {255, 215, 0}, {255, 20, 147}, {124, 252, 0},
{218, 112, 214}, { 30, 144, 255}, {250, 128, 114}, {154, 205, 50},
{ 25, 25, 112}, { 0, 255, 127}, {139, 0, 0}, {100, 149, 237},
{ 0, 128, 128}, {255, 192, 203}, {255, 250, 205}, {119, 136, 153},
{255, 127, 80}, {255, 0, 255}, {128, 128, 0}, {245, 222, 179},
{184, 134, 11}, {173, 216, 230}, {102, 205, 170}, {255, 165, 0},
};
int watercol[3] = {0,0,255}; /* blue */
int landcol[3] = {0,0,0}; /* black */
if (!server_arg.save_ppm) {
return;
}
/* put this file in the same place we put savegames */
my_snprintf(filename, sizeof(filename),
"%s%+05d.int.ppm", game.server.save_name, game.info.year);
/* Ensure the saves directory exists. */
make_dir(server_arg.saves_pathname);
sz_strlcpy(tmpname, server_arg.saves_pathname);
if (tmpname[0] != '\0') {
sz_strlcat(tmpname, "/");
}
sz_strlcat(tmpname, filename);
sz_strlcpy(filename, tmpname);
fp = fopen(filename, "w");
if (!fp) {
freelog(LOG_ERROR, "couldn't open file ppm save: %s\n", filename);
return;
}
fprintf(fp, "P3\n# version:2\n# gameid: %s\n", game.server.id);
fprintf(fp, "# An intermediate map from saved Warciv game %s%+05d\n",
game.server.save_name, game.info.year);
for (i = 0; i < game.info.nplayers; i++) {
player_t *pplayer = get_player(i);
fprintf(fp, "# playerno:%d:color:#%02x%02x%02x:name:\"%s\"\n",
pplayer->player_no, col[i][0], col[i][1], col[i][2],
pplayer->name);
}
fprintf(fp, "%d %d\n", map.info.xsize, map.info.ysize);
fprintf(fp, "255\n");
for (j = 0; j < map.info.ysize; j++) {
for (i = 0; i < map.info.xsize; i++) {
tile_t *ptile = native_pos_to_tile(i, j);
int *color;
/* color for cities first, then units, then land */
if (ptile->city) {
color = col[city_owner(ptile->city)->player_no];
} else if (unit_list_size(ptile->units) > 0) {
color = col[unit_owner(unit_list_get(ptile->units, 0))->player_no];
} else if (is_ocean(ptile->terrain)) {
color = watercol;
} else {
color = landcol;
}
fprintf(fp, "%d %d %d\n", color[0], color[1], color[2]);
}
}
fclose(fp);
}
#ifdef DEBUG
/**************************************************************************
...
**************************************************************************/
static void dump_grouping_players(const struct grouping *p)
{
int j;
player_t *pp;
freelog(LOG_DEBUG, "dump_grouping_players grouping=%p", p);
for (j = 0; j < p->num_players; j++) {
pp = p->players[j];
if (!pp) {
freelog(LOG_DEBUG, " player %d @ %p !!!", j, pp);
continue;
}
freelog(LOG_DEBUG, " player %d @ %p: %s user=%s score=%d rank=%f "
"result=%d player_id=%d",
j, pp, pp->name, pp->username, get_civ_score(pp), pp->rank,
pp->result, pp->wcdb.player_id);
freelog(LOG_DEBUG, " rated_user_id=%d r=%f "
"rd=%f ts=%ld nr=%f nrd=%f",
pp->wcdb.rated_user_id, pp->wcdb.rating,
pp->wcdb.rating_deviation, pp->wcdb.last_rating_timestamp,
pp->wcdb.new_rating, pp->wcdb.new_rating_deviation);
}
}
/**************************************************************************
...
**************************************************************************/
static void dump_grouping(const struct grouping *p, int i)
{
freelog(LOG_DEBUG, "grouping %d @ %p: score=%f rank=%f result=%d "
"r=%f rd=%f",
i, p, p->score, p->rank, p->result, p->rating,
p->rating_deviation);
freelog(LOG_DEBUG, " nr=%f nrd=%f num_players=%d num_alive=%d",
p->new_rating, p->new_rating_deviation, p->num_players,
p->num_alive);
dump_grouping_players(p);
}
/**************************************************************************
...
**************************************************************************/
static void dump_groupings(void)
{
struct grouping *p;
int i;
freelog(LOG_DEBUG, "BEGIN GROUPING DUMP num_groupings=%d",
num_groupings);
for (i = 0, p = groupings; i < num_groupings; i++, p++) {
dump_grouping(p, i);
}
freelog(LOG_DEBUG, "END GROUPING DUMP");
}
#endif /* DEBUG */
/**************************************************************************
...
**************************************************************************/
#if 0 /* FOR HARDCORE DEBUGGING ONLY */
static int real_grouping_compare(const void *va, const void *vb);
static int grouping_compare(const void *va, const void *vb)
{
const struct grouping *a, *b;
int r;
a = (const struct grouping *) va;
b = (const struct grouping *) vb;
r = real_grouping_compare(a, b);
freelog(LOG_DEBUG, "about to compare (%p, %p):", a, b);
dump_grouping(a, -1);
dump_grouping(b, -2);
freelog(LOG_DEBUG, "grouping_compare(%p, %p) = %d", a, b, r);
return r;
}
static int real_grouping_compare(const void *va, const void *vb)
{
#else
/**************************************************************************
...
**************************************************************************/
static int grouping_compare(const void *va, const void *vb)
{
#endif
const struct grouping *a, *b;
double dscore;
a = (const struct grouping *) va;
b = (const struct grouping *) vb;
if (a->result == PR_WIN && b->result != PR_WIN)
return -1;
if (a->result != PR_WIN && b->result == PR_WIN)
return 1;
if (a->result == PR_LOSE && b->result != PR_LOSE)
return 1;
if (a->result != PR_LOSE && b->result == PR_LOSE)
return -1;
if (a->result == PR_DRAW && b->result == PR_DRAW)
return 0;
if (a->result == PR_DRAW && b->result != PR_DRAW)
return -1;
if (a->result != PR_DRAW && b->result == PR_DRAW)
return 1;
dscore = a->score - b->score;
if (fabs(dscore) < MINIMUM_SCORE_DIFFERENCE) {
if (a->num_alive > 0 && b->num_alive <= 0)
return -1;
if (a->num_alive <= 0 && b->num_alive > 0)
return 1;
if (a->num_players < b->num_players)
return -1;
if (a->num_players > b->num_players)
return 1;
if (a->num_alive > b->num_alive)
return -1;
if (a->num_alive < b->num_alive)
return 1;
return 0;
}
return dscore > 0.0 ? -1 : (dscore < 0.0 ? 1 : 0);
}
/**************************************************************************
NB Assumes score_cache has been filled in.
**************************************************************************/
static int player_compare(const void *va, const void *vb)
{
player_t *a, *b;
a = *((player_t **) va);
b = *((player_t **) vb);
if (a->result == PR_WIN && b->result != PR_WIN)
return -1;
if (a->result != PR_WIN && b->result == PR_WIN)
return 1;
if (a->result == PR_LOSE && b->result != PR_LOSE)
return 1;
if (a->result != PR_LOSE && b->result == PR_LOSE)
return -1;
if (a->result == PR_DRAW && b->result == PR_DRAW)
return 0;
if (a->result == PR_DRAW && b->result != PR_DRAW)
return -1;
if (a->result != PR_DRAW && b->result == PR_DRAW)
return 1;
if (a->is_alive && !b->is_alive)
return -1;
if (!a->is_alive && b->is_alive)
return 1;
return score_cache[b->player_no] - score_cache[a->player_no];
}
/**************************************************************************
Assumes (old) player ratings have been already assigned. Checks that
there are enough rated *users* for rating this game and if enough
turns have elapsed. Notifies players if the game cannot be rated.
**************************************************************************/
static bool game_can_be_rated(void)
{
int num_rated_users = 0;
players_iterate(pplayer) {
if (pplayer->wcdb.rating > 0.0
&& pplayer->wcdb.rating_deviation >= RATING_CONSTANT_MINIMUM_RD
&& pplayer->wcdb.rated_user_id > 0) {
num_rated_users++;
}
} players_iterate_end;
freelog(LOG_DEBUG, "game_can_be_rated num_rated_users=%d game.info.turn=%d",
num_rated_users, game.info.turn);
if ((game.server.wcdb.type == GAME_TYPE_SOLO && num_rated_users < 1)
|| (game.server.wcdb.type != GAME_TYPE_SOLO && num_rated_users < 2)) {
notify_conn(NULL, _("Game: The game cannot be rated because there "
"are not enough rated users in the game."));
return FALSE;
}
if (server_arg.wcdb.min_rated_turns > game.info.turn) {
notify_conn(NULL, _("Game: The game cannot be rated because not "
"enough turns (%d) have been played."),
server_arg.wcdb.min_rated_turns);
return FALSE;
}
return TRUE;
}
/**************************************************************************
...
**************************************************************************/
static inline double glicko_g_function(double RD) {
return 1.0/sqrt(1.0 + 3.0 * RATING_CONSTANT_Q * RATING_CONSTANT_Q
* RD * RD / (M_PI * M_PI));
}
/**************************************************************************
NB Unlike Glicko's definition, we pass g(RD_j) here not RD_j.
**************************************************************************/
static inline double glicko_E_function(double r, double rj, double gRDj)
{
return 1.0/(1.0 + pow(10.0, -gRDj * (r - rj) / 400.0));
}
/**************************************************************************
Calculate the rating and RD for each grouping from the
individual players' ratings and RDs. As this is not
part of the Glicko rating system, just something I made
up, it might be complete bullshit.
NB: Also sets rating and RD fields in team structs.
NB: Modifies global groupings array.
**************************************************************************/
void score_calculate_grouping_ratings(void)
{
double K, A, B, min_r, RD, avgRD, sum, r;
int i, j;
K = RATING_CONSTANT_EXTRA_TEAMMATE_INFLUENCE;
A = RATING_CONSTANT_AVERAGE_PLAYER_RATING;
B = RATING_CONSTANT_BAD_PLAYER_RATING;
min_r = RATING_CONSTANT_AVERAGE_PLAYER_RATING;
for (i = 0; i < num_groupings; i++) {
/* A grouping's base rating is the average of
* its members' ratings. Its RD is the average
* of its members' RDs. */
sum = 0.0;
avgRD = 0.0;
for (j = 0; j < groupings[i].num_players; j++) {
sum += groupings[i].players[j]->wcdb.rating;
RD = groupings[i].players[j]->wcdb.rating_deviation;
avgRD += RD;
min_r = MIN(min_r, groupings[i].players[j]->wcdb.rating);
}
sum /= (double) groupings[i].num_players;
avgRD /= (double) groupings[i].num_players;
/* If there is more than 1 player in the grouping,
* add to the base rating the approximate effect
* each player will have. Thus better-than-average
* players will increase the rating, while worse
* players will decrease it. Furthermore, the more
* members the grouping has, the smaller this
* contribution will be. */
if (groupings[i].num_players > 1) {
for (j = 0; j < groupings[i].num_players; j++) {
r = groupings[i].players[j]->wcdb.rating;
if (r > A) {
sum += K * (r - A);
} else if (r < B) {
sum += K * (r - B);
}
}
}
/* In the case of a team of mostly bad players,
* ensure that the rating does not go too low. */
if (sum < min_r) {
sum = min_r;
}
groupings[i].rating = sum;
groupings[i].rating_deviation = avgRD;
if (player_is_on_team(groupings[i].players[0])) {
/* Set corresponding wcdb fields in team structures. */
struct team *pteam = team_get_by_id(groupings[i].players[0]->team);
pteam->server.wcdb.rating = groupings[i].rating;
pteam->server.wcdb.rating_deviation = groupings[i].rating_deviation;
}
}
}
/**************************************************************************
NB: Modifies global groupings and player structs.
**************************************************************************/
void score_propagate_grouping_ratings(void)
{
int i, j;
double rating_change, rd_change, sum, new_r, new_RD, trank, weight;
for (i = 0; i < num_groupings; i++) {
rating_change = groupings[i].new_rating - groupings[i].rating;
rd_change = groupings[i].new_rating_deviation
- groupings[i].rating_deviation;
/* Note 'sum' is the sum of all the trank (i.e. the rank of
* a player in his own team, with 1 being first place and
* groupings[i].num_players being that last place value)
* values used below. We use n*(n+1)/2 not (n-1)*n/2 since
* the trank values start at 1 (unlike most other internal
* rank values, which start at 0). */
sum = groupings[i].num_players
* (groupings[i].num_players + 1.0) / 2.0;
for (j = 0; j < groupings[i].num_players; j++) {
new_r = groupings[i].players[j]->wcdb.rating;
new_RD = groupings[i].players[j]->wcdb.rating_deviation;
if (groupings[i].num_players == 1) {
new_r += rating_change;
new_RD += rd_change;
} else {
/* The "pie/blame" allotment scheme:
* If the rating change is positive, "better" members get a
* bigger piece of the pie (i.e. the rating change). If the
* change is negative, "worse" members get a bigger piece of
* the blame. */
/* NB: HIGHER score means LOWER rank, i.e. 0 is first place. */
/* Add 1 to the in-team rank to avoid weight = 0. */
trank = groupings[i].players[j]->team_rank + 1.0;
if (rating_change > 0) {
/* Flip the in-team rank so that players with
* a LOWER rank (i.e. higher score) get a BIGGER
* piece of the rating change. */
trank = groupings[i].num_players - trank + 1;
}
weight = trank / sum;
new_r += rating_change * weight;
/* If the player ranks highly (i.e. near 1st place)
* in his team and the team wins, 'weight' will be
* larger. This corresponds to a higher certainty that
* the player played a role in the team's win, hence
* the RD change should be larger.
*
* Similarly, if the team loses and the player ranks
* lowly (i.e. near last place in the team), then it
* is probable that the player contributed more to the
* team's loss. Hence again 'weight' will be larger and
* the RD change larger as well. */
new_RD += rd_change * weight;
}
/* As per Glicko's suggestion. */
if (new_RD < RATING_CONSTANT_MINIMUM_RD) {
new_RD = RATING_CONSTANT_MINIMUM_RD;
}
groupings[i].players[j]->wcdb.new_rating = new_r;
groupings[i].players[j]->wcdb.new_rating_deviation = new_RD;
}
}
}
/**************************************************************************
Glicko rating system extended to variable-sized groups of players. To
understand what this code is trying to do, read what it is based on at
http://math.bu.edu/people/mg/glicko/glicko.doc/glicko.html.
NB: Modifies global groupings and player structs.
**************************************************************************/
static void update_ratings(void)
{
int i, j;
double RD, c, t, r, q, q2, RD2, sum, inv_d2;
double rj, sj, E, new_r, new_RD, gRD[MAX_NUM_PLAYERS];
time_t now_time;
if (game.server.wcdb.type == GAME_TYPE_SOLO) {
assert(num_groupings == 1);
assert(groupings[0].num_players == 1);
}
/* Adjust player RDs to reflect the passage
* of time. (Glicko Step 1) */
c = RATING_CONSTANT_C;
now_time = time(NULL);
players_iterate(pplayer) {
if (pplayer->wcdb.last_rating_timestamp <= 0) {
continue;
}
RD = pplayer->wcdb.rating_deviation;
t = (double) (now_time - pplayer->wcdb.last_rating_timestamp)
/ RATING_CONSTANT_SECONDS_PER_RATING_PERIOD;
pplayer->wcdb.rating_deviation
= MIN(sqrt(RD*RD + c*c*t), RATING_CONSTANT_MAXIMUM_RD);
} players_iterate_end;
/* Transform player ratings into team/grouping ratings. */
score_calculate_grouping_ratings();
/* Update ratings. (Glicko Step 2) */
/* Fill gRD[j] table to avoid recalculation. */
if (game.server.wcdb.type == GAME_TYPE_SOLO) {
gRD[0] = glicko_g_function(score_get_solo_opponent_rating_deviation());
} else {
for (i = 0; i < num_groupings; i++) {
gRD[i] = glicko_g_function(groupings[i].rating_deviation);
}
}
q = RATING_CONSTANT_Q;
q2 = q * q;
for (i = 0; i < num_groupings; i++) {
r = groupings[i].rating;
RD = groupings[i].rating_deviation;
RD2 = RD * RD;
sum = 0.0;
inv_d2 = 0.0;
for (j = 0; j < num_groupings; j++) {
if (game.server.wcdb.type == GAME_TYPE_SOLO) {
rj = score_calculate_solo_opponent_rating(&groupings[0]);
/* You only 'win' if you get to Alpha Centauri. */
sj = game.server.wcdb.outcome == GAME_ENDED_BY_SPACESHIP ? 1.0 : 0.0;
} else {
if (i == j) {
/* Don't update your rating against yourself! */
continue;
}
rj = groupings[j].rating;
/* There are many potential ways we can calculate sj
* (the observed performace):
* 1. Relative rank: higher rank means win, same rank
* means draw, lower rank means loss, with the results
* giving sj 1.0, 0.5, 0.0 respectively, as in the
* original Glicko system.
* 2. Weighted rank: sj = 1/2 - (rank - rankj) / (2 * (n-1))
* where n is the number of groupings.
* 3. Result only:
* PR_WIN ==> sj = 1.0
* PR_DRAW ==> sj = 0.5
* PR_LOSE ==> sj = 0.0
* 4. Weighted score: like (2) but using scores instead of
* ranks.
*/
/* Method 2 */
sj = 0.5 - (groupings[i].rank - groupings[j].rank)
/ (2.0 * ((double) num_groupings - 1.0));
}
E = glicko_E_function(r, rj, gRD[j]);
sum += gRD[j] * (sj - E);
inv_d2 += gRD[j] * gRD[j] * E * (1.0 - E);
}
inv_d2 = q2 * inv_d2;
new_r = r + (q / (1.0 / RD2 + inv_d2)) * sum;
new_RD = sqrt(1.0 / (1.0 / RD2 + inv_d2));
groupings[i].new_rating = new_r;
groupings[i].new_rating_deviation = new_RD;
if (player_is_on_team(groupings[i].players[0])) {
/* Set corresponding wcdb fields in team structures. */
struct team *pteam = team_get_by_id(groupings[i].players[0]->team);
pteam->server.wcdb.new_rating = groupings[i].new_rating;
pteam->server.wcdb.new_rating_deviation = groupings[i].new_rating_deviation;
}
}
/* Now transform the new grouping ratings and RDs into new
* player ratings and RDs. (Not part of Glicko, caveat lector) */
score_propagate_grouping_ratings();
}
/**************************************************************************
NB: Modifies global grouping array.
**************************************************************************/
void score_assign_groupings(void)
{
int i, j;
memset(groupings, 0, sizeof(groupings));
num_groupings = 0;
/* Assign all players in the same team to their own grouping. */
i = 0;
team_iterate(pteam) {
j = 0;
players_iterate(pplayer) {
if (pplayer->team == pteam->id) {
groupings[i].players[j++] = pplayer;
}
} players_iterate_end;
groupings[i].num_players = j;
groupings[i].num_alive = team_count_members_alive(pteam->id);
i++;
} team_iterate_end;
/* Assign the individual players that are left. */
players_iterate(pplayer) {
if (player_is_on_team(pplayer)
|| is_barbarian(pplayer)
|| pplayer->is_civil_war_split) {
continue;
}
groupings[i].players[0] = pplayer;
groupings[i].num_players = 1;
groupings[i].num_alive = pplayer->is_alive ? 1 : 0;
i++;
} players_iterate_end;
num_groupings = i;
}
/**************************************************************************
Calculate the fractional ranking of the 'nmemb' objects each of 'size'
bytes given in 'base' using the supplied comparison function 'cmp' and
recording the results into 'frac_ranks'.
NB: The elements of 'base' are assumed to be ordered already.
NB: The 'frac_ranks' array must have room for at least 'nmemb'
elements.
**************************************************************************/
static void calculate_fractional_ranking(void *base,
int nmemb,
size_t size,
float *frac_ranks,
compare_func_t cmp)
{
int i, j, k;
float ranksum, frac_rank;
char *a = (char*)base;
freelog(LOG_DEBUG, "calculate_fractional_ranking base=%p nmemb=%d "
"size=%d", base, nmemb, (int) size);
if (nmemb < 1) {
return;
}
assert(base != NULL);
assert(frac_ranks != NULL);
assert(cmp != NULL);
i = 0;
frac_ranks[0] = 0.0;
do {
ranksum = (float) i;
j = i + 1;
while (j < nmemb && 0 == cmp(a + (j-1)*size, a + j*size)) {
ranksum += (float) j;
j++;
}
frac_rank = ranksum / (float) (j - i);
for (k = i; k < j; k++) {
frac_ranks[k] = frac_rank;
}
i = j;
} while (i < nmemb);
}
/**************************************************************************
NB: Modifies global grouping array.
**************************************************************************/
void score_update_grouping_results(void)
{
int i, j, next_cmp;
float frac_ranks[MAX_NUM_PLAYERS];
bool force_draw, force_loss;
assert(num_groupings > 0);
/* Build the score cache, so we don't have to
constantly call get_civ_score. */
players_iterate(pplayer) {
if (is_barbarian(pplayer)) {
continue;
}
score_cache[pplayer->player_no] = get_civ_score(pplayer);
} players_iterate_end;
/* Assign grouping scores. */
for (i = 0; i < num_groupings; i++) {
if (groupings[i].num_players == 1) {
groupings[i].score = score_cache[groupings[i].players[0]->player_no];
} else {
struct team *pteam = team_get_by_id(groupings[i].players[0]->team);
assert(pteam != NULL);
groupings[i].score = pteam->server.score;
}
}
/* Assign the groupings' forced results (if any). */
for (i = 0; i < num_groupings; i++) {
force_draw = FALSE;
force_loss = FALSE;
groupings[i].result = PR_NONE;
for (j = 0; j < groupings[i].num_players; j++) {
if (groupings[i].result == PR_NONE) {
if (groupings[i].players[j]->result == PR_WIN) {
/* forced winner (e.g. spaceship, /end <name>, etc. */
groupings[i].result = PR_WIN;
} else if (groupings[i].players[j]->result == PR_DRAW) {
/* forced draw may be overruled by forced win above */
force_draw = TRUE;
} else if (groupings[i].players[j]->result == PR_LOSE) {
/* for completeness, handle forced loss too (not used
in any game outcome as of yet) */
force_loss = TRUE;
}
}
}
if (force_draw && groupings[i].result == PR_NONE) {
groupings[i].result = PR_DRAW;
} else if (force_loss && groupings[i].result == PR_NONE) {
groupings[i].result = PR_LOSE;
}
}
#ifdef DEBUG
freelog(LOG_DEBUG, "Groupings after result assignment:");
dump_groupings();
#endif
/* Sort the groupings, and the players within the groupings. */
qsort(groupings, num_groupings, sizeof(struct grouping),
grouping_compare);
for (i = 0; i < num_groupings; i++) {
if (groupings[i].num_players < 2) {
continue;
}
freelog(LOG_DEBUG, "sorting players in grouping %d", i);
qsort(groupings[i].players, groupings[i].num_players,
sizeof(player_t *), player_compare);
}
#ifdef DEBUG
freelog(LOG_DEBUG, "Groupings after sort:");
dump_groupings();
#endif
/* Fill in unset results based on the order. */
if (groupings[0].result == PR_NONE) {
if (num_groupings < 2) {
if (game.server.wcdb.type == GAME_TYPE_SOLO
&& game.server.wcdb.outcome != GAME_ENDED_BY_SPACESHIP) {
groupings[0].result = PR_LOSE;
} else {
groupings[0].result = PR_WIN;
}
} else {
next_cmp = grouping_compare(&groupings[0], &groupings[1]);
groupings[0].result = PR_DRAW;
if (next_cmp != 0) {
groupings[0].result = PR_WIN;
} else {
i = 0;
while (TRUE) {
i++;
if (i >= num_groupings - 1) {
groupings[i].result = PR_DRAW;
break;
}
next_cmp = grouping_compare(&groupings[i], &groupings[i+1]);
groupings[i].result = PR_DRAW;
if (next_cmp != 0) {
break;
}
}
}
}
}
for (i = 0; i < num_groupings; i++) {
if (groupings[i].result != PR_NONE) {
continue;
}
groupings[i].result = PR_LOSE;
}
#ifdef DEBUG
freelog(LOG_DEBUG, "Groupings after result assignment:");
dump_groupings();
#endif
/* Assign fractional ranks based on the order. */
calculate_fractional_ranking(groupings,
num_groupings,
sizeof(struct grouping),
frac_ranks,
grouping_compare);
for (i = 0; i < num_groupings; i++) {
groupings[i].rank = frac_ranks[i];
}
#ifdef DEBUG
freelog(LOG_DEBUG, "Groupings after fractional ranking:");
dump_groupings();
#endif
}
/**************************************************************************
Propagate the groupings' results back to the players and teams, and
calculate the fractional ranking for players.
NB: Assumes groupings' results and ranks have been calculated.
NB: Modifies global groupings, player and team structs.
**************************************************************************/
void score_propagate_grouping_results(void)
{
int i, j;
float frac_ranks[MAX_NUM_PLAYERS];
struct team *pteam = NULL;
player_t *ranked[MAX_NUM_PLAYERS];
int num_ranked = 0;
/* Copy grouping results/ranks to teams. */
for (i = 0; i < num_groupings; i++) {
if (!player_is_on_team(groupings[i].players[0])) {
continue;
}
pteam = team_get_by_id(groupings[i].players[0]->team);
if (!pteam) {
continue;
}
pteam->server.rank = groupings[i].rank;
pteam->server.result = groupings[i].result;
}
for (i = 0; i < num_groupings; i++) {
/* Propagate grouping results to players. */
for (j = 0; j < groupings[i].num_players; j++) {
groupings[i].players[j]->result = groupings[i].result;
}
/* Calculate fractional team rank (the rank of
* the player only with respect to other members
* of the grouping). */
calculate_fractional_ranking(groupings[i].players,
groupings[i].num_players,
sizeof(player_t *),
frac_ranks,
player_compare);
for (j = 0; j < groupings[i].num_players; j++) {
groupings[i].players[j]->team_rank = frac_ranks[j];
}
/* Assemble the players into the ranked list. */
for (j = 0; j < groupings[i].num_players; j++) {
ranked[num_ranked++] = groupings[i].players[j];
}
}
/* Now calculate the overall fractional player rank. */
calculate_fractional_ranking(ranked,
num_ranked,
sizeof(player_t *),
frac_ranks,
player_compare);
for (i = 0; i < num_ranked; i++) {
ranked[i]->rank = frac_ranks[i];
}
}
/**************************************************************************
...
**************************************************************************/
void score_evaluate_players(void)
{
freelog(LOG_DEBUG, "Evaluating players...");
score_calculate_team_scores();
score_assign_groupings();
score_update_grouping_results();
score_propagate_grouping_results();
#ifdef DEBUG
freelog(LOG_DEBUG, "Groupings after assign, update and propagate:");
dump_groupings();
#endif
if (!game.server.rated || !server_arg.wcdb.enabled || !server_arg.auth.enabled) {
return;
}
/* Get the old ratings. */
if (!wcdb_load_player_ratings(game.server.wcdb.type, TRUE)) {
notify_conn(NULL, _("Game: Though the server option 'rated' was set, "
"player ratings cannot be updated because there was an error "
"communicating with the database."));
game.server.rated = FALSE;
return;
}
if (!game_can_be_rated()) {
game.server.rated = FALSE;
return;
}
update_ratings();
#ifdef DEBUG
freelog(LOG_DEBUG, "Groupings after rating calculation:");
dump_groupings();
#endif
}
/***************************************************************
The team score is the average of the members' scores.
***************************************************************/
void score_calculate_team_scores(void)
{
double sum;
team_iterate(pteam) {
sum = 0.0;
players_iterate(pplayer) {
if (pplayer->team != pteam->id)
continue;
sum += (double) get_civ_score(pplayer);
} players_iterate_end;
pteam->server.score = sum / (double) pteam->member_count;
} team_iterate_end;
}
/**************************************************************************
...
**************************************************************************/
void score_assign_ai_rating(player_t *pplayer,
int game_type)
{
score_get_ai_rating(pplayer->ai.skill_level, game_type,
&pplayer->wcdb.rating,
&pplayer->wcdb.rating_deviation);
pplayer->wcdb.new_rating = 0.0;
pplayer->wcdb.new_rating_deviation = 0.0;
pplayer->wcdb.last_rating_timestamp = 0;
}
/**************************************************************************
...
**************************************************************************/
void score_assign_new_player_rating(player_t *pplayer,
int game_type)
{
pplayer->wcdb.rating = RATING_CONSTANT_AVERAGE_PLAYER_RATING;
pplayer->wcdb.rating_deviation = RATING_CONSTANT_MAXIMUM_RD;
pplayer->wcdb.new_rating = 0.0;
pplayer->wcdb.new_rating_deviation = 0.0;
pplayer->wcdb.last_rating_timestamp = 0;
}
/**************************************************************************
...
**************************************************************************/
const struct grouping *score_get_groupings(int *pnum_groupings)
{
*pnum_groupings = num_groupings;
return groupings;
}
/**************************************************************************
...
**************************************************************************/
double score_get_solo_opponent_rating_deviation(void)
{
return RATING_CONSTANT_MINIMUM_RD;
}
/**************************************************************************
Because there is no opponent for solo players, create a 'pseudo opponent'
whose rating depends on your score and the turn that the game ended.
**************************************************************************/
double score_calculate_solo_opponent_rating(const struct grouping *g)
{
double K, S, T, rating;
K = RATING_CONSTANT_SOLO_RATING_COEFFICIENT;
S = g->score;
T = game.info.turn;
rating = K * S / (1.0 + T);
freelog(LOG_DEBUG, "Solo game psuedo-opponent rating=%f", rating);
return rating;
}
/**************************************************************************
Estimate AI rating and RD.
**************************************************************************/
void score_get_ai_rating(int skill_level, int game_type,
double *prating, double *prd)
{
/* I assume higher skill level implies a better ai. */
*prating = 600 + skill_level * 50;
if (game_type == GAME_TYPE_TEAM) {
*prating -= 100;
}
*prd = 50;
}
/**************************************************************************
...
**************************************************************************/
int player_get_rated_username(const player_t *pplayer,
char *outbuf, int maxlen)
{
if (pplayer->wcdb.rated_user_id <= 0
|| pplayer->wcdb.rated_user_name[0] == '\0') {
return player_get_username(pplayer, outbuf, maxlen);
}
return mystrlcpy(outbuf, pplayer->wcdb.rated_user_name, maxlen);
}
|
seggil/warciv
|
server/score.cc
|
C++
|
gpl-2.0
| 49,999
|
#
# downloadview.py
#
# Copyright 2010 Brett Mravec <brett.mravec@gmail.com>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
class DownloadView:
def __init__ (self, downloadlist):
self.downloadlist = downloadlist
downloadlist.view = self
def add_download (self, download):
print 'DownloadView.add_download (download): stub'
def update_download (self, download):
print 'DownloadView.update_download (download): stub'
def remove_download (self, download):
print 'DownloadView.remove_download (download): stub'
def get_selected (self):
print 'DownloadView.get_selected (): stub'
return []
|
bmravec/DownMan
|
downman/gui/downloadview.py
|
Python
|
gpl-2.0
| 1,413
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Struct template is_keyword_descriptor</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../../expressions.html#header.boost.log.expressions.is_keyword_descriptor_hpp" title="Header <boost/log/expressions/is_keyword_descriptor.hpp>">
<link rel="prev" href="keyword_descriptor.html" title="Struct keyword_descriptor">
<link rel="next" href="attribute_keyword.html" title="Struct template attribute_keyword">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="keyword_descriptor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../expressions.html#header.boost.log.expressions.is_keyword_descriptor_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="attribute_keyword.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.expressions.is_keyword_descriptor"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Struct template is_keyword_descriptor</span></h2>
<p>boost::log::expressions::is_keyword_descriptor</p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: <<a class="link" href="../../../expressions.html#header.boost.log.expressions.is_keyword_descriptor_hpp" title="Header <boost/log/expressions/is_keyword_descriptor.hpp>">boost/log/expressions/is_keyword_descriptor.hpp</a>>
</span><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> T<span class="special">,</span> <span class="keyword">typename</span> VoidT <span class="special">=</span> <span class="keyword">void</span><span class="special">></span>
<span class="keyword">struct</span> <a class="link" href="is_keyword_descriptor.html" title="Struct template is_keyword_descriptor">is_keyword_descriptor</a> <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">false_</span> <span class="special">{</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm45848820701360"></a><h2>Description</h2>
<p>The metafunction detects if the type <code class="computeroutput">T</code> is a keyword descriptor </p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2007-2016 Andrey Semashev<p>
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
</p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="keyword_descriptor.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../expressions.html#header.boost.log.expressions.is_keyword_descriptor_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="attribute_keyword.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
|
FFMG/myoddweb.piger
|
myodd/boost/libs/log/doc/html/boost/log/expressions/is_keyword_descriptor.html
|
HTML
|
gpl-2.0
| 4,240
|
/*
* twl-common.c
*
* Copyright (C) 2011 Texas Instruments, Inc..
* Author: Peter Ujfalusi <peter.ujfalusi@ti.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#include <linux/i2c.h>
#include <linux/i2c/twl.h>
#include <linux/gpio.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/fixed.h>
#include <linux/mfd/twl6040.h>
#include <plat/i2c.h>
#include <plat/usb.h>
#include "twl-common.h"
#include "pm.h"
#include "mux.h"
#include <linux/power/ti-fg.h>
static struct i2c_board_info __initdata pmic_i2c_board_info = {
.addr = 0x48,
.flags = I2C_CLIENT_WAKE,
};
static struct i2c_board_info __initdata omap4_i2c1_board_info[] = {
{
.addr = 0x48,
.flags = I2C_CLIENT_WAKE,
},
{
I2C_BOARD_INFO("twl6040", 0x4b),
},
};
static struct i2c_board_info __initdata omap5_i2c1_generic_info[] = {
{
I2C_BOARD_INFO("twl6035", 0x48),
.flags = I2C_CLIENT_WAKE,
},
{
I2C_BOARD_INFO("twl6040", 0x4b),
},
};
static int twl6040_pdm_ul_errata(void)
{
struct omap_mux_partition *part;
u16 reg_offset, pdm_ul;
if (cpu_is_omap44xx())
reg_offset = OMAP4_CTRL_MODULE_PAD_ABE_PDM_UL_DATA_OFFSET;
else if (cpu_is_omap54xx())
reg_offset = OMAP5_CTRL_MODULE_PAD_ABEMCPDM_UL_DATA_OFFSET;
else
return 0;
part = omap_mux_get("core");
if (!part) {
pr_err("failed to apply PDM_UL errata\n");
return -EINVAL;
}
/*
* ERRATA: Reset value of PDM_UL buffer logic is 1 (VDDVIO)
* when AUDPWRON = 0, which causes current drain on this pin's
* pull-down on OMAP side. The workaround consists of disabling
* pull-down resistor of ABE_PDM_UL_DATA pin
*/
pdm_ul = omap_mux_read(part, reg_offset);
omap_mux_write(part, pdm_ul & ~OMAP_PULL_ENA, reg_offset);
return 0;
}
void __init omap_pmic_init(int bus, u32 clkrate,
const char *pmic_type, int pmic_irq,
struct twl4030_platform_data *pmic_data)
{
strncpy(pmic_i2c_board_info.type, pmic_type,
sizeof(pmic_i2c_board_info.type));
pmic_i2c_board_info.irq = pmic_irq;
pmic_i2c_board_info.platform_data = pmic_data;
omap_register_i2c_bus(bus, clkrate, &pmic_i2c_board_info, 1);
}
void __init omap4_pmic_init(const char *pmic_type,
struct twl4030_platform_data *pmic_data,
struct twl6040_platform_data *twl6040_data, int twl6040_irq)
{
/* PMIC part*/
strncpy(omap4_i2c1_board_info[0].type, pmic_type,
sizeof(omap4_i2c1_board_info[0].type));
omap4_i2c1_board_info[0].irq = OMAP44XX_IRQ_SYS_1N;
omap4_i2c1_board_info[0].platform_data = pmic_data;
/* TWL6040 audio IC part */
twl6040_data->pdm_ul_errata = twl6040_pdm_ul_errata;
omap4_i2c1_board_info[1].irq = twl6040_irq;
omap4_i2c1_board_info[1].platform_data = twl6040_data;
omap_register_i2c_bus(1, 400, omap4_i2c1_board_info, 2);
}
#ifdef CONFIG_OMAP5_SEVM_PALMAS
/**
* omap5_pmic_init() - PMIC init for i2c
* @bus_id: which bus
* @speed: speed
* @pmic_type: name of pmic
* @pmic_data: pointer to pmic data
* @audio_data: audio data
* @audio_irq: irq for audio
* @bd_info: other board specific i2c_board_info data
* @num_bd_info: count
*
* To be called after register_i2c_bus is called by board file
*/
void __init omap5_pmic_init(int bus_id, const char *pmic_type, int pmic_irq,
struct palmas_platform_data *pmic_data,
const char *audio_type, int audio_irq,
struct twl6040_platform_data *audio_data)
{
/* PMIC part*/
strncpy(omap5_i2c1_generic_info[0].type, pmic_type,
sizeof(omap5_i2c1_generic_info[0].type));
omap5_i2c1_generic_info[0].irq = pmic_irq;
omap5_i2c1_generic_info[0].platform_data = pmic_data;
/* TWL6040 audio IC part */
strncpy(omap5_i2c1_generic_info[1].type, audio_type,
sizeof(omap5_i2c1_generic_info[1].type));
audio_data->pdm_ul_errata = twl6040_pdm_ul_errata;
omap5_i2c1_generic_info[1].irq = audio_irq;
omap5_i2c1_generic_info[1].platform_data = audio_data;
i2c_register_board_info(bus_id, omap5_i2c1_generic_info,
ARRAY_SIZE(omap5_i2c1_generic_info));
}
#endif
void __init omap_pmic_late_init(void)
{
/* Init the OMAP TWL parameters (if PMIC has been registerd) */
if (!pmic_i2c_board_info.irq && !omap4_i2c1_board_info[0].irq &&
!omap5_i2c1_generic_info[0].irq)
return;
omap_twl_init();
omap_tps6236x_init();
omap_palmas_init();
}
#if defined(CONFIG_ARCH_OMAP3)
static struct twl4030_usb_data omap3_usb_pdata = {
.usb_mode = T2_USB_MODE_ULPI,
};
static int omap3_batt_table[] = {
/* 0 C */
30800, 29500, 28300, 27100,
26000, 24900, 23900, 22900, 22000, 21100, 20300, 19400, 18700, 17900,
17200, 16500, 15900, 15300, 14700, 14100, 13600, 13100, 12600, 12100,
11600, 11200, 10800, 10400, 10000, 9630, 9280, 8950, 8620, 8310,
8020, 7730, 7460, 7200, 6950, 6710, 6470, 6250, 6040, 5830,
5640, 5450, 5260, 5090, 4920, 4760, 4600, 4450, 4310, 4170,
4040, 3910, 3790, 3670, 3550
};
static struct twl4030_bci_platform_data omap3_bci_pdata = {
.battery_tmp_tbl = omap3_batt_table,
.tblsize = ARRAY_SIZE(omap3_batt_table),
};
static struct twl4030_madc_platform_data omap3_madc_pdata = {
.irq_line = 1,
};
static struct twl4030_codec_data omap3_codec;
static struct twl4030_audio_data omap3_audio_pdata = {
.audio_mclk = 26000000,
.codec = &omap3_codec,
};
static struct regulator_consumer_supply omap3_vdda_dac_supplies[] = {
REGULATOR_SUPPLY("vdda_dac", "omapdss_venc"),
};
static struct regulator_init_data omap3_vdac_idata = {
.constraints = {
.min_uV = 1800000,
.max_uV = 1800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = ARRAY_SIZE(omap3_vdda_dac_supplies),
.consumer_supplies = omap3_vdda_dac_supplies,
};
static struct regulator_consumer_supply omap3_vpll2_supplies[] = {
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
};
static struct regulator_init_data omap3_vpll2_idata = {
.constraints = {
.min_uV = 1800000,
.max_uV = 1800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
},
.num_consumer_supplies = ARRAY_SIZE(omap3_vpll2_supplies),
.consumer_supplies = omap3_vpll2_supplies,
};
void __init omap3_pmic_get_config(struct twl4030_platform_data *pmic_data,
u32 pdata_flags, u32 regulators_flags)
{
if (!pmic_data->irq_base)
pmic_data->irq_base = TWL4030_IRQ_BASE;
if (!pmic_data->irq_end)
pmic_data->irq_end = TWL4030_IRQ_END;
/* Common platform data configurations */
if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
pmic_data->usb = &omap3_usb_pdata;
if (pdata_flags & TWL_COMMON_PDATA_BCI && !pmic_data->bci)
pmic_data->bci = &omap3_bci_pdata;
if (pdata_flags & TWL_COMMON_PDATA_MADC && !pmic_data->madc)
pmic_data->madc = &omap3_madc_pdata;
if (pdata_flags & TWL_COMMON_PDATA_AUDIO && !pmic_data->audio)
pmic_data->audio = &omap3_audio_pdata;
/* Common regulator configurations */
if (regulators_flags & TWL_COMMON_REGULATOR_VDAC && !pmic_data->vdac)
pmic_data->vdac = &omap3_vdac_idata;
if (regulators_flags & TWL_COMMON_REGULATOR_VPLL2 && !pmic_data->vpll2)
pmic_data->vpll2 = &omap3_vpll2_idata;
}
#endif /* CONFIG_ARCH_OMAP3 */
#if defined(CONFIG_ARCH_OMAP4)
static struct twl4030_usb_data omap4_usb_pdata = {
};
static struct twl4030_madc_platform_data omap4_madc_pdata = {
.irq_line = -1,
};
/* Fuel Gauge EDV Configuration */
static struct edv_config edv_cfg = {
.averaging = true,
.seq_edv = 5,
.filter_light = 155,
.filter_heavy = 199,
.overload_current = 1000,
.edv = {
{3150, 0},
{3450, 4},
{3600, 10},
},
};
/* Fuel Gauge OCV Configuration */
static struct ocv_config ocv_cfg = {
.voltage_diff = 75,
.current_diff = 30,
.sleep_enter_current = 60,
.sleep_enter_samples = 3,
.sleep_exit_current = 100,
.sleep_exit_samples = 3,
.long_sleep_current = 500,
.ocv_period = 300,
.relax_period = 600,
.flat_zone_low = 35,
.flat_zone_high = 65,
.max_ocv_discharge = 1300,
.table = {
3300, 3603, 3650, 3662, 3700,
3723, 3734, 3746, 3756, 3769,
3786, 3807, 3850, 3884, 3916,
3949, 3990, 4033, 4077, 4129,
4193
},
};
/* General OMAP4 Battery Cell Configuration */
static struct cell_config cell_cfg = {
.cc_voltage = 4175,
.cc_current = 250,
.cc_capacity = 15,
.seq_cc = 5,
.cc_polarity = true,
.cc_out = true,
.ocv_below_edv1 = false,
.design_capacity = 4000,
.design_qmax = 4100,
.r_sense = 10,
.qmax_adjust = 1,
.fcc_adjust = 2,
.max_overcharge = 100,
.electronics_load = 200, /* *10 uAh */
.max_increment = 150,
.max_decrement = 150,
.low_temp = 119,
.deep_dsg_voltage = 30,
.max_dsg_estimate = 300,
.light_load = 100,
.near_full = 500,
.cycle_threshold = 3500,
.recharge = 300,
.mode_switch_capacity = 5,
.call_period = 2,
.ocv = &ocv_cfg,
.edv = &edv_cfg,
};
static int omap4_batt_table[] = {
/* adc code for temperature in degree C */
929, 925, /* -2 ,-1 */
920, 917, 912, 908, 904, 899, 895, 890, 885, 880, /* 00 - 09 */
875, 869, 864, 858, 853, 847, 841, 835, 829, 823, /* 10 - 19 */
816, 810, 804, 797, 790, 783, 776, 769, 762, 755, /* 20 - 29 */
748, 740, 732, 725, 718, 710, 703, 695, 687, 679, /* 30 - 39 */
671, 663, 655, 647, 639, 631, 623, 615, 607, 599, /* 40 - 49 */
591, 583, 575, 567, 559, 551, 543, 535, 527, 519, /* 50 - 59 */
511, 504, 496 /* 60 - 62 */
};
static struct twl4030_bci_platform_data omap4_bci_pdata = {
.monitoring_interval = 10,
.max_charger_currentmA = 1500,
.max_charger_voltagemV = 4560,
.max_bat_voltagemV = 4200,
.low_bat_voltagemV = 3300,
.battery_tmp_tbl = omap4_batt_table,
.tblsize = ARRAY_SIZE(omap4_batt_table),
.cell_cfg = &cell_cfg,
};
static struct regulator_init_data omap4_vdac_idata = {
.constraints = {
.min_uV = 1800000,
.max_uV = 1800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.always_on = true,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.supply_regulator = "V2V1",
};
static struct regulator_consumer_supply omap4_vaux_supply[] = {
REGULATOR_SUPPLY("vmmc", "omap_hsmmc.1"),
};
static struct regulator_init_data omap4_vaux1_idata = {
.constraints = {
.min_uV = 1000000,
.max_uV = 3000000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_vaux_supply),
.consumer_supplies = omap4_vaux_supply,
};
static struct regulator_consumer_supply omap4_vaux2_supply[] = {
REGULATOR_SUPPLY("av-switch", "omap-abe-twl6040"),
};
static struct regulator_init_data omap4_vaux2_idata = {
.constraints = {
.min_uV = 1200000,
.max_uV = 2800000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_vaux2_supply),
.consumer_supplies = omap4_vaux2_supply,
};
static struct regulator_consumer_supply omap4_cam2_supply[] = {
REGULATOR_SUPPLY("cam2pwr", NULL),
};
static struct regulator_init_data omap4_vaux3_idata = {
.constraints = {
.min_uV = 1000000,
.max_uV = 3000000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_cam2_supply),
.consumer_supplies = omap4_cam2_supply,
};
static struct regulator_consumer_supply omap4_vmmc_supply[] = {
REGULATOR_SUPPLY("vmmc", "omap_hsmmc.0"),
};
/* VMMC1 for MMC1 card */
static struct regulator_init_data omap4_vmmc_idata = {
.constraints = {
.min_uV = 1200000,
.max_uV = 3000000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_vmmc_supply),
.consumer_supplies = omap4_vmmc_supply,
};
static struct regulator_init_data omap4_vpp_idata = {
.constraints = {
.min_uV = 1800000,
.max_uV = 2500000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
};
static struct regulator_init_data omap4_vusim_idata = {
.constraints = {
.min_uV = 1200000,
.max_uV = 2900000,
.apply_uV = true,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
| REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
};
static struct regulator_init_data omap4_vana_idata = {
.constraints = {
.min_uV = 2100000,
.max_uV = 2100000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.always_on = true,
.state_mem = {
.enabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
};
static struct regulator_consumer_supply omap4_vcxio_supply[] = {
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dss"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.1"),
};
static struct regulator_init_data omap4_vcxio_idata = {
.constraints = {
.min_uV = 1800000,
.max_uV = 1800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.always_on = true,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_vcxio_supply),
.consumer_supplies = omap4_vcxio_supply,
.supply_regulator = "V2V1",
};
static struct regulator_consumer_supply omap4_vusb_supply[] = {
REGULATOR_SUPPLY("vusb", "twl6030_usb"),
};
static struct regulator_init_data omap4_vusb_idata = {
.constraints = {
.min_uV = 3300000,
.max_uV = 3300000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_vusb_supply),
.consumer_supplies = omap4_vusb_supply,
};
static struct regulator_init_data omap4_clk32kg_idata = {
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
.always_on = true,
},
};
static struct regulator_consumer_supply omap4_v1v8_supply[] = {
REGULATOR_SUPPLY("vio", "1-004b"),
};
static struct regulator_init_data omap4_v1v8_idata = {
.constraints = {
.min_uV = 1800000,
.max_uV = 1800000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.always_on = true,
.state_mem = {
.enabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_v1v8_supply),
.consumer_supplies = omap4_v1v8_supply,
};
static struct regulator_consumer_supply omap4_v2v1_supply[] = {
REGULATOR_SUPPLY("v2v1", "1-004b"),
};
static struct regulator_init_data omap4_v2v1_idata = {
.constraints = {
.min_uV = 2100000,
.max_uV = 2100000,
.valid_modes_mask = REGULATOR_MODE_NORMAL
| REGULATOR_MODE_STANDBY,
.valid_ops_mask = REGULATOR_CHANGE_MODE
| REGULATOR_CHANGE_STATUS,
.always_on = true,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_v2v1_supply),
.consumer_supplies = omap4_v2v1_supply,
};
static struct regulator_init_data omap4_ext_v2v1_idata = {
.constraints = {
.min_uV = 2100000,
.max_uV = 2100000,
.valid_modes_mask = REGULATOR_MODE_NORMAL,
},
.num_consumer_supplies = ARRAY_SIZE(omap4_v2v1_supply),
.consumer_supplies = omap4_v2v1_supply,
.supply_regulator = "SYSEN",
};
static struct regulator_init_data omap4_sysen_idata = {
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
.always_on = true,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
};
static struct regulator_init_data omap4_clk32kaudio_idata = {
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
.always_on = true,
},
};
static struct regulator_init_data omap4_regen1_idata = {
.constraints = {
.valid_ops_mask = REGULATOR_CHANGE_STATUS,
.always_on = true,
.state_mem = {
.disabled = true,
},
.initial_state = PM_SUSPEND_MEM,
},
};
static struct twl6030_thermal_data omap4_thermal_pdata = {
.hotdie_cfg = TWL6030_HOTDIE_130C,
};
void __init omap4_pmic_get_config(struct twl4030_platform_data *pmic_data,
u32 pdata_flags, u32 regulators_flags)
{
if (!pmic_data->irq_base)
pmic_data->irq_base = TWL6030_IRQ_BASE;
if (!pmic_data->irq_end)
pmic_data->irq_end = TWL6030_IRQ_END;
/* Common platform data configurations */
if (pdata_flags & TWL_COMMON_PDATA_USB && !pmic_data->usb)
pmic_data->usb = &omap4_usb_pdata;
if (pdata_flags & TWL_COMMON_PDATA_BCI && !pmic_data->bci)
pmic_data->bci = &omap4_bci_pdata;
if (pdata_flags & TWL_COMMON_PDATA_MADC && !pmic_data->madc)
pmic_data->madc = &omap4_madc_pdata;
if (pdata_flags & TWL_COMMON_PDATA_THERMAL && !pmic_data->thermal)
pmic_data->thermal = &omap4_thermal_pdata;
/* Common regulator configurations */
if (regulators_flags & TWL_COMMON_REGULATOR_VDAC) {
if (!pmic_data->vdac)
pmic_data->vdac = &omap4_vdac_idata;
if (!pmic_data->ldoln)
pmic_data->ldoln = &omap4_vdac_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VAUX1) {
if (!pmic_data->vaux1)
pmic_data->vaux1 = &omap4_vaux1_idata;
if (!pmic_data->ldo2)
pmic_data->ldo2 = &omap4_vaux1_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VAUX2) {
if (!pmic_data->vaux2)
pmic_data->vaux2 = &omap4_vaux2_idata;
if (!pmic_data->ldo4)
pmic_data->ldo4 = &omap4_vaux2_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VAUX3) {
if (!pmic_data->vaux3)
pmic_data->vaux3 = &omap4_vaux3_idata;
if (!pmic_data->ldo3)
pmic_data->ldo3 = &omap4_vaux3_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VMMC) {
if (!pmic_data->vmmc)
pmic_data->vmmc = &omap4_vmmc_idata;
if (!pmic_data->ldo5)
pmic_data->ldo5 = &omap4_vmmc_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VPP) {
if (!pmic_data->vpp)
pmic_data->vpp = &omap4_vpp_idata;
if (!pmic_data->ldo1)
pmic_data->ldo1 = &omap4_vpp_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VUSIM) {
if (!pmic_data->vusim)
pmic_data->vusim = &omap4_vusim_idata;
if (!pmic_data->ldo7)
pmic_data->ldo7 = &omap4_vusim_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VANA && !pmic_data->vana)
pmic_data->vana = &omap4_vana_idata;
if (regulators_flags & TWL_COMMON_REGULATOR_VCXIO) {
if (!pmic_data->vcxio)
pmic_data->vcxio = &omap4_vcxio_idata;
if (!pmic_data->ldo6)
pmic_data->ldo6 = &omap4_vcxio_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_VUSB) {
if (!pmic_data->vusb)
pmic_data->vusb = &omap4_vusb_idata;
if (!pmic_data->ldousb)
pmic_data->ldousb = &omap4_vusb_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KG &&
!pmic_data->clk32kg)
pmic_data->clk32kg = &omap4_clk32kg_idata;
if (regulators_flags & TWL_COMMON_REGULATOR_V1V8) {
if (!pmic_data->v1v8)
pmic_data->v1v8 = &omap4_v1v8_idata;
if (!pmic_data->smps4)
pmic_data->smps4 = &omap4_v1v8_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_V2V1) {
if (!pmic_data->v2v1)
pmic_data->v2v1 = &omap4_v2v1_idata;
if (!pmic_data->ext_v2v1)
pmic_data->ext_v2v1 = &omap4_ext_v2v1_idata;
}
if (regulators_flags & TWL_COMMON_REGULATOR_SYSEN &&
!pmic_data->sysen)
pmic_data->sysen = &omap4_sysen_idata;
if (regulators_flags & TWL_COMMON_REGULATOR_CLK32KAUDIO &&
!pmic_data->clk32kaudio)
pmic_data->clk32kaudio = &omap4_clk32kaudio_idata;
if (regulators_flags & TWL_COMMON_REGULATOR_REGEN1 &&
!pmic_data->regen1)
pmic_data->regen1 = &omap4_regen1_idata;
}
#endif /* CONFIG_ARCH_OMAP4 */
/**
* omap_pmic_register_data() - Register the PMIC information to OMAP mapping
* @map: array ending with a empty element representing the maps
*/
int __init omap_pmic_register_data(struct omap_pmic_map *map)
{
struct voltagedomain *voltdm;
int r;
if (!map)
return 0;
while (map->name) {
if (cpu_is_omap34xx() && !(map->cpu & PMIC_CPU_OMAP3))
goto next;
if (cpu_is_omap443x() && !(map->cpu & PMIC_CPU_OMAP4430))
goto next;
if (cpu_is_omap446x() && !(map->cpu & PMIC_CPU_OMAP4460))
goto next;
if (cpu_is_omap447x() && !(map->cpu & PMIC_CPU_OMAP4470))
goto next;
if (cpu_is_omap54xx() && !(map->cpu & PMIC_CPU_OMAP54XX))
goto next;
voltdm = voltdm_lookup(map->name);
if (IS_ERR_OR_NULL(voltdm)) {
pr_err("%s: unable to find map %s\n", __func__,
map->name);
goto next;
}
if (IS_ERR_OR_NULL(map->pmic_data)) {
pr_warning("%s: domain[%s] has no pmic data\n",
__func__, map->name);
goto next;
}
r = omap_voltage_register_pmic(voltdm, map->pmic_data);
if (r) {
pr_warning("%s: domain[%s] register returned %d\n",
__func__, map->name, r);
goto next;
}
if (map->special_action) {
r = map->special_action(voltdm);
WARN(r, "%s: domain[%s] action returned %d\n", __func__,
map->name, r);
}
next:
map++;
}
return 0;
}
|
Kuzma30/NT34K
|
arch/arm/mach-omap2/twl-common.c
|
C
|
gpl-2.0
| 22,908
|
//-----------------------------------------------------------------------------
//
// $Id: CudaUtils.h 874 2014-09-08 02:21:29Z weegreenblobbie $
//
// Nsound is a C++ library and Python module for audio synthesis featuring
// dynamic digital filters. Nsound lets you easily shape waveforms and write
// to disk or plot them. Nsound aims to be as powerful as Csound but easy to
// use.
//
// Copyright (c) 2008 to Present Nick Hilton
//
// weegreenblobbie2_gmail_com (replace '_' with '@' and '.')
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// This program 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 2 of the License, or
// (at your option) any later version.
//
// This program 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 Library General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//-----------------------------------------------------------------------------
#ifndef _NSOUND_CUDA_UTILS_H_
#define _NSOUND_CUDA_UTILS_H_
namespace Nsound
{
//-----------------------------------------------------------------------------
// Magic macro to check for cuda errors.
#define checkForCudaError() \
{ \
cudaError_t ecode = cudaGetLastError(); \
if(ecode) \
{ \
printf("%s:%3d: Error: %s\n", \
__FILE__, \
__LINE__, \
cudaGetErrorString(ecode)); \
} \
}
struct Context
{
enum State
{
BOOTING_ = 1,
INITALIZED_ = 10,
UNLOADED_ = 20,
ERROR_ = 30,
};
static State state_;
//! Initialize the card once.
void
init(int flags = 0);
};
} // namespace
#endif
// :mode=c++: jEdit modeline
|
weegreenblobbie/nsound
|
src/Nsound/CudaUtils.h
|
C
|
gpl-2.0
| 2,492
|
/* header file for bd-imp.c --
* test code for bd-imp.c
* Copyright (C) 2007 Kengo Ichiki <kichiki@users.sourceforge.net>
* $Id: check-bd-imp.h,v 1.1 2007/12/12 06:31:52 kichiki Exp $
*
* This program 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 2
* of the License, or (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _CHECK_BD_IMP_H_
#define _CHECK_BD_IMP_H_
int
check_BD_evolve_JGdP00 (int version, int flag_lub, int flag_mat,
int flag_Q, double dt,
int verbose, double tiny);
int
check_BD_imp_ode_evolve (int version, int flag_lub, int flag_mat,
int flag_Q, double dt, double t_out,
int verbose, double tiny);
#endif /* !_CHECK_BD_IMP_H_ */
|
kichiki/libstokes
|
test/check-bd-imp.h
|
C
|
gpl-2.0
| 1,264
|
<!DOCTYPE html>
<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head lang="en-US">
<title>My Family Tree - Wong, Jane</title>
<meta charset="UTF-8" />
<meta name ="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1" />
<meta name ="apple-mobile-web-app-capable" content="yes" />
<meta name="generator" content="Gramps 4.2.2 http://gramps-project.org/" />
<meta name="author" content="" />
<link href="../../../images/favicon2.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../../css/narrative-screen.css" media="screen" rel="stylesheet" type="text/css" />
<link href="../../../css/narrative-print.css" media="print" rel="stylesheet" type="text/css" />
<link href="../../../css/ancestortree.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<h1 id="SiteTitle">My Family Tree</h1>
</div>
<div class="wrapper" id="nav" role="navigation">
<div class="container">
<ul class="menu" id="dropmenu">
<li class = "CurrentSection"><a href="../../../individuals.html" title="Individuals">Individuals</a></li>
<li><a href="../../../index.html" title="Surnames">Surnames</a></li>
<li><a href="../../../families.html" title="Families">Families</a></li>
<li><a href="../../../places.html" title="Places">Places</a></li>
<li><a href="../../../sources.html" title="Sources">Sources</a></li>
<li><a href="../../../repositories.html" title="Repositories">Repositories</a></li>
<li><a href="../../../media.html" title="Media">Media</a></li>
<li><a href="../../../thumbnails.html" title="Thumbnails">Thumbnails</a></li>
<li><a href="../../../addressbook.html" title="Address Book">Address Book</a></li>
</ul>
</div>
</div>
<div class="content" id="IndividualDetail">
<h3>Wong, Jane<sup><small> <a href="#sref1">1</a></small></sup></h3>
<div id="summaryarea">
<table class="infolist">
<tr>
<td class="ColumnAttribute">Birth Name</td>
<td class="ColumnValue">
Wong, Jane
</td>
</tr>
<tr>
<td class="ColumnAttribute">Gramps ID</td>
<td class="ColumnValue">I1600</td>
</tr>
<tr>
<td class="ColumnAttribute">Gender</td>
<td class="ColumnValue">female</td>
</tr>
</table>
</div>
<div class="subsection" id="families">
<h4>Families</h4>
<table class="infolist">
<tr class="BeginFamily">
<td class="ColumnType"> </td>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue"><a href="../../../fam/b/h/AOOKQCKYIBDI1HKGHB.html" title="Family of Benson, Samuel Sr. and Wong, Jane">Family of Benson, Samuel Sr. and Wong, Jane<span class="grampsid"> [F0515]</span></a></td>
</tr>
<tr class="BeginFamily">
<td class="ColumnType">Married</td>
<td class="ColumnAttribute">Husband</td>
<td class="ColumnValue">
<a href="../../../ppl/9/y/0OOKQCSCEUA85DM2Y9.html">Benson, Samuel Sr.<span class="grampsid"> [I1599]</span></a>
</td>
</tr>
<tr>
<td class="ColumnType"> </td>
<td class="ColumnAttribute"> </td>
<td class="ColumnValue">
<table class="infolist eventlist">
<thead>
<tr>
<th class="ColumnEvent">Event</th>
<th class="ColumnDate">Date</th>
<th class="ColumnPlace">Place</th>
<th class="ColumnDescription">Description</th>
<th class="ColumnNotes">Notes</th>
<th class="ColumnSources">Sources</th>
</tr>
</thead>
<tbody>
<tr>
<td class="ColumnEvent">
Marriage
</td>
<td class="ColumnDate"> </td>
<td class="ColumnPlace"> </td>
<td class="ColumnDescription">
Marriage of Benson, Samuel Sr. and Wong, Jane
</td>
<td class="ColumnNotes">
<div>
</div>
</td>
<td class="ColumnSources">
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
</div>
<div class="subsection" id="pedigree">
<h4>Pedigree</h4>
<ol class="pedigreegen">
<li>
<ol>
<li class="thisperson">
Wong, Jane
<ol class="spouselist">
<li class="spouse">
<a href="../../../ppl/9/y/0OOKQCSCEUA85DM2Y9.html">Benson, Samuel Sr.<span class="grampsid"> [I1599]</span></a>
</li>
</ol>
</li>
</ol>
</li>
</ol>
</div>
<div class="subsection" id="sourcerefs">
<h4>Source References</h4>
<ol>
<li>
<a href="../../../src/x/a/X5TJQC9JXU4RKT6VAX.html" title="Import from test2.ged" name ="sref1">
Import from test2.ged
<span class="grampsid"> [S0003]</span>
</a>
</li>
</ol>
</div>
</div>
<div class="fullclear"></div>
<div id="footer">
<p id="createdate">
Generated by <a href="http://gramps-project.org/">Gramps</a> 4.2.2 on 2015-12-25<br />Last change was the 2007-07-26 08:34:25<br />Created for <a href="../../../ppl/h/o/GNUJQCL9MD64AM56OH.html">Garner von Zieliński, Lewis Anderson Sr</a>
</p>
<p id="copyright">
</p>
</div>
</body>
</html>
|
belissent/testing-example-reports
|
gramps42/gramps/example_NAVWEB1/ppl/r/3/GOOKQC6AVMQO31SP3R.html
|
HTML
|
gpl-2.0
| 5,168
|
/**
* @file
* Site Footer styles.
*/
.l-footer {
margin: 1.5rem 0 0;
}
.l-footer a {
text-decoration: none;
}
.l-footer a:hover,
.l-footer a:focus {
text-decoration: underline;
}
/**
* Footer menu styles
*/
.l-footer .menu,
.l-footer .menu li {
list-style: none;
margin: 0;
padding: 0;
}
.l-footer .menu:after {
/* Clearfix menus */
content: '';
display: table;
clear: both;
}
.l-footer .menu > li {
float: left;
}
[dir="rtl"] .l-footer .menu > li {
float: right;
}
.l-footer .menu a {
display: block;
padding: 0 1rem;
}
/**
* Powered by Backdrop Block
*/
.l-footer .block-system-powered-by a {
text-decoration: none;
}
.l-footer .block-system-powered-by a:hover {
text-decoration: underline;
}
.drop-lounging {
position: relative;
/* To make Drop larger/smaller, adjust the width below. */
width: 7em;
}
.drop-lounging:before {
content: '';
position: absolute;
top: -0.75em;
left: 50%;
left: calc(50% + 1.25em);
display: none; /* Default hidden unless certain criteria are met */
box-sizing: content-box;
width: 100%;
height: 0;
margin: 0;
padding: 0 0 52%;
-webkit-transform: translate(-50%, -82%);
transform: translate(-50%, -82%);
background: url("../../images/drop-lounging.png") no-repeat;
background-size: 100% auto;
}
.l-footer .block:first-child .drop-lounging:before {
display: block;
}
|
backdrop-ops/backdrop-pantheon
|
core/themes/basis/css/component/footer.css
|
CSS
|
gpl-2.0
| 1,386
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Qt 4.3: OpenGL in an HTML page</title>
<link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 class="title">OpenGL in an HTML page<br /><span class="subtitle"></span>
</h1>
<SCRIPT LANGUAGE="JavaScript">
function setRot( form )
{
GLBox.setXRotation( form.XEdit.value );
GLBox.setYRotation( form.YEdit.value );
GLBox.setZRotation( form.ZEdit.value );
}
</SCRIPT>
<p />
An OpenGL scene:<br />
<object ID="GLBox" CLASSID="CLSID:5fd9c22e-ed45-43fa-ba13-1530bb6b03e0"
CODEBASE="http://www.trolltech.com/demos/openglax.cab">
[Object not available! Did you forget to build and register the server?]
</object><br />
<form>
Rotate the scene:<br />
X:<input type="edit" ID="XEdit" value="0" /><br />
Y:<input type="edit" name="YEdit" value="0" /><br />
Z:<input type="edit" name="ZEdit" value="0" /><br />
<input type="button" value="Set" onClick="setRot(this.form)" />
</form>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright © 2008 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.3.6</div></td>
</tr></table></div></address></body>
</html>
|
muromec/qtopia-ezx
|
doc/html/qaxserver-demo-opengl.html
|
HTML
|
gpl-2.0
| 2,502
|
package mexica.multiplayer.core;
import mexica.core.utilities.DataBuilder;
import mexica.multiplayer.core.CommStandards.CommChat;
import mexica.multiplayer.core.CommStandards.CommConnection;
import mexica.multiplayer.core.CommStandards.CommGameLobby;
import mexica.multiplayer.core.CommStandards.CommOnlineGame;
import mexica.multiplayer.core.CommStandards.CommServer;
public final class PacketType {
public static final int UNDEFINED = 00;
/** Packets a Server sends. */
public static class Server {
/** Packets about the connection with the client. */
public static class Connection {
/** Packets about authentication of the client. */
public static class Authentication {
/**
* Packet containing new token for the client. "to" specifies a
* token.
*/
public static final int Token = -10;
public static final Packet generateTokenPacket(String token) {
return new Packet(Token, new DataBuilder()
.add(CommConnection.Token).wrap(token).getString());
}
/** Packets about the user login of a client. */
public static class Login {
/**
* Packet containing response for authentication request of
* the client. "a" specifies either "true" or "false".
*/
// public static final int Response = -20;
public static final int Response = -1
* PacketType.Client.Connection.Authentication.Login.Request;
public static final Packet generateResponsePacket(
boolean answer) {
return new Packet(Response, new DataBuilder()
.add(CommConnection.Answer)
.wrap(CommStandards.parseBoolean(answer))
.getString());
}
}
/** Packets about registering the client as a new user. */
public static class Register {
/**
* Packet containing response for register request of the
* client. "a" specifies either "t" or "f".
*/
// public static final int Response = -60;
public static final int Response = -1
* PacketType.Client.Connection.Authentication.Register.Request;
public static final Packet generateResponsePacket(
boolean answer) {
return new Packet(Response, new DataBuilder()
.add(CommConnection.Answer)
.wrap(CommStandards.parseBoolean(answer))
.getString());
}
}
}
/**
* Packet telling the client it has been kicked from the server.
* Does not actually kick the client. "r" specifies the reason.
*/
public static final int Kick = -30;
public static final Packet generateKickPacket(String reason) {
return new Packet(Kick, new DataBuilder()
.add(CommConnection.Reason).wrap(reason).getString());
}
/**
* Packet telling other clients a new client has joined. "u"
* specifies the username of the client.
*/
public static final int Join = -40;
public static final Packet generateJoinPacket(String username) {
return new Packet(Join, new DataBuilder()
.add(CommConnection.Username).wrap(username)
.getString());
}
/**
* Packet telling other clients a client has left the server. "u"
* specifies the username of the client.
*/
public static final int Leave = -50;
public static final Packet generateLeavePacket(String username) {
return new Packet(Leave, new DataBuilder()
.add(CommConnection.Username).wrap(username)
.getString());
}
/**
* Friendly version of Kick. Packet telling the client the reason
* for a disconnect from the server. "r" specifies the reason.
*/
public static final int Disconnect = -70;
public static final Packet generateDisconnectPacket(String reason) {
return new Packet(Disconnect, new DataBuilder()
.add(CommConnection.Reason).wrap(reason).getString());
}
}
/** Packets about chat messages from the server */
public static class Chat {
/**
* General packet used for chatting on the server. "s" is the
* username of the sender of the message. "m" is the message.
*/
public static final int General = 140;
public static final Packet generateGeneralChatPacket(
String sendersname, String message) {
return new Packet(General, new DataBuilder()
.add(CommChat.Sender).wrap(sendersname)
.add(CommChat.ChatMessage).wrap(message).getString());
}
/**
* Packet containing a chat message for all clients inside a game.
* data[0] must contain chat message.
*/
@Deprecated
public static final int Game = -110;
/**
* Packet containing a chat message for all clients on a server.
* data[0] must contain a chat message.
*/
@Deprecated
public static final int Server = -120;
/**
* Packet containing a personal message for a client. data[0]
* specifies the message.
*/
@Deprecated
public static final int Personal = -130;
}
/**
* Packets about the state of a Game. Not about GamePlay!
*
* @see Play
*/
public static class GameLobby {
public static class Join {
/**
* Packet containing a response to a Join Request of a client.
* "a" must contain either "true" or "false".
*/
// public static final int Response = -210;
public static final int Response = -1
* PacketType.Client.GameLobby.Join.Request;
public static final Packet generateResponsePacket(boolean answer) {
return new Packet(Response, new DataBuilder()
.add(CommConnection.Answer)
.wrap(CommStandards.parseBoolean(answer))
.getString());
}
}
/**
* Packet containing the new game settings for all (potential)
* players of a lobby. "ls" specifies the new lobbysettings.
*/
public static final int LobbySettings = -220;
public static final Packet generateLobbySettingsPacket(
String lobbysettings) {
return new Packet(LobbySettings, new DataBuilder()
.add(CommGameLobby.GameLobbySettings)
.wrap(lobbysettings).getString());
}
/**
* Packet telling a client it has been kicked from the lobby. "r"
* specifies the reason.
*/
public static final int Kick = -230;
public static final Packet generateKickPacket(String reason) {
return new Packet(Kick, new DataBuilder()
.add(CommConnection.Reason).wrap(reason).getString());
}
/**
* Packet telling other players of a game the status of the game
* changed. "s" specifies the status of the onlinegame.
*/
public static final int Status = -240;
public static final Packet generateGameStatusPacket(String status) {
return new Packet(Status, new DataBuilder()
.add(CommGameLobby.Status).wrap(status).getString());
}
/**
* Packet telling other clients a new lobby has been created. "n"
* specifies the lobbys name. "a" specifies the username of the
* lobby host. "ls" specifies the lobbysettings.
*/
public static final int Create = -250;
public static final Packet generateLobbyCreatePacket(
String gamesname, String admin, String lobbysettings) {
return new Packet(Create, new DataBuilder()
.add(CommGameLobby.GameLobbyName).wrap(gamesname)
.add(CommGameLobby.Admin).wrap(admin)
.add(CommGameLobby.GameLobbySettings)
.wrap(lobbysettings).getString());
}
/**
* Packet telling other clients a lobby has been removed. "n"
* specifies the lobbys name. "a" specifies the user of the lobby
* host.
*/
public static final int Remove = -260;
public static final Packet generateLobbyRemovePacket(
String gamesname, String admin) {
return new Packet(Remove, new DataBuilder()
.add(CommGameLobby.GameLobbyName).wrap(gamesname)
.add(CommGameLobby.Admin).wrap(admin).getString());
}
/** Packet telling other players the status of the client. */
@Deprecated
public static final int ClientStatus = -270;
}
/** Packets concerning the gameplay. */
public static class Play {
/** Packets concerning actions in the game. */
public static class GameAction {
/** Packets concerning the verification of a players action. */
public static class Verification {
/**
* Packet containing a response to a verification request of
* a client. "a" must specify the playeraction. data[1] must
* specify the answer: "true" or "false".
*/
// public static final int Response = -310;
public static final int Response = -1
* PacketType.Client.Play.GameAction.Verification.Request;
public static final Packet generateResponsePacket(
boolean answer) {
return new Packet(Response, new DataBuilder()
.add(CommConnection.Answer)
.wrap(CommStandards.parseBoolean(answer))
.getString());
}
/**
* Packet requesting the verification of a players action.
* "ga" must specify the gameaction.
*/
public static final int Request = -320;
public static final Packet generateRequestPacket(
String gameaction) {
return new Packet(
Request,
new DataBuilder()
.add(CommOnlineGame.CommOnlineGameAction.OnlineGameAction)
.wrap(gameaction).getString());
}
}
/**
* Packet telling players an action has been done. "ga" must
* specify the gameaction.
*/
public static final int Do = -330;
public static final Packet generateDoPacket(String gameaction) {
return new Packet(
Do,
new DataBuilder()
.add(CommOnlineGame.CommOnlineGameAction.OnlineGameAction)
.wrap(gameaction).getString());
}
/**
* Packet telling players an action has been undone. "ga" must
* specify the gameaction.
*/
public static final int Undo = -340;
public static final Packet generateUndoPacket(String gameaction) {
return new Packet(
Undo,
new DataBuilder()
.add(CommOnlineGame.CommOnlineGameAction.OnlineGameAction)
.wrap(gameaction).getString());
}
}
}
/** Packets sending server info. */
public static class Info {
/**
* Packet sending the version of the server. "sv" must specify the
* version.
*/
public static final int ServerVersion = -410;
public static final Packet generateServerVersionPacket() {
return new Packet(ServerVersion, new DataBuilder()
.add(CommServer.ServerVersion)
.wrap(mexica.multiplayer.server.Server.VERSION)
.getString());
}
/**
* Packet sending a list of all online players on the server. "ps"
* specifies the list.
*/
public static final int OnlinePlayers = -420;
public static final Packet generateOnlinePlayersPacket(
String onlineplayers) {
return new Packet(OnlinePlayers, new DataBuilder()
.add(CommServer.OnlinePlayers).wrap(onlineplayers)
.getString());
}
/**
* Packet sending a list of all running games, including the
* username of the host. "l" specifies the list.
*/
public static final int Lobbys = -430;
public static final Packet generateLobbysInfoPacket(
String lobbysinfo) {
return new Packet(Lobbys, new DataBuilder()
.add(CommServer.Lobbys).wrap(lobbysinfo).getString());
}
}
}
/** Packets a client sends. */
public static class Client {
/**
* Packets concerning the connection with the server. The type (int)
* ranges from 1 till 11.
*/
public static class Connection {
/** Packets concerning authentication with the server. */
public static class Authentication {
/** Packets concerning the login protocol */
public static class Login {
/**
* Packet requesting to log in on the server. data[0] is the
* username data[1] is the password, hashed with the token
* received from the server.
*/
public static final int Request = 20;
}
/** Packets concerning a new user. */
public static class Register {
/**
* Packet requesting a new User account on the server.
* data[0] is the username data[1] is the password, hashed
* with the token received from the server.
*/
public static final int Request = 60;
}
}
/** Packet telling the server ??? */
@Deprecated
public static final int Disconnect = 70;
}
/**
* Packets concerning chatting. The type (int) ranges from 11 till 21.
*/
public static class Chat {
/**
* General packet to chat on the server. data[0] must specify the
* username the message is meant for. data[1] is the message.
*/
public static final int General = 140;
@Deprecated
public static final int Game = 110;
@Deprecated
public static final int Server = 120;
@Deprecated
public static final int Personal = 130;
}
/**
* Packets concerning games on the server The type (int) ranges from 21
* till 31.
*/
public static class GameLobby {
/** Packets concerning joining a game. */
public static class Join {
/**
* Packet requesting to join the game. data[0] is the games
* name.
*/
public static final int Request = 210;
public static final Packet generateRequestPacket(
String gamesname) {
return new Packet(Request, new DataBuilder()
.add(CommOnlineGame.Name).wrap(gamesname)
.getString());
}
}
/**
* Packet updating the settings of a game. data[0] is the new game
* settings.
*/
public static final int LobbySettings = 220;
/**
* Packet kicking a player from a game. data[0] is the players name.
* data[1] is the reason.
*/
public static final int Kick = 230;
/**
* Packet updating the status of a game. data[0] is either "B", "F"
* or "S"
*/
public static final int Status = 240;
/** Packet telling the server it will leave a game. */
public static final int Leave = 280;
/**
* Packet creating a new game on the server. Data contains the lobby
* settings.
*/
public static final int Create = 250;
/** Packet removing a game from the server. */
public static final int Remove = 260;
/** Packet ??? */
public static final int ClientStatus = 270;
}
/**
* Packets concerning gameplay. The type (int) ranges from 31 till 41.
*/
public static class Play {
/** Packets concerning game actions. */
public static class GameAction {
/** Packets concerning the verification of game actions; */
public static class Verification {
/**
* Packet giving a response to a verification from the
* server. data[0] is the players action. data[1] is the
* answer, either "T" or "F".
*/
// public static final int Response = 310;
public static final int Response = -1
* PacketType.Server.Play.GameAction.Verification.Request;
/**
* Packet request the validation of a players action.
* data[0] is the players action.
*/
public static final int Request = 320;
}
/**
* Packet requesting to do a clients action in a game. data[0]
* is the playeraction.
*/
public static final int Do = 330;
/**
* Packet requesting to undo a clients action in a game. data[0]
* is the playeraction.
*/
public static final int Undo = 340;
}
}
/**
* Packets concerning the server info. The type (int) ranges from 41
* till 51.
*/
public static class Info {
/** Packet requesting the version of the server. */
public static final int ServerVersion = 410;
/** Packet requesting a list of online players. */
public static final int OnlinePlayers = 420;
/** Packet requesting a list of running games. */
public static final int Lobbys = 430;
}
}
public static boolean isConnectionPacket(int packettype) {
packettype = Math.abs(packettype);
return (packettype > 00 && packettype < 110);
}
public static boolean isChatPacket(int packettype) {
packettype = Math.abs(packettype);
return (packettype > 100 && packettype < 210);
}
public static boolean isGamePacket(int packettype) {
packettype = Math.abs(packettype);
return (packettype > 200 && packettype < 310);
}
public static boolean isPlayPacket(int packettype) {
packettype = Math.abs(packettype);
return (packettype > 300 && packettype < 410);
}
public static boolean isInfoPacket(int packettype) {
packettype = Math.abs(packettype);
return (packettype > 400 && packettype < 510);
}
}
|
Burglory/MexicaJavaServer
|
src/mexica/multiplayer/core/PacketType.java
|
Java
|
gpl-2.0
| 16,393
|
Title: Transports en commun et développement personnel
Date: 2010-01-12 00:21
Tags: Mobilité
La semaine prochaine sera un gros changement de rythme, je commence un nouveau
job à Marseille. Et, chose qui ne m'est pas arrivé depuis mes années
d'étudiant, je n'utiliserais pas ma voiture mais le train... parce que c'est
enfin possible. Je m'en réjouis car après des années à passer le trajet en
écoutant seulement la radio, j'ai enfin l'opportunité de mettre ce temps à
profit au lieu de le subir. Je pense flux RSS, Podcasts et eBooks.
Pour les flux RSS, c'est rôdé depuis longtemps, j'ai un peu étoffé mes
abonnements et je consommerais depuis mon Nokia E61i avec Opera Mini / Google
Reader.
Pour la musique et les podcasts j'ai d'abord eu le stigmate du consommateur en
période de soldes : j'ai envisagé investir dans un lecteur mp3/mp4. A la
réflexion, ce sont des frais en plus, un 2ème appareil à recharger le soir,
une synchronisation avec l'ordinateur quotidienne, un certain nombre
d'inconvénients. J'ai alors regardé ce Nokia E61i sous Symbian 3 acheté
d'occasion l'année dernière : il n'est certes pas tendance au regard de la
marée iPhone / Android qui déferle, mais il répond à 100% de mes besoins :
- gérer les couriels de mon compte Gmail en Imap (avec Profimail qui fournit un
logiciel de grande qualité pour un prix raisonnable),
- naviguer sur des sites pas trop complexes (merci Opera Mini ),
- envoyer des SMS avec un vrai clavier AZERTY.
Et je me suis dit que je ne l'avais pas encore poussé dans ses retranchements.
Après quelques heures de recherche, j'ai rajouté :
* un excellent lecteur audio sous licence GPL qui lit les formats mp3 et ogg :
OggPlay
* une grande découverte pour moi malgré que ce soit sorti depuis un bout de
temps : un vrai logiciel de gestion de podcasts, Nokia Podcasting, capable de
gérer les abonnements et les téléchargements par Wifi de manière autonome..
un vrai bijou.
* le classique des lecteurs d'eBooks MobiReader qui fait bien son travail : on
peut jouer sur la taille des polices, lire en plein écran (important vu sa
taille modeste). Ce que je cherche maintenant c'est une manière de convertir
quelques PDF au format LRC depuis GNU/Linux bien sûr :-) si quelqu'un a une
bonne technique merci de me laisser un commentaire :-)
Je pense être paré, il me reste à alimenter mes nouveaux logiciels avec du
bon contenu pour transformer ces temps de transport en temps profitable.
|
kianby/pecosys
|
site/blogduyax/content/2010/0012.transports-en-commun-et-developpement-personnel.md
|
Markdown
|
gpl-2.0
| 2,507
|
/*
* Author: MontaVista Software, Inc. <source@mvista.com>
*
* 2007 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#include <linux/init.h>
#include <linux/mvl_patch.h>
static __init int regpatch(void)
{
return mvl_register_patch(279);
}
module_init(regpatch);
|
xoox/linux-2.6.18_pro500
|
mvl_patches/pro50-0279.c
|
C
|
gpl-2.0
| 446
|
package org.twd2.game.HelloParticle.Physics;
import org.twd2.game.HelloParticle.Math.Vector2D;
public class Particle {
public Vector2D acceleration=Vector2D.zero.clone(),
velocity=Vector2D.zero.clone(),
position=Vector2D.zero.clone(),
force=Vector2D.zero.clone(),
userForce=Vector2D.zero.clone();
public double m, q;
public boolean enable=true, flag=false, enableColl=true;
public boolean fixed=false;
public Vector2D lastColl=null;
public Particle(double m){
this.m=m;
}
public Particle(double m, Vector2D position){
this.m=m;
this.position=position;
}
public void move(double dt) {
if (fixed) return;
position=position.add(velocity.mul(dt).add(acceleration.mul(0.5d*dt*dt))); //delta=v0*t+1/2*a*t*t
}
public Vector2D newPosition(double dt) {
if (fixed) return position;
return position.add(velocity.mul(dt).add(acceleration.mul(0.5d*dt*dt))); //delta=v0*t+1/2*a*t*t
}
/**
* 不足
* @param dt
* @return
*/
public Vector2D newPositionEstimateIn(double dt) {
if (fixed) return position;
return position.add(velocity.mul(dt)); //delta=v0*t
}
/**
* 过剩
* @param dt
* @return
*/
public Vector2D newPositionEstimateEx(double dt) {
if (fixed) return position;
return position.add(velocity.add(acceleration.mul(dt)).mul(dt)); //delta=(v0+at)*t
}
/**
* 不足
* @param dt
* @return
*/
public Vector2D newVelocityEstimateIn(double dt) {
if (fixed) return position;
return velocity; //delta=v0*t
}
/**
* 过剩
* @param dt
* @return
*/
public Vector2D newVelocityEstimateEx(double dt) {
if (fixed) return position;
return velocity.add(acceleration.mul(dt)); //delta=(v0+at)*t
}
public void addForce(Vector2D f) {
userForce=userForce.add(f);
}
}
|
twd2/HelloParticle
|
src/org/twd2/game/HelloParticle/Physics/Particle.java
|
Java
|
gpl-2.0
| 1,799
|
all:
gcc -Wall -O2 lock.c -lpthread
|
gurugio/caos
|
docs/spinlock_test/Makefile
|
Makefile
|
gpl-2.0
| 39
|
var searchData=
[
['extensionimagescontentfile',['ExtensionImagesContentFile',['../class_local_search_engine_1_1_file_manager_1_1_file_agent.html#a03463d0a27136f657cd7007781177306',1,'LocalSearchEngine::FileManager::FileAgent']]],
['extensionimagesfile',['ExtensionImagesFile',['../class_local_search_engine_1_1_file_manager_1_1_file_agent.html#a71c001aa2c25052285cfc06477cae793',1,'LocalSearchEngine::FileManager::FileAgent']]],
['extensiononlytextfile',['ExtensionOnlyTextFile',['../class_local_search_engine_1_1_file_manager_1_1_file_agent.html#a2a66883935cd583998622bad289f99a2',1,'LocalSearchEngine::FileManager::FileAgent']]]
];
|
Omarmtz/Perceptual-Hash
|
Docs/Documentation/html/search/variables_0.js
|
JavaScript
|
gpl-2.0
| 641
|
/*
* ALSA Patch Bay
*
* Copyright (C) 2002 Robert Ham (node@users.sourceforge.net)
*
* You have permission to use this file under the GNU General
* Public License, version 2 or later. See the file COPYING
* for the full text.
*
*/
#ifndef __APB_ALSA_DRIVER_H__
#define __APB_ALSA_DRIVER_H__
#include <list>
#include <string>
#include <iostream>
#include <alsa/asoundlib.h>
#include <pthread.h>
#include "apb.h"
#include "driver.h"
#include "subscription.h"
#include "addr.h"
#include "alsa-addr.h"
namespace APB {
namespace Alsa {
class Driver : public APB::Driver {
private:
snd_seq_t * _seq;
std::list<APB::Addr *> _readPorts;
std::list<APB::Addr *> _writePorts;
std::list<APB::Subscription *> _subscriptions;
std::string _title;
void refreshPorts (std::list<APB::Addr *>&, unsigned int);
void doPortSubscription (snd_seq_port_subscribe_t *,
const APB::Addr *,
const APB::Addr *);
void doPortUnsubscription (snd_seq_port_subscribe_t *,
const APB::Addr *,
const APB::Addr *);
int createListenPort ();
void sendRefresh ();
void getEvent ();
pthread_t _listenThread;
public:
Driver (const std::string&, int *, char ***);
virtual ~Driver () {
}
virtual std::string findClientName (const APB::Addr *) const;
virtual std::string findPortName (const APB::Addr *) const;
virtual const std::list<APB::Addr *>& getReadPorts ();
virtual const std::list<APB::Addr *>& getWritePorts ();
virtual const std::list<const APB::Subscription *>& getSubscriptions ();
virtual void refreshPorts ();
virtual void refreshSubscriptions ();
virtual void subscribePorts (const APB::Addr *, const APB::Addr *);
virtual void subscribeClients (const APB::Addr *, const APB::Addr *);
virtual void removeSubscription (const Subscription *);
static void * refreshMain (void *);
void refreshIMain (void);
};
} /* namespace Alsa */
} /* namespace APB */
#endif /* __APB_ALSA_DRIVER_H__ */
|
MostAwesomeDude/alsa-patch-bay
|
src/driver/alsa/alsa-driver.h
|
C
|
gpl-2.0
| 2,501
|
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "Memory"
#include "JNIHelp.h"
#include "JniConstants.h"
#include "ScopedBytes.h"
#include "ScopedPrimitiveArray.h"
#include "UniquePtr.h"
#include <byteswap.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <signal.h>
#if defined(__arm__)
// 32-bit ARM has load/store alignment restrictions for longs.
#define LONG_ALIGNMENT_MASK 0x3
#define INT_ALIGNMENT_MASK 0x0
#define SHORT_ALIGNMENT_MASK 0x0
#elif defined(__mips__)
// MIPS has load/store alignment restrictions for longs, ints and shorts.
#define LONG_ALIGNMENT_MASK 0x7
#define INT_ALIGNMENT_MASK 0x3
#define SHORT_ALIGNMENT_MASK 0x1
#elif defined(__i386__)
// x86 can load anything at any alignment.
#define LONG_ALIGNMENT_MASK 0x0
#define INT_ALIGNMENT_MASK 0x0
#define SHORT_ALIGNMENT_MASK 0x0
#else
#error unknown load/store alignment restrictions for this architecture
#endif
// Use packed structures for access to unaligned data on targets with alignment restrictions.
// The compiler will generate appropriate code to access these structures without
// generating alignment exceptions.
template <typename T> static inline T get_unaligned(const T* address) {
struct unaligned { T v; } __attribute__ ((packed));
const unaligned* p = reinterpret_cast<const unaligned*>(address);
return p->v;
}
template <typename T> static inline void put_unaligned(T* address, T v) {
struct unaligned { T v; } __attribute__ ((packed));
unaligned* p = reinterpret_cast<unaligned*>(address);
p->v = v;
}
template <typename T> static T cast(jint address) {
return reinterpret_cast<T>(static_cast<uintptr_t>(address));
}
// Byte-swap 2 jshort values packed in a jint.
static inline jint bswap_2x16(jint v) {
// v is initially ABCD
#if defined(__mips__) && defined(__mips_isa_rev) && (__mips_isa_rev >= 2)
__asm__ volatile ("wsbh %0, %0" : "+r" (v)); // v=BADC
#else
v = bswap_32(v); // v=DCBA
v = (v << 16) | ((v >> 16) & 0xffff); // v=BADC
#endif
return v;
}
static inline void swapShorts(jshort* dstShorts, const jshort* srcShorts, size_t count) {
// Do 32-bit swaps as long as possible...
jint* dst = reinterpret_cast<jint*>(dstShorts);
const jint* src = reinterpret_cast<const jint*>(srcShorts);
if ((reinterpret_cast<uintptr_t>(dst) & INT_ALIGNMENT_MASK) == 0 &&
(reinterpret_cast<uintptr_t>(src) & INT_ALIGNMENT_MASK) == 0) {
for (size_t i = 0; i < count / 2; ++i) {
jint v = *src++;
*dst++ = bswap_2x16(v);
}
// ...with one last 16-bit swap if necessary.
if ((count % 2) != 0) {
jshort v = *reinterpret_cast<const jshort*>(src);
*reinterpret_cast<jshort*>(dst) = bswap_16(v);
}
} else {
for (size_t i = 0; i < count / 2; ++i) {
jint v = get_unaligned<jint>(src++);
put_unaligned<jint>(dst++, bswap_2x16(v));
}
if ((count % 2) != 0) {
jshort v = get_unaligned<jshort>(reinterpret_cast<const jshort*>(src));
put_unaligned<jshort>(reinterpret_cast<jshort*>(dst), bswap_16(v));
}
}
}
static inline void swapInts(jint* dstInts, const jint* srcInts, size_t count) {
if ((reinterpret_cast<uintptr_t>(dstInts) & INT_ALIGNMENT_MASK) == 0 &&
(reinterpret_cast<uintptr_t>(srcInts) & INT_ALIGNMENT_MASK) == 0) {
for (size_t i = 0; i < count; ++i) {
jint v = *srcInts++;
*dstInts++ = bswap_32(v);
}
} else {
for (size_t i = 0; i < count; ++i) {
jint v = get_unaligned<int>(srcInts++);
put_unaligned<jint>(dstInts++, bswap_32(v));
}
}
}
static inline void swapLongs(jlong* dstLongs, const jlong* srcLongs, size_t count) {
jint* dst = reinterpret_cast<jint*>(dstLongs);
const jint* src = reinterpret_cast<const jint*>(srcLongs);
if ((reinterpret_cast<uintptr_t>(dstLongs) & INT_ALIGNMENT_MASK) == 0 &&
(reinterpret_cast<uintptr_t>(srcLongs) & INT_ALIGNMENT_MASK) == 0) {
for (size_t i = 0; i < count; ++i) {
jint v1 = *src++;
jint v2 = *src++;
*dst++ = bswap_32(v2);
*dst++ = bswap_32(v1);
}
} else {
for (size_t i = 0; i < count; ++i) {
jint v1 = get_unaligned<jint>(src++);
jint v2 = get_unaligned<jint>(src++);
put_unaligned<jint>(dst++, bswap_32(v2));
put_unaligned<jint>(dst++, bswap_32(v1));
}
}
}
static void Memory_memmove(JNIEnv* env, jclass, jobject dstObject, jint dstOffset, jobject srcObject, jint srcOffset, jlong length) {
ScopedBytesRW dstBytes(env, dstObject);
if (dstBytes.get() == NULL) {
return;
}
ScopedBytesRO srcBytes(env, srcObject);
if (srcBytes.get() == NULL) {
return;
}
memmove(dstBytes.get() + dstOffset, srcBytes.get() + srcOffset, length);
}
static jbyte Memory_peekByte(JNIEnv*, jclass, jint srcAddress) {
return *cast<const jbyte*>(srcAddress);
}
static void Memory_peekByteArray(JNIEnv* env, jclass, jint srcAddress, jbyteArray dst, jint dstOffset, jint byteCount) {
env->SetByteArrayRegion(dst, dstOffset, byteCount, cast<const jbyte*>(srcAddress));
}
// Implements the peekXArray methods:
// - For unswapped access, we just use the JNI SetXArrayRegion functions.
// - For swapped access, we use GetXArrayElements and our own copy-and-swap routines.
// GetXArrayElements is disproportionately cheap on Dalvik because it doesn't copy (as opposed
// to Hotspot, which always copies). The SWAP_FN copies and swaps in one pass, which is cheaper
// than copying and then swapping in a second pass. Depending on future VM/GC changes, the
// swapped case might need to be revisited.
#define PEEKER(SCALAR_TYPE, JNI_NAME, SWAP_TYPE, SWAP_FN) { \
if (swap) { \
Scoped ## JNI_NAME ## ArrayRW elements(env, dst); \
if (elements.get() == NULL) { \
return; \
} \
const SWAP_TYPE* src = cast<const SWAP_TYPE*>(srcAddress); \
SWAP_FN(reinterpret_cast<SWAP_TYPE*>(elements.get()) + dstOffset, src, count); \
} else { \
const SCALAR_TYPE* src = cast<const SCALAR_TYPE*>(srcAddress); \
env->Set ## JNI_NAME ## ArrayRegion(dst, dstOffset, count, src); \
} \
}
static void Memory_peekCharArray(JNIEnv* env, jclass, jint srcAddress, jcharArray dst, jint dstOffset, jint count, jboolean swap) {
PEEKER(jchar, Char, jshort, swapShorts);
}
static void Memory_peekDoubleArray(JNIEnv* env, jclass, jint srcAddress, jdoubleArray dst, jint dstOffset, jint count, jboolean swap) {
PEEKER(jdouble, Double, jlong, swapLongs);
}
static void Memory_peekFloatArray(JNIEnv* env, jclass, jint srcAddress, jfloatArray dst, jint dstOffset, jint count, jboolean swap) {
PEEKER(jfloat, Float, jint, swapInts);
}
static void Memory_peekIntArray(JNIEnv* env, jclass, jint srcAddress, jintArray dst, jint dstOffset, jint count, jboolean swap) {
PEEKER(jint, Int, jint, swapInts);
}
static void Memory_peekLongArray(JNIEnv* env, jclass, jint srcAddress, jlongArray dst, jint dstOffset, jint count, jboolean swap) {
PEEKER(jlong, Long, jlong, swapLongs);
}
static void Memory_peekShortArray(JNIEnv* env, jclass, jint srcAddress, jshortArray dst, jint dstOffset, jint count, jboolean swap) {
PEEKER(jshort, Short, jshort, swapShorts);
}
static void Memory_pokeByte(JNIEnv*, jclass, jint dstAddress, jbyte value) {
*cast<jbyte*>(dstAddress) = value;
}
static void Memory_pokeByteArray(JNIEnv* env, jclass, jint dstAddress, jbyteArray src, jint offset, jint length) {
env->GetByteArrayRegion(src, offset, length, cast<jbyte*>(dstAddress));
}
// Implements the pokeXArray methods:
// - For unswapped access, we just use the JNI GetXArrayRegion functions.
// - For swapped access, we use GetXArrayElements and our own copy-and-swap routines.
// GetXArrayElements is disproportionately cheap on Dalvik because it doesn't copy (as opposed
// to Hotspot, which always copies). The SWAP_FN copies and swaps in one pass, which is cheaper
// than copying and then swapping in a second pass. Depending on future VM/GC changes, the
// swapped case might need to be revisited.
#define POKER(SCALAR_TYPE, JNI_NAME, SWAP_TYPE, SWAP_FN) { \
if (swap) { \
Scoped ## JNI_NAME ## ArrayRO elements(env, src); \
if (elements.get() == NULL) { \
return; \
} \
const SWAP_TYPE* src = reinterpret_cast<const SWAP_TYPE*>(elements.get()) + srcOffset; \
SWAP_FN(cast<SWAP_TYPE*>(dstAddress), src, count); \
} else { \
env->Get ## JNI_NAME ## ArrayRegion(src, srcOffset, count, cast<SCALAR_TYPE*>(dstAddress)); \
} \
}
static void Memory_pokeCharArray(JNIEnv* env, jclass, jint dstAddress, jcharArray src, jint srcOffset, jint count, jboolean swap) {
POKER(jchar, Char, jshort, swapShorts);
}
static void Memory_pokeDoubleArray(JNIEnv* env, jclass, jint dstAddress, jdoubleArray src, jint srcOffset, jint count, jboolean swap) {
POKER(jdouble, Double, jlong, swapLongs);
}
static void Memory_pokeFloatArray(JNIEnv* env, jclass, jint dstAddress, jfloatArray src, jint srcOffset, jint count, jboolean swap) {
POKER(jfloat, Float, jint, swapInts);
}
static void Memory_pokeIntArray(JNIEnv* env, jclass, jint dstAddress, jintArray src, jint srcOffset, jint count, jboolean swap) {
POKER(jint, Int, jint, swapInts);
}
static void Memory_pokeLongArray(JNIEnv* env, jclass, jint dstAddress, jlongArray src, jint srcOffset, jint count, jboolean swap) {
POKER(jlong, Long, jlong, swapLongs);
}
static void Memory_pokeShortArray(JNIEnv* env, jclass, jint dstAddress, jshortArray src, jint srcOffset, jint count, jboolean swap) {
POKER(jshort, Short, jshort, swapShorts);
}
static jshort Memory_peekShort(JNIEnv*, jclass, jint srcAddress, jboolean swap) {
jshort result = *cast<const jshort*>(srcAddress);
if (swap) {
result = bswap_16(result);
}
return result;
}
static void Memory_pokeShort(JNIEnv*, jclass, jint dstAddress, jshort value, jboolean swap) {
if (swap) {
value = bswap_16(value);
}
*cast<jshort*>(dstAddress) = value;
}
static jint Memory_peekInt(JNIEnv*, jclass, jint srcAddress, jboolean swap) {
jint result = *cast<const jint*>(srcAddress);
if (swap) {
result = bswap_32(result);
}
return result;
}
#if 1
static bool sigBusCatched = false;
static void sigBusCatcher(int signum, siginfo_t* info, void* context)
{
void* addr = info->si_addr;
context = context;
ALOGE("Signal (%d) : %p\n", signum, addr);
sigBusCatched = true;
signal(SIGBUS, SIG_IGN);
}
static bool isReadableAddr(int p)
{
int cc;
volatile int x;
struct sigaction sa;
struct sigaction old_sa;
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = sigBusCatcher;
sa.sa_flags = SA_SIGINFO;
cc = sigaction(SIGBUS, &sa, &old_sa);
if (cc != 0)
return false;
sigBusCatched = false;
x = * ((int *) p);
cc = sigaction(SIGBUS, &old_sa, NULL);
if (sigBusCatched)
return false;
return true;
}
#endif
static void Memory_pokeInt(JNIEnv*, jclass, jint dstAddress, jint value, jboolean swap) {
if (swap) {
value = bswap_32(value);
}
*cast<jint*>(dstAddress) = value;
}
static jlong Memory_peekLong(JNIEnv*, jclass, jint srcAddress, jboolean swap) {
jlong result;
const jlong* src = cast<const jlong*>(srcAddress);
if ((srcAddress & LONG_ALIGNMENT_MASK) == 0) {
if (isReadableAddr(srcAddress)) {
result = *src;
}
else {
ALOGD("Memory_peekLong : 0x%X", (int) srcAddress);
result = 0;
}
} else {
result = get_unaligned<jlong>(src);
}
if (swap) {
result = bswap_64(result);
}
return result;
}
static void Memory_pokeLong(JNIEnv*, jclass, jint dstAddress, jlong value, jboolean swap) {
jlong* dst = cast<jlong*>(dstAddress);
if (swap) {
value = bswap_64(value);
}
if ((dstAddress & LONG_ALIGNMENT_MASK) == 0) {
*dst = value;
} else {
put_unaligned<jlong>(dst, value);
}
}
static void unsafeBulkCopy(jbyte* dst, const jbyte* src, jint byteCount,
jint sizeofElement, jboolean swap) {
if (!swap) {
memcpy(dst, src, byteCount);
return;
}
if (sizeofElement == 2) {
jshort* dstShorts = reinterpret_cast<jshort*>(dst);
const jshort* srcShorts = reinterpret_cast<const jshort*>(src);
swapShorts(dstShorts, srcShorts, byteCount / 2);
} else if (sizeofElement == 4) {
jint* dstInts = reinterpret_cast<jint*>(dst);
const jint* srcInts = reinterpret_cast<const jint*>(src);
swapInts(dstInts, srcInts, byteCount / 4);
} else if (sizeofElement == 8) {
jlong* dstLongs = reinterpret_cast<jlong*>(dst);
const jlong* srcLongs = reinterpret_cast<const jlong*>(src);
swapLongs(dstLongs, srcLongs, byteCount / 8);
}
}
static void Memory_unsafeBulkGet(JNIEnv* env, jclass, jobject dstObject, jint dstOffset,
jint byteCount, jbyteArray srcArray, jint srcOffset, jint sizeofElement, jboolean swap) {
ScopedByteArrayRO srcBytes(env, srcArray);
if (srcBytes.get() == NULL) {
return;
}
jarray dstArray = reinterpret_cast<jarray>(dstObject);
jbyte* dstBytes = reinterpret_cast<jbyte*>(env->GetPrimitiveArrayCritical(dstArray, NULL));
if (dstBytes == NULL) {
return;
}
jbyte* dst = dstBytes + dstOffset*sizeofElement;
const jbyte* src = srcBytes.get() + srcOffset;
unsafeBulkCopy(dst, src, byteCount, sizeofElement, swap);
env->ReleasePrimitiveArrayCritical(dstArray, dstBytes, 0);
}
static void Memory_unsafeBulkPut(JNIEnv* env, jclass, jbyteArray dstArray, jint dstOffset,
jint byteCount, jobject srcObject, jint srcOffset, jint sizeofElement, jboolean swap) {
ScopedByteArrayRW dstBytes(env, dstArray);
if (dstBytes.get() == NULL) {
return;
}
jarray srcArray = reinterpret_cast<jarray>(srcObject);
jbyte* srcBytes = reinterpret_cast<jbyte*>(env->GetPrimitiveArrayCritical(srcArray, NULL));
if (srcBytes == NULL) {
return;
}
jbyte* dst = dstBytes.get() + dstOffset;
const jbyte* src = srcBytes + srcOffset*sizeofElement;
unsafeBulkCopy(dst, src, byteCount, sizeofElement, swap);
env->ReleasePrimitiveArrayCritical(srcArray, srcBytes, 0);
}
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(Memory, memmove, "(Ljava/lang/Object;ILjava/lang/Object;IJ)V"),
NATIVE_METHOD(Memory, peekByte, "!(I)B"),
NATIVE_METHOD(Memory, peekByteArray, "(I[BII)V"),
NATIVE_METHOD(Memory, peekCharArray, "(I[CIIZ)V"),
NATIVE_METHOD(Memory, peekDoubleArray, "(I[DIIZ)V"),
NATIVE_METHOD(Memory, peekFloatArray, "(I[FIIZ)V"),
NATIVE_METHOD(Memory, peekInt, "!(IZ)I"),
NATIVE_METHOD(Memory, peekIntArray, "(I[IIIZ)V"),
NATIVE_METHOD(Memory, peekLong, "!(IZ)J"),
NATIVE_METHOD(Memory, peekLongArray, "(I[JIIZ)V"),
NATIVE_METHOD(Memory, peekShort, "!(IZ)S"),
NATIVE_METHOD(Memory, peekShortArray, "(I[SIIZ)V"),
NATIVE_METHOD(Memory, pokeByte, "!(IB)V"),
NATIVE_METHOD(Memory, pokeByteArray, "(I[BII)V"),
NATIVE_METHOD(Memory, pokeCharArray, "(I[CIIZ)V"),
NATIVE_METHOD(Memory, pokeDoubleArray, "(I[DIIZ)V"),
NATIVE_METHOD(Memory, pokeFloatArray, "(I[FIIZ)V"),
NATIVE_METHOD(Memory, pokeInt, "!(IIZ)V"),
NATIVE_METHOD(Memory, pokeIntArray, "(I[IIIZ)V"),
NATIVE_METHOD(Memory, pokeLong, "!(IJZ)V"),
NATIVE_METHOD(Memory, pokeLongArray, "(I[JIIZ)V"),
NATIVE_METHOD(Memory, pokeShort, "!(ISZ)V"),
NATIVE_METHOD(Memory, pokeShortArray, "(I[SIIZ)V"),
NATIVE_METHOD(Memory, unsafeBulkGet, "(Ljava/lang/Object;II[BIIZ)V"),
NATIVE_METHOD(Memory, unsafeBulkPut, "([BIILjava/lang/Object;IIZ)V"),
};
void register_libcore_io_Memory(JNIEnv* env) {
jniRegisterNativeMethods(env, "libcore/io/Memory", gMethods, NELEM(gMethods));
}
|
rex-xxx/mt6572_x201
|
libcore/luni/src/main/native/libcore_io_Memory.cpp
|
C++
|
gpl-2.0
| 16,749
|
/* roadmap_tile_manager.c - Manage loading of map tiles.
*
* LICENSE:
*
* Copyright 2009 Israel Disatnik.
*
* This file is part of RoadMap.
*
* RoadMap 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 2 of the License, or
* (at your option) any later version.
*
* RoadMap 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 RoadMap; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include "roadmap_tile_manager.h"
#include "roadmap_tile_storage.h"
#include "roadmap.h"
#include "roadmap_tile_status.h"
#include "roadmap_httpcopy_async.h"
#include "roadmap_file.h"
#include "roadmap_path.h"
#include "roadmap_locator.h"
#include "roadmap_data_format.h"
#include "roadmap_label.h"
#include "roadmap_square.h"
#include "roadmap_main.h"
#include "roadmap_config.h"
#include "navigate/navigate_graph.h"
#include "Realtime/Realtime.h"
#include "roadmap_street.h"
#include "roadmap_tile.h"
#include "roadmap_config.h"
#if defined(_WIN32) || defined(__SYMBIAN32__) || defined(J2ME)
#define TM_MAX_CONCURRENT 1
#elif defined(IPHONE) || defined(ANDROID)
#define TM_MAX_CONCURRENT 3
#else
#define TM_MAX_CONCURRENT 1
#endif
#define TM_MAX_QUEUE 256
#define TM_RETRY_CONNECTION_SECONDS 30
#define TM_HTTP_TIMEOUT_SECONDS 30
typedef struct {
time_t time_out;
int tile_index;
int *tile_status;
char url[512];
RoadMapCallback callback;
char *tile_data;
size_t tile_size;
HttpAsyncContext *http_context;
} ConnectionContext;
static enum {
stat_First,
stat_Waiting,
stat_Active
} Status = stat_First;
static ConnectionContext *Connections = NULL;
static int NumOpenConnections = 0;
static RoadMapConfigDescriptor RoadMapConfigTilesUrl =
ROADMAP_CONFIG_ITEM("Download", "Tiles");
typedef struct {
int tile_index;
int priority;
RoadMapCallback callback;
} TileData;
static TileData RequestQueue[TM_MAX_QUEUE];
static int QueueHead = 0;
static int QueueSize = 0;
static RoadMapCallback NextLoginCallback = NULL;
static RoadMapTileCallback TileCallback = NULL;
static int ActiveLoadingSession = 0;
static RoadMapConfigDescriptor LastLoadingSessionCfg =
ROADMAP_CONFIG_ITEM("Tiles", "Last Session");
static RoadMapConfigDescriptor LoadingSessionLifetimeCfg =
ROADMAP_CONFIG_ITEM("Tiles", "Loading session lifetime");
static void load_next_tile (void);
static void queue_tile (int index, int push, RoadMapCallback on_loaded);
static void roadmap_tile_manager_login_cb (void);
static void on_connection_failure (ConnectionContext *conn);
static void init_loading_session (void) {
int last_session;
int session_period;
int time_now;
static int initialized = 0;
if (initialized) return;
initialized = 1;
time_now = (int)time (NULL);
roadmap_config_declare ("session", &LastLoadingSessionCfg, "0", NULL);
roadmap_config_declare ("preferences", &LoadingSessionLifetimeCfg, "604800", NULL); // seconds in one week
last_session = roadmap_config_get_integer (&LastLoadingSessionCfg);
session_period = roadmap_config_get_integer (&LoadingSessionLifetimeCfg);
if (time_now > last_session + session_period) {
ActiveLoadingSession = 1;
roadmap_config_set_integer (&LastLoadingSessionCfg, time_now);
roadmap_config_save (0);
}
}
static void init_connections (void) {
int i;
if (Connections != NULL) return;
Connections = (ConnectionContext *) malloc (TM_MAX_CONCURRENT * sizeof (ConnectionContext));
for (i = 0; i < TM_MAX_CONCURRENT; i++) {
Connections[i].tile_status = NULL;
}
}
static int http_cb_size (void *context, size_t size) {
ConnectionContext *conn = (ConnectionContext *)context;
//printf ("Size for %s is %d\n", conn->url, size);
conn->tile_data = malloc (size);
conn->tile_size = 0;
return size;
}
static void http_cb_progress (void *context, char *data, size_t size) {
ConnectionContext *conn = (ConnectionContext *)context;
if (size && (conn->tile_data != NULL)) {
memcpy (conn->tile_data + conn->tile_size, data, size);
conn->tile_size += size;
}
conn->time_out = time (NULL) + TM_HTTP_TIMEOUT_SECONDS;
}
static void http_cb_error (void *context, int connection_failure, const char *format, ...) {
va_list ap;
ConnectionContext *conn = (ConnectionContext *)context;
char err_string[1024];
//printf ("Error downloading %s\n", conn->url);
va_start (ap, format);
vsnprintf (err_string, 1024, format, ap);
va_end (ap);
if (connection_failure) {
roadmap_log (ROADMAP_ERROR, err_string);
} else {
roadmap_log (ROADMAP_INFO, err_string);
}
if (conn->tile_data) {
free (conn->tile_data);
conn->tile_data = NULL;
}
if (connection_failure) {
on_connection_failure (conn);
return;
}
*conn->tile_status = ((*conn->tile_status) |
(ROADMAP_TILE_STATUS_FLAG_ERROR | ROADMAP_TILE_STATUS_FLAG_UPTODATE)) &
~ROADMAP_TILE_STATUS_FLAG_ACTIVE;
if (conn->callback) {
conn->callback ();
}
conn->tile_status = NULL;
NumOpenConnections--;
load_next_tile ();
}
#ifndef J2ME
#define NOPH_System_currentTimeMillis() time(NULL)
#endif
static void http_cb_done (void *context) {
ConnectionContext *conn = (ConnectionContext *)context;
int *tile_status = conn->tile_status;
int tile_index = conn->tile_index;
int unloaded;
time_t t1;
time_t t2;
int rc;
t1 = NOPH_System_currentTimeMillis();
unloaded = roadmap_locator_unload_tile (tile_index);
t2 = NOPH_System_currentTimeMillis();
//printf("http_cb_done: unload %dms\n", t2 - t1);
roadmap_tile_store(roadmap_locator_active(), tile_index, conn->tile_data, conn->tile_size);
t2 = NOPH_System_currentTimeMillis();
//printf("http_cb_done: save %dms\n", t2 - t1);
*tile_status = ((*tile_status) |
(ROADMAP_TILE_STATUS_FLAG_EXISTS | ROADMAP_TILE_STATUS_FLAG_UPTODATE)) &
~ROADMAP_TILE_STATUS_FLAG_ACTIVE;
conn->tile_status = NULL;
NumOpenConnections--;
roadmap_label_clear (tile_index);
navigate_graph_clear (tile_index);
if (!unloaded) {
roadmap_square_delete_reference (tile_index);
}
rc = roadmap_locator_load_tile_mem (tile_index, conn->tile_data, conn->tile_size);
free (conn->tile_data);
conn->tile_data = NULL;
t2 = NOPH_System_currentTimeMillis();
//printf("http_cb_done: load %dms\n", t2 - t1);
load_next_tile ();
if (rc != ROADMAP_US_OK) {
return;
}
if (roadmap_tile_get_scale (tile_index) == 0) {
roadmap_street_update_city_index ();
}
if (conn->callback) {
conn->callback ();
}
roadmap_log (ROADMAP_DEBUG, "Download of tile %d complete", tile_index);
if (TileCallback != NULL &&
(*tile_status) & ROADMAP_TILE_STATUS_FLAG_CALLBACK) {
roadmap_log (ROADMAP_DEBUG, "Calling callback for tile %d", tile_index);
TileCallback (tile_index);
}
roadmap_screen_refresh();
}
static void init_url (void) {
roadmap_config_declare
("preferences",
&RoadMapConfigTilesUrl, "", NULL);
}
static const char *get_url_prefix (void) {
return roadmap_config_get (&RoadMapConfigTilesUrl);
}
static void get_url (ConnectionContext *context) {
int fips = roadmap_locator_active ();
int tile_id = context->tile_index;
snprintf (context->url,
sizeof (context->url),
"%s/%05d_%02x/%05d_%04x/%05d_%06x/%05d_%08x%s",
get_url_prefix (),
fips, tile_id >> 24,
fips, tile_id >> 16,
fips, tile_id >> 8,
fips, tile_id, ROADMAP_DATA_TYPE);
}
static void next_to_load (int *tile_index, int *priority, RoadMapCallback *callback) {
if (QueueSize <= 0) {
*tile_index = -1;
return;
}
*tile_index = RequestQueue[QueueHead].tile_index;
*callback = RequestQueue[QueueHead].callback;
*priority = RequestQueue[QueueHead].priority;
QueueHead = (QueueHead + 1) % TM_MAX_QUEUE;
QueueSize--;
}
static void load_next_tile (void) {
static RoadMapHttpAsyncCallbacks callbacks = { http_cb_size, http_cb_progress, http_cb_error, http_cb_done };
int conn;
time_t tile_time;
int tile_index;
int priority;
int *tile_status;
RoadMapCallback tile_callback;
roadmap_log(ROADMAP_DEBUG, "load_next_tile - status:%d", Status);
if (NumOpenConnections >= TM_MAX_CONCURRENT || Status != stat_Active) {
return;
}
do {
next_to_load (&tile_index, &priority, &tile_callback);
if (tile_index == -1) {
return;
}
tile_status = roadmap_tile_status_get (tile_index);
assert (tile_status != NULL);
if (((*tile_status) & ROADMAP_TILE_STATUS_FLAG_UPTODATE ) && tile_callback) {
tile_callback ();
}
*tile_status &= ~ROADMAP_TILE_STATUS_FLAG_QUEUED;
}
while ((*tile_status) & (ROADMAP_TILE_STATUS_FLAG_ACTIVE | ROADMAP_TILE_STATUS_FLAG_UPTODATE));
roadmap_log (ROADMAP_DEBUG, "Loading tile %d -- priority %d",
tile_index, priority);
for (conn = 0; conn < TM_MAX_CONCURRENT; conn++) {
if (Connections[conn].tile_status == NULL) break;
}
assert (conn < TM_MAX_CONCURRENT);
Connections[conn].tile_index = tile_index;
Connections[conn].tile_status = tile_status;
Connections[conn].callback = tile_callback;
Connections[conn].time_out = 0;
Connections[conn].tile_data = NULL;
Connections[conn].tile_size = 0;
get_url (&Connections[conn]);
//printf ("Requesting %s\n", Connections[conn].url);
*tile_status |= ROADMAP_TILE_STATUS_FLAG_ACTIVE;
NumOpenConnections++;
tile_time = roadmap_square_timestamp (tile_index);
Connections[conn].http_context =
roadmap_http_async_copy (&callbacks,
&Connections[conn],
Connections[conn].url,
tile_time);
// failure is handled by http_cb_error
}
static void requeue_tile (ConnectionContext *conn) {
*conn->tile_status = (*conn->tile_status) & ~ROADMAP_TILE_STATUS_FLAG_ACTIVE;
queue_tile (conn->tile_index, (*conn->tile_status) & ROADMAP_TILE_STATUS_MASK_PRIORITY, conn->callback);
conn->tile_status = NULL;
NumOpenConnections--;
}
static void roadmap_tile_manager_check_timeouts (void) {
int i;
time_t time_now = time (NULL);
for (i = 0; i < TM_MAX_CONCURRENT; i++) {
ConnectionContext *conn = Connections + i;
if (conn->tile_status != NULL && conn->time_out && conn->time_out < time_now) {
roadmap_log (ROADMAP_ERROR, "Timed out waiting for tile %d", conn->tile_index);
roadmap_http_async_copy_abort (conn->http_context);
requeue_tile (conn);
}
}
}
static void start_network (void) {
init_url ();
Status = stat_Active;
load_next_tile ();
}
static void roadmap_tile_manager_login_cb (void) {
roadmap_log(ROADMAP_DEBUG, "roadmap_tile_manager_login_cb called!");
start_network ();
roadmap_main_set_periodic (TM_HTTP_TIMEOUT_SECONDS * 1000, roadmap_tile_manager_check_timeouts);
if (NextLoginCallback) {
NextLoginCallback ();
NextLoginCallback = NULL;
}
}
static void on_connection_failure (ConnectionContext *conn) {
requeue_tile (conn);
if (Status != stat_Active) return;
Status = stat_Waiting;
roadmap_main_set_periodic (TM_RETRY_CONNECTION_SECONDS * 1000, start_network);
}
static void queue_tile (int index, int priority, RoadMapCallback on_loaded) {
int slot;
if (priority) {
int pos;
int test_slot;
QueueHead = (QueueHead + TM_MAX_QUEUE - 1) % TM_MAX_QUEUE;
// Note{ID}:
// This is a safety against removing callback items from queue
// assuming there is only one callback item at a time.
// if things change (more than one possible callback item)
// change it to call the callback (it will work but will demand more CPU)
if (QueueSize == TM_MAX_QUEUE) {
if (RequestQueue[QueueHead].priority > priority) {
roadmap_log (ROADMAP_WARNING, "Tile request queue is full with prioritized items");
return;
}
if (RequestQueue[QueueHead].callback != NULL) {
int before_last = (QueueHead + TM_MAX_QUEUE - 1) % TM_MAX_QUEUE;
assert (RequestQueue[before_last].callback == NULL);
*roadmap_tile_status_get (RequestQueue[before_last].tile_index) &= ~ROADMAP_TILE_STATUS_FLAG_QUEUED;
RequestQueue[before_last] = RequestQueue[QueueHead];
}
QueueSize--;
}
for (slot = QueueHead, pos = 1; pos <= QueueSize; pos++) {
test_slot = (QueueHead + pos) % TM_MAX_QUEUE;
if (RequestQueue[test_slot].priority <= priority) break;
RequestQueue[slot] = RequestQueue[test_slot];
slot = test_slot;
}
if (QueueSize < TM_MAX_QUEUE) {
QueueSize++;
}
} else {
if (QueueSize >= TM_MAX_QUEUE) {
roadmap_log (ROADMAP_INFO, "Tile request queue is full");
return;
}
slot = (QueueHead + QueueSize) % TM_MAX_QUEUE;
if (QueueSize < TM_MAX_QUEUE) {
QueueSize++;
}
}
RequestQueue[slot].tile_index = index;
RequestQueue[slot].callback = on_loaded;
RequestQueue[slot].priority = priority;
roadmap_log (ROADMAP_DEBUG, "Queued tile %d at slot %d (position %d) with priority %d Status:%d",
index, slot, (slot + 1 + TM_MAX_QUEUE - QueueHead) % TM_MAX_QUEUE, priority, Status);
}
void roadmap_tile_request (int index, int priority, int force_update, RoadMapCallback on_loaded) {
int *tile_status = roadmap_tile_status_get (index);
if ((*tile_status) & (ROADMAP_TILE_STATUS_FLAG_ACTIVE | ROADMAP_TILE_STATUS_FLAG_UPTODATE)) {
return;
}
if (((*tile_status) & ROADMAP_TILE_STATUS_FLAG_QUEUED) &&
((*tile_status) & ROADMAP_TILE_STATUS_MASK_PRIORITY) > priority) {
return;
}
if (!force_update) {
if ((*tile_status) & ROADMAP_TILE_STATUS_FLAG_UNFORCE) return;
init_loading_session ();
if ((!ActiveLoadingSession) &&
roadmap_square_timestamp (index) > 0) {
*tile_status |= ROADMAP_TILE_STATUS_FLAG_UNFORCE;
roadmap_log (ROADMAP_DEBUG, "Tile %d is not forced and already has a version - not requesting", index);
return;
}
}
queue_tile (index, priority, on_loaded);
*tile_status = ((*tile_status) & ~ROADMAP_TILE_STATUS_MASK_PRIORITY) | ROADMAP_TILE_STATUS_FLAG_QUEUED | priority;
init_connections ();
if (Status == stat_First) {
Status = stat_Waiting;
NextLoginCallback = Realtime_NotifyOnLogin (roadmap_tile_manager_login_cb);
}
if (Status == stat_Active) {
load_next_tile ();
}
#ifdef J2ME
start_network();
#endif
}
RoadMapTileCallback roadmap_tile_register_callback (RoadMapTileCallback cb) {
RoadMapTileCallback prev = TileCallback;
TileCallback = cb;
return prev;
}
void roadmap_tile_reset_session (void) {
init_loading_session ();
roadmap_config_set_integer (&LastLoadingSessionCfg, (int)time (NULL));
roadmap_config_save (0);
ActiveLoadingSession = 0;
}
|
maximuska/Freemap-waze
|
roadmap_tile_manager.c
|
C
|
gpl-2.0
| 14,984
|
/*****************************************************************************
* *
* File: espi.h *
* $Revision: #1 $ *
* $Date: 2012/09/27 $ *
* Description: *
* part of the Chelsio 10Gb Ethernet Driver. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License, version 2, as *
* published by the Free Software Foundation. *
* *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED *
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF *
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
* *
* http://www.chelsio.com *
* *
* Copyright (c) 2003 - 2005 Chelsio Communications, Inc. *
* All rights reserved. *
* *
* Maintainers: maintainers@chelsio.com *
* *
* Authors: Dimitrios Michailidis <dm@chelsio.com> *
* Tina Yang <tainay@chelsio.com> *
* Felix Marti <felix@chelsio.com> *
* Scott Bardone <sbardone@chelsio.com> *
* Kurt Ottaway <kottaway@chelsio.com> *
* Frank DiMambro <frank@chelsio.com> *
* *
* History: *
* *
****************************************************************************/
#ifndef _CXGB_ESPI_H_
#define _CXGB_ESPI_H_
#include "common.h"
struct espi_intr_counts {
unsigned int DIP4_err;
unsigned int rx_drops;
unsigned int tx_drops;
unsigned int rx_ovflw;
unsigned int parity_err;
unsigned int DIP2_parity_err;
};
struct peespi;
struct peespi *t1_espi_create(adapter_t *adapter);
void t1_espi_destroy(struct peespi *espi);
int t1_espi_init(struct peespi *espi, int mac_type, int nports);
void t1_espi_intr_enable(struct peespi *);
void t1_espi_intr_clear(struct peespi *);
void t1_espi_intr_disable(struct peespi *);
int t1_espi_intr_handler(struct peespi *);
const struct espi_intr_counts *t1_espi_get_intr_counts(struct peespi *espi);
u32 t1_espi_get_mon(adapter_t *adapter, u32 addr, u8 wait);
int t1_espi_get_mon_t204(adapter_t *, u32 *, u8);
#endif /* _CXGB_ESPI_H_ */
|
jameshilliard/WM2500RP-V1.0.0.34_gpl_src
|
git_home/linux.git/drivers/net/chelsio/espi.h
|
C
|
gpl-2.0
| 3,727
|
/* This file will hold styles for the mobile version of your website (mobile first). */
/* This also can include ANY global CSS that applies site-wide. Unless overwritten by a more specific style rule, CSS declarations in global.css will apply site-wide. */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
ol, ul {
list-style: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/*
Clear Floated Elements
*/
.clear {
clear:both;
display:block;
overflow:hidden;
visibility:hidden;
width:0;
height:0;
}
.clear:after {
clear:both;
content:' ';
display:block;
font-size:0;
line-height:0;
visibility:hidden;
width:0;
height:0;
}
* html .clear {
height:1%;
}
/*
Style HTML Tags
DARK GRAY #555450
LIGHT GRAY #d9d9d9
RED #e51837
*/
html {
background:#fff;
}
body {
/*background-position-y: 116px;*/
color: #515F5C;
font-family: Arial,Helvetica,sans-serif;
font-size:12px;
line-height:1.62em;
padding:0px;
background: #fff;
}
a, a:visited, a:link {
color: #e51837;
text-decoration:none;
}
a:hover, a:active, a.active {
color: #555450;
text-decoration: none;
}
h1, h2, h3, h4, h5, h6 {
color: #d9d9d9;
font-family: "Arial", "Helvetica", sans-serif;
font-weight: normal;
margin-bottom:6px;
line-height: 125%;
letter-spacing: 1px;
}
h1 {
font-size:28px;
}
h2 {
font-size:24px;
}
h3 {
font-size:18px;
}
h4 {
font-size:16px;
}
h5 {
font-size:15px;
}
h6 {
font-size:14px;
}
h2.block-title {
border-bottom: 2px solid #e51837;
font-size: 22px;
margin: 0;
line-height: 35px;
color:#e51837;
}
article {
margin: 0 0 20px 0;
}
article p {
margin: 0 0 10px;
color:#d9d9d9;
}
table {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border: medium none;
border-collapse: collapse;
border-spacing: 0;
margin-bottom: 20px;
width: 100%;
}
th, tr, td {
vertical-align: middle;
color: #d9d9d9;
padding:5px;
}
tr {
padding-bottom: 0px;
}
.sticky-header th, .sticky-table th {
border-bottom: 3px solid #ccc;
padding-right: 1em;
text-align: left;
}
th {
background: #dbdbdb;
padding: 5px 4px;
text-shadow: 1px 1px #fff;
color:#333;
}
td {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border-bottom: medium none;
border-right: medium none;
color: #d9d9d9;
}
code {
background: #d8d8d8;
text-shadow: 1px 1px #fff;
border: 1px solid #bbbbbb;
display: block;
padding: 7px;
margin: 5px 0;
border-radius: 7px;
}
mark {
background-color:#fdfc9b;
font-style:italic;
font-weight:bold;
}
del {
text-decoration: line-through;
}
hr {
border:none;
border-top:#EEE 1px solid;
}
dt {
font-weight:bold;
margin-bottom:24px;
}
dd {
margin-left:30px;
margin-bottom:24px;
}
ul {
list-style-type:disc;
margin-left:15px;
margin-bottom:12px;
}
ul ul {
list-style-type:square;
margin-bottom:0;
}
ul ul ul {
list-style-type:circle;
}
ol {
list-style-type:decimal;
margin-left:30px;
margin-bottom:24px;
}
ol ol {
list-style: upper-alpha;
margin-bottom:0
}
ol ol ol {
list-style: lower-roman;
}
ol ol ol ol {
list-style: lower-alpha;
}
p { color:#e51837;}
abbr,
acronym {
border-bottom:#999 1px dotted;
cursor:help;
}
big {
font-size:1.3em;
}
cite,
em {
font-style:italic;
}
ins {
background-color:#fdfc9b;
text-decoration:none;
}
pre {
background: #d8d8d8;
text-shadow: 1px 1px #fff;
border: 1px solid #bbbbbb;
padding: 7px;
margin: 5px 0;
border-radius: 7px;
}
blockquote, q {
quotes:none;
border: 1px solid rgb(226, 220, 220);
background: rgb(250, 247, 247) url(images/quote.png) no-repeat;
padding: 10px 5px 5px 47px;
text-shadow: 1px 1px #fff;
margin: 5px 0;
border-radius: 7px;
}
blockquote:before, blockquote:after,
q:before, q:after {
content:'';
content:none;
}
strong {
font-weight:bold;
}
sup,
sub {
height:0;
line-height:1;
vertical-align:baseline;
position:relative;
font-size:10px;
}
sup {
bottom:1ex;
}
sub {
top:.5ex;
}
img,
video {
height:auto;
max-width:100%;
}
video {
display:block;
}
audio {
max-width:100%;
}
.content a img {
background:#FFF;
max-width:100%;
}
.content a:hover img {
background:#F0F0F0;
}
/*///////////////////////////////////////////*/
/* CONTENT */
/*///////////////////////////////////////////*/
#page {
}
#zone-branding {
padding-bottom: 0px;
}
#zone-preface-wrapper {
/*background:#e51837;*/
}
#zone-branding-wrapper {
border-bottom: none;
padding-bottom: 20px;
}
#zone-preface #block-block-1 {
padding:20px;
background:#e51837;
}
#region-preface-first {
}
#block-system-main-menu h2.block-title {
display:none;
}
#block-system-main-menu ul.menu li {
font-size: 14px;
list-style: none outside none;
margin-left: -20px;
padding: 0;
text-align: left;
}
#block-system-main-menu ul.menu li.leaf a {
color: #e51837;
display: block;
padding: 10px 0 10px 10px;
}
#block-system-main-menu ul.menu li.leaf a:hover,
#block-system-main-menu ul.menu li.leaf a.active-trail.active {
background:#e51837;
color:#d9d9d9;
}
#region-branding-second {
}
#region-branding-second h2 {
font-size: 20px;
color:#e51837;
}
#region-branding-second p {
/*color: #fff;
display: inline-block;
font-size: 28px;
line-height: normal;
margin: 0;
vertical-align: middle; */
margin:0;
}
#region-branding-second p.line1 {
color:#e51837;
}
#region-branding-second p.line2 {}
#region-sidebar-second .block {
margin-bottom: 20px;
}
#region-sidebar-second.block p {
margin-bottom:0;
}
#region-sidebar-second .block img {
display:none;
}
#region-preface-second p {
margin:0;
}
#zone-postscript .block,
#region-preface-second .block {
background:#d9d9d9;
padding:20px;
}
#zone-postscript .block p,
#region-preface-second .block p {
color:#555450;
}
.grid-6.region-preface-third {
background: none repeat scroll 0 0 #e51837;
margin-right: 0;
padding-right: 10px;
}
.block-main-menu {
color:#e51837;
}
.logo-img {
width: 100%;
margin-top: 10px;
}
#region-content {
color:#e51837;
background:#e51837;
display: block;
padding: 10px;
margin-bottom:20px;
/*background: none repeat scroll 0 0 rgba(255, 255, 255, 0.6);*/
/*background: #afc0cc;
background: -moz-linear-gradient(top, #afc0cc 0%, #dee4e8 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#afc0cc), color-stop(100%,#dee4e8)); /
background: -webkit-linear-gradient(top, #afc0cc 0%,#dee4e8 100%);
background: -o-linear-gradient(top, #afc0cc 0%,#dee4e8 100%);
background: -ms-linear-gradient(top, #afc0cc 0%,#dee4e8 100%);
background: linear-gradient(to bottom, #afc0cc 0%,#dee4e8 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#afc0cc', endColorstr='#dee4e8',GradientType=0 ); */
}
.page-user #region-content {
background: #d9d9d9;
}
#region-content.content p {
color: #d9d9d9;
}
#region-content.content p a img {
}
#zone-content-wrapper {
}
#zone-content {
}
#region-sidebar-first {
margin-bottom: 20px;
}
#region-sidebar-second {
}
#region-preface-second {
margin-top:20px;
}
h3.fp {
float: left;
margin: 10px 0 10px 10px;
font-size:24px;
}
.fp-img {
clear: both;
display: block;
float: left;
margin: 0 10px 10px 0;
}
.fp-link {
float: left;
font-size:14px;
margin: 0 10px 10px;
}
.field-name-body {
margin-bottom:20px;
}
article h2 {
border-bottom: 2px solid #d9d9d9;
color: #d9d9d9;
font-size: 28px;
font-weight: bold;
margin: 0px 0px 20px 0;
}
.node-type-article article {
padding:10px;
}
article .field-type-image img {
float:left;
width:100%;
margin-bottom:10px;
}
footer.submitted {
font-style:italic;
color:#e51837;
}
.node-type-article article h2 {
border-bottom: 2px solid #e51837;
margin-bottom: 10px;
margin-left: 0;
margin-right: 0;
}
.page-node-1 #region-content h1#page-title,
.page-node-1 #region-content article h2 {
display:none;
}
#region-postscript-second {
float: right;
margin:0 10px 0 10px;
}
.page-node-1 #region-postscript-second {
display:none;
}
/*FP TITLE BLOCK*/
#block-block-15 {
background: #e51837;
padding: 20px;
}
#block-block-15 h1 {
color:#d9d9d9;
border-bottom:2px solid #d9d9d9;
}
#block-block-15 h2 {
color:#d9d9d9;
}
#block-block-15 p {
color: #d9d9d9;
font-size: 16px;
font-weight: lighter;
line-height: 24px;
}
#block-block-15 img {
width: 100%;
margin:5px 0 0 0;
}
.black {
color: #000;
}
#block-user-login {
background:#d9d9d9;
padding: 20px;
margin:10px;
}
#zone-footer .block {
padding:0;
}
/*///////////////////////////////////////////*/
/* WEBFORMS */
/*///////////////////////////////////////////*/
article#node-webform-10 {
margin:0;
}
#block-webform-client-block-9 h2 {
display:none;
}
#block-webform-client-block-9 {
padding-top: 0;
}
#block-webform-client-block-10 header,
#block-webform-client-block-10 footer.submitted {
display:none;
}
#block-webform-client-block-10 .field-name-body {
margin-bottom: 0px;
}
#block-webform-client-block-10 h2 {
color:#fff;
margin-left:0;
margin-bottom:5px;
}
#block-webform-client-block-10 .field-name-body p {
color:#fff;
}
#block-webform-client-block-9 #webform-component-message textarea {
/*resize:none;*/
}
.pop-out a,
a.pop-out,
button,
input[type="reset"],
input[type="submit"],
input[type="button"] {
-webkit-appearance: none;
/*-moz-border-radius: 11px;
-webkit-border-radius: 11px;*/
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
border-radius: 0;
background: #e51837;
border: none;
border-color: none;
cursor: pointer;
color: #fff;
outline: 0;
overflow: visible;
padding: 3px 10px 4px;
text-shadow: none;
width: auto;
padding: 15px 35px;
*padding-top: 2px; /* IE7 */
*padding-bottom: 0px; /* IE7 */
}
.page-user #edit-submit,
.page-search .form-submit,
#question-node-form input[type="submit"] {
color: #e51837;
background:#d9d9d9;
margin: 20px 0;
}
.watch-live a:hover,
.pop-out a:hover,
.form-actions input:hover {
background: #d9d9d9;
color: #e51837;
}
#edit-submit--2.form-submit {
background:#d9d9d9;
color:#e51837;
}
.input-text, .form-autocomplete, .form-text, .form-textarea, .form-select {
border: 1px solid #ccc;
box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.37) inset;
color: #e51837;
font-family: arial;
font-size: 14px;
line-height: 1.37143em;
padding: 2px 3px;
width: 100%;
}
textarea, select, input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="email"], input[type="month"], input[type="number"], input[type="password"], input[type="search"], input[type="tel"], input[type="text"], input[type="time"], input[type="url"], input[type="week"] {
color:#e51837;
}
form {
margin-bottom: 20px;
}
label {
color:#d9d9d9;
font-size: 14px;
}
#user-pass label,
#user-login label,
.page-node-1 label {
color: #e51837;
}
#user-login .marker, .form-required {
color: #e51837;
}
#user-register-form .marker, #user-register-form .form-required,
#user-register-form label {
color:#e51837;
}
#node-webform-10 .form-item {
}
#block-search-form .form-text {
margin-bottom: 20px;
color:#e51837;
}
#edit-submitted-your-full-name {
color:#e51837;
}
.form-actions {
margin-top:20px;
}
#block-webform-client-block-10 h2.block-title {
font-size: 32px;
line-height: 24px;
margin-bottom: 10px;
color:#fff;
}
/*///////////////////////////////////////////*/
/* MOBILE MENU */
/*///////////////////////////////////////////*/
#collapsed-menu-button {
background: none repeat scroll 0 0 #e51837;
border: medium none;
border-radius: 0;
color: white;
display: block;
margin: 0;
padding: 5px 0 7px;
text-align: center;
width: 100%;
}
/*///////////////////////////////////////////*/
/* FACULTY VIEW */
/*///////////////////////////////////////////*/
td.col-1.col-first.grid-4,
td.col-2.col-last.grid-4 {
width: 20%;
}
#block-views-faculty-members-faculty h2 {
font-size: 26px;
margin: 10px 0 20px 10px;
}
.views-field.views-field-field-photo {
width:100%
}
.views-field.views-field-field-photo img {
width:100%
}
.views-field.views-field-title {
border-bottom: 2px solid #e51837;
font-size: 20px;
padding-bottom: 5px;
}
.views-field-field-abstract-by,
.field-name-field-job-title,
.views-field-field-job-title {
color:#e51837;
font-size:14px;
}
.field-name-field-location,
.views-field-field-location {
color:#e51837;
font-style:italic;
float:left;
margin-right: 2px;
}
.field-name-field-country,
.views-field-field-country {
color:#e51837;
}
.field-name-field-abstract-by {
color:#e51837;
font-style:italic;
margin-bottom:20px;
}
.views-field-field-abstract-by {
color:#e51837;
font-size:14px;
margin:5px 0;
}
.field-name-field-references p {
font-size:11px;
}
.pager li.pager-current {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
color: #e51837;
outline: 0 none;
border:none;
margin: 0 20px;
}
.pager {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border-image: none;
border-radius: 5px;
border-style: solid;
border-width: 0;
}
.pager li.pager-last, .pager li.pager-next.last {
border-right: 0 none;
position: absolute;
right: 30px;
top: 0;
}
tr:hover td, tr.even:hover td.active, tr.odd:hover td.active {
background: none;
}
.pager li.pager-first a, .pager li.pager-previous a,
.pager li.pager-next a, .pager li.pager-last a
.pager li.pager-last, .pager li.pager-next.last,
.pager li.first, .pager li.first a, .pager li.first a:hover {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
float: left;
margin-left: 5px;
position: relative;
}
.item-list .pager li, .item-list .pager ul li {
border:none;
}
/*///////////////////////////////////////////*/
/* FRONT PAGE NEWS ITEMS */
/*///////////////////////////////////////////*/
#block-views-front-page-news-items-block {
margin: 0 10px;
padding: 10px 0 0;
}
#block-views-front-page-news-items-block .views-row {
margin: 0 0 20px;
}
#block-views-front-page-news-items-block .views-field.views-field-field-image {
float: left;
margin: 5px 10px 20px 0;
width:50px;
}
#block-views-front-page-news-items-block .views-field.views-field-body {
font-size: 12px;
margin-top: 5px;
}
#block-views-front-page-news-items-block .views-field.views-field-title a {
font-size: 20px;
padding-bottom: 5px;
color:#e51837;
font-weight:bold;
letter-spacing:1px;
}
#block-views-front-page-news-items-block .views-field-created {
color:#e51837;
font-style:italic;
}
.watch-live {
margin:10px 0px;
}
.watch-live a {
-webkit-appearance: none;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
-moz-background-clip: padding;
-webkit-background-clip: padding;
background: none repeat scroll 0 0 #e51837;
border: medium none;
border-radius: 5px;
color: #fff;
cursor: pointer;
float: left;
outline: 0 none;
overflow: visible;
padding: 25px 0;
text-shadow: none;
width: 100%;
*padding-top: 2px; /* IE7 */
*padding-bottom: 0px; /* IE7 */
margin: 0 0 10px 0;
font-size:18px;
text-align: center;
}
/*///////////////////////////////////////////*/
/* ASK A QUESTION */
/*///////////////////////////////////////////*/
#question-node-form {
}
#edit-field-question textarea {
/*resize:none;
height:120px;*/
}
.resizable-textarea .grippie {
display:none;
}
#edit-preview.form-submit {
display:none;
}
#question-node-form label {
font-size:14px;
}
h1#page-title,
h2.page-title {
border-bottom: 2px solid #d9d9d9;
color: #d9d9d9;
font-size: 28px;
font-weight: bold;
margin: 0;
}
#question-eu-node-form .field-name-field-country,
#question-node-form .field-name-field-country {
font-style:normal;
}
/*///////////////////////////////////////////*/
/* FOOTER */
/*///////////////////////////////////////////*/
#zone-footer {
color: #d9d9d9;
padding: 10px 20px;
}
#zone-footer p {
color: #d9d9d9;
font-size:10px;
}
#region-footer-first {
}
#region-footer-first p {
text-align: right;
}
#zone-footer-wrapper {
background: none repeat scroll 0 0 #e51837;
margin-top: 20px;
}
#zone-footer a, #zone-footer a:visited, #zone-footer a:link {
color: #d9d9d9;
text-decoration:underline;
font-size:10px;
}
#zone-footer a:hover, #zone-footer a:active, #zone-footer a.active {
color: #d9d9d9;
text-decoration: none;
}
#block-block-4 {
float:left;
}
#block-block-4 img {
width: 40px;
}
#region-footer-second {
text-align: right;
}
/*///////////////////////////////////////////*/
/* MODERATION & CHAIRMAN PAGES */
/*///////////////////////////////////////////*/
li.questions-item {
background: none repeat scroll 0 0 #fff;
margin: 0 0 10px;
padding:10px;
}
.q-wrapper-chair-False,
.q-wrapper-False-True,
.q-wrapper-False-False {
background: none repeat scroll 0 0 #fff;
display: block;
margin: 10px;
padding: 10px;
}
.q-wrapper-True-False,
.q-wrapper-True-False {
background: none repeat scroll 0 0 #D4F6E3; /*light green*/
display: block;
margin: 10px;
padding: 10px;
}
.q-wrapper-True-True,
.q-wrapper-chair-True {
background:#fa7c8f; /*light red*/
display: block;
margin: 10px;
padding: 10px;
color:#e51837;
}
.flag-wrapper {
float: right;
margin:5px 10px 10px;
}
.q-edit {
margin: 5px 5px 5px 0;
}
.q-edit a.questions-edit {
background: none repeat scroll 0 0 #e51837;
border: 1px solid #e51837;
border-radius: 5px;
color:#fff;
padding:5px 10px;
}
span.flag-wrapper a {
background: none repeat scroll 0 0 #e51837;
border: 1px solid #e51837;
border-radius: 5px;
color:#fff;
}
span.flag-wrapper.flag-approve {}
span.flag-wrapper.flag-trash {}
span.flag-wrapper.flag-checked {}
span.flag-wrapper.flag-approve-comment a.unflag-action {
background:green;
}
span.flag-wrapper.flag-delete-comment a.unflag-action {
background:red;
}
span.flag-wrapper.flag-checked-comment a.unflag-action {
background:green;
}
.submit-info,
.submit-info a {
font-style: italic;
color:#e51837;
}
.q-asked {
font-size:16px;
}
#region-content .q-asked p {
color: #555450;
}
.view-display-comments .views-row {
/*background: none repeat scroll 0 0 white;*/
width: 100%;
}
/* CHAIRMAN SPECIFIC STYLES*/
html.js body.html.not-front.logged-in.page-chair.context-chair.role-authenticated-user.role-chair {
}
.page-approved-questions span.flag-wrapper a,
.page-chair span.flag-wrapper a {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
border: medium none;
color: #d9d9d9;
font-size: 36px;
}
.page-approved-questions span.flag-wrapper.flag-checked-comment a.unflag-action,
.page-chair span.flag-wrapper.flag-checked-comment a.unflag-action {
background: none;
border: medium none;
color: #e51837;
font-size: 36px;
}
.page-approved-questions #region-content,
.page-chair #region-content {margin-top:10px;}
.page-approved-questions #zone-branding,
.page-chair #zone-branding {
margin-bottom:0px;
border:none;
}
.page-approved-questions #zone-header-wrapper,
.page-chair #zone-header-wrapper {}
/*.page-chair #region-header-first {
border-bottom:2px solid #e51837;
}*/
.page-approved-questions #zone-header,
.page-chair #zone-header {
border-bottom:2px solid #e51837;
background:none repeat scroll 0 0 #e51837;
padding-top: 7px;
}
h2.eu {
font-size: 30px;
font-weight: bold;
text-align: center;
text-transform: uppercase;
color:#fff;
}
/* END */
.ajax-progress.ajax-progress-throbber,
.ajax-progress.ajax-progress-throbber .message {
display:none;
}
.page-chair li,
.page-moderate li {
list-style:none;
}
.role-moderator ul.tabs.primary.clearfix,
.role-moderator .vertical-tabs {
display:none;
}
ul.questions {
margin: 10px;
}
ul.questions-controls {
margin: 0;
}
.flag-wrapper a {
padding: 5px;
}
li.questions-item .blockquote {
background: none repeat scroll 0 0 #fff;
margin: 10px 0;
padding: 5px;
}
div.feed-icon {
margin: 0 0 10px 10px;
}
/* EU QUESTION SPECIFIC STYLES */
.page-node-add-question-eu #region-content {
margin: 10px;
padding: 10px;
}
.page-node-add-question-eu h2.page-title {
margin-left:0;
}
/* EVENT PAGES */
h3.event-sub {
font-weight: bold;
font-size:22px;
}
span.bold {
font-weight: bold;
}
span.italic {
font-style:italic;
}
.event p {
margin: 0 0 0 20px;
}
.time {
font-size: 14px;
font-weight: bold;
padding: 1px 0 0;
vertical-align: top;
}
.event {
}
.event tr {
padding: 10px 0 0;
}
.event h4 {
border-bottom: 1px solid #e51837;
margin-bottom: 20px;
}
.pop-out {
margin: 20px 0;
float:left;
}
.pop-out p {
color: #e51837;
text-align:center;
}
#edit-actions #edit-submit,
.pop-out a {
background: #d9d9d9;
color: #e51837;
font-weight: bold;
}
#edit-actions #edit-submit:hover,
.pop-out a:hover {
}
.form-submit.ajax-processed {
background: none repeat scroll 0 0 #d9d9d9;
color: #e51837;
}
#views-exposed-form-user-data-page .form-submit,
.view-user-data a.pop-out,
.fieldset-wrapper .form-submit {
background: #d9d9d9;
color: #e51837;
font-weight: bold;
}
#user-pass #edit-actions #edit-submit,
#user-login #edit-actions #edit-submit,
#user-register-form #edit-actions #edit-submit,
#user-login-form #edit-actions #edit-submit{
background: #e51837;
color: #d9d9d9;
}
.event iframe {
max-width:100% !important;
}
#streamplayer {
width: 100%;
}
#flashplayer {
height: 0;
width: 100%;
padding-bottom: 56.25%;
overflow: hidden;
position: relative;
}
#flashplayer > div {
width: 60%;
margin: 1em auto;
}
#flashplayer .install-flash img {
float: left;
margin-right: 20px;
}
#flashplayer .native-stream {
text-align: center;
}
#flashplayer .native-stream {
text-align: center;
}
#flashplayer .native-stream a { cursor: pointer; color: blue; }
#flashplayer .native-stream a:hover, #flashplayer .native-stream a.hover { text-decoration: underline; }
#flashplayer object {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.views-row {
}
.views-row-odd {
}
.page-node-1 .views-row {
width:100%;
}
.page-moderate .views-row,
.page-chair .views-row {
width:100%;
margin:0;
}
a.views-more-link {
color:#e51837;
}
#block-block-11 p {
color:#d9d9d9;
font-size: 14px;
}
.page-node-add-question-eu #block-block-11 p {
margin-left:0px;
}
/* WELCOME PAGE */
.signature {
float:left;
margin-right:50px;
}
/* HCP POP UP */
#sliding-popup .popup-content #popup-buttons button {
-webkit-appearance: none;
-moz-border-radius: 11px;
-webkit-border-radius: 11px;
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
border-radius: 5px;
background: #e51837;
border: none;
border-color: none;
cursor: pointer;
color: #d9d9d9;
outline: 0;
overflow: visible;
text-shadow: none;
*padding-top: 2px; /* IE7 */
*padding-bottom: 0px; /* IE7 */
box-shadow:none;
}
#confirm-popup-buttons a:hover ,
#sliding-popup .popup-content #popup-buttons button:hover {
background: #e51837;
}
#sliding-popup.sliding-popup-top {
}
#sliding-popup .popup-content {
display: block;
min-height: 60px;
}
#sliding-popup .popup-content #popup-text p {
font-size: 12px;
}
.page-node-45#sliding-popup.sliding-popup-top {
display:none;
}
/* EVENT PAGES */
.soon-come {
background: none repeat scroll 0 0 #e51837;
color: white;
font-size: 24px;
line-height: 30px;
margin-top: -130px;
padding: 50px 0;
position: relative;
text-align: center;
top: 280px;
z-index: 1000;
}
.form-item .description {
color:#e51837;
}
.page-node-46 #block-block-11,
.page-node-46 #block-block-8 {
display:none;
}
.page-node-46 #block-block-12 {
margin: 10px;
}
.node-type-abstract .pop-out {
margin-right: 10px;
}
.page-node-46 #region-content,
.page-node-53 #region-content {
margin: 0;
}
#block-block-3 {
padding: 20px 0 0;
}
#block-block-3 img {
float: left;
width: 100px;
}
#block-block-5 {
float:left;
padding: 20px 0 0;
text-align: left;
margin-top: 10px;
}
article#node-page-53 h2 {
display:none;
}
#confirm-popup-text {
text-align: center;
padding-top:20px;
}
#confirm-popup-text p {
font-size: 22px;
color:#e51837;
}
#confirm-popup-buttons a {
display: block;
float: left;
margin: 5%;
padding: 20px 0;
text-align: center;
width: 40%;
}
article#node-page-53 {
background:url("../../../../default/files/images/opaqueBGwhite.png") repeat scroll 0 0 rgba(0, 0, 0, 0);
}
.page-node-53 #region-postscript-second {
display:none;
}
.item-list ul li {
margin: 0;
padding: 0;
}
#user-login,
#user-register-form {
background: none repeat scroll 0 0 #d9d9d9;
margin-bottom: 0px;
margin-top: 0;
padding: 0;
}
ul.primary {
background: none repeat scroll 0 0 #d9d9d9;
margin: 0;
padding: 20px 20px 4px;
border-bottom: 2px solid #e51837;
}
ul.primary li a {
padding: 5px 10px;
border:none;
background:none;
}
ul.primary li a:hover {
background-color: #e51837;
color:#d9d9d9;
border-color: #e51837;
}
ul.primary li.active a {
border-color: #e51837;
color:#d9d9d9;
background:#e51837;
border-width:0px;
}
/* AGENDA TABLE OUTPUT */
#block-views-agenda-output-agenda-block {
padding:10px;
}
.view-agenda-output {
float:left;
width:100%;
}
.view-agenda-output h2,
.view-agenda-output h3 {
color: #d9d9d9;
}
.view-agenda-output table {
margin-top:20px;
}
.views-field-field-time-slot {
width: 15%
}
.views-field-field-sessions {}
.views-field-field-presenter {}
#node-page-39 {
display: none;
}
tr.even td {
background: #e51837;
}
tr.odd td {
background: none repeat scroll 0 0 #e74961;
}
thead th, th {
background: none repeat scroll 0 0 #d9d9d9;
border-bottom: 1px solid #d9d9d9;
color: #e51837;
text-shadow:none;
}
#question-node-form label {
color:#d9d9d9;
}
#question-node-form .form-item .description {
color: #d9d9d9;
}
#question-node-form .marker, .form-required {
color: #d9d9d9;
}
.block h2.page-title {
border-bottom: 2px solid #d9d9d9;
color: #d9d9d9;
font-size: 28px;
font-weight: bold;
margin: 0 0px 20px 0;
}
.page-node-add-question .block h2.page-title {
margin-right: 0;
}
#question-eu-node-form .description {
margin-top: 10px;
color:#d9d9d9;
}
.page-node-add-question-eu #region-branding,
.page-node-add-question-eu #region-branding-second {
display:none;
}
.page-node-add-question-eu #zone-branding-wrapper {
padding: 0;
}
.click-to-watch {
background: none repeat scroll 0 0 #d9d9d9;
border: 2px solid #e51837;
display: block;
font-size: 32px;
padding: 20px 0;
text-align: center;
width: 100%;
}
a.fieldset-title {
color: #d9d9d9;
}
#region-postscript-first .block {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
float: right;
margin: -20px 10px 0;
padding: 0;
}
#views-form-user-data-page a {
color: #d9d9d9;
}
.view-user-data .view-header {
float: left;
width: 100%;
}
.view-user-data .view-header > p {
clear: both;
float: left;
}
#edit-actionuser-block-user-action, #edit-rules-componentrules-link-set-unblock-users {
margin-bottom: 20px;
margin-right: 20px;
}
.page-node-207 ul li {
color:#d9d9d9;
font-size: 14px;
}
.page-node-207 a {
color: #555450;
}
#block-webform-client-block-208 h2 {
color:#d9d9d9;
}
#block-webform-client-block-208 .links {
margin: 10px 0 20px;
}
#block-webform-client-block-208 .links a {
background: none repeat scroll 0 0 #d9d9d9;
font-weight: bold;
padding: 10px;
}
#block-webform-client-block-208 .links a:hover {
color: #e51837;
}
#block-webform-client-block-208 {
padding-top: 0;
}
/* COMMENTS*/
.username {
display:block;
color: #e51837;
-webkit-appearance: none;
-moz-border-radius: 0;
-webkit-border-radius: 0;
border-radius: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-moz-background-clip: padding;
-webkit-background-clip: padding;
background-clip: padding-box;
background-color: #fff;
border: 1px solid;
border-color: #848484 #c1c1c1 #e1e1e1;
color: #000;
outline: 0;
padding: 2px 3px;
font-size: 13px;
font-family: Arial, sans-serif;
height: 1.8em;
*padding-top: 2px; /* IE7 */
*padding-bottom: 1px; /* IE7 */
*height: auto; /* IE7 */
}
span.username {
color: #e51837;
}
.role-authenticated-user .filter-wrapper {
display: none
}
#edit-preview--2 {
display: none;
}
.page-node-3 article h2 {
display:none;
}
.page-user #region-content .block {
}
.password-strength-title {
color: #d9d9d9;
}
.password-strength-text,
div.password-confirm {
color: #d9d9d9;
}
.reg-btn {
background: none repeat scroll 0 0 #e51837;
display: block;
margin: 20px 0 0;
padding: 14px 0;
text-align: center;
width: 100%;
}
a.reg-btn {
color: #fff;
font-weight: bold;
text-transform: uppercase;
}
.pass-btn {
float:right;
}
/* 1/12/14 */
.page-user .form-item .description {
display: none;
}
.page-user-reset #region-content {
background: none repeat scroll 0 0 #e51837;
}
.page-user-edit #region-content {
background: none repeat scroll 0 0 #e51837;
height: auto;
}
.page-user-edit #edit-field-first-name,
.page-user-edit #edit-field-last-name,
.page-user-edit #edit-field-academic-title,
.page-user-edit #edit-field-country,
.page-user-edit #edit-timezone {
display:none;
}
div.form-item div.password-suggestions {
background:#d9d9d9;
}
#edit-field-country-location .form-select {
width:100%;
}
/* POLL EVERYWHERE */
.pe_multiple_choice_poll_10077397.peWidget .peHeader .peTitle {
background: none repeat scroll 0 0 #e51837;
color: #d9d9d9;
padding: 0 !important;
text-align: left !important;
}
.pe_multiple_choice_poll_10077397.peWidget .peMultipleChoicePoll .peBody {
background: none repeat scroll 0 0 #e51837;
color: #d9d9d9;
}
.pe_multiple_choice_poll_10077397.peWidget .peMultipleChoicePoll .peOptions a.peOption {
background: none repeat scroll 0 0 #d9d9d9;
color: #e51837 !important;
margin-top: 5px;
}
.pe_multiple_choice_poll_10077397.peWidget .peHeader .peStatus,
.pe_multiple_choice_poll_10077397.peWidget .peMultipleChoicePoll .peOptions a.peOption:hover {
background:#555450 !important;
color: #d9d9d9 !important;
}
.pe_multiple_choice_poll_10077397.peWidget .peMultipleChoicePoll .peChart .peChartBar {
background: #d9d9d9 !important;
color: #555450 !important;
}
/* END POLL EVERYWHERE */
/* LIVESTREAM PLAYER */
#livestream-player {
width:100%;
}
#live-cast {
height: 0;
width: 100%;
padding-bottom: 56.25%;
overflow: hidden;
position: relative;
margin-bottom:20px;
}
#live-cast iframe {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
/* END LIVESTREAM PLATYER */
article#node-webform-229 input#edit-previous.form-submit,
article#node-webform-229 input#edit-next.form-submit {
background:#d9d9d9;
color:#e51837;
}
article#node-webform-229 input#edit-submit.form-submit {
margin:0;
}
form#webform-client-form-229 .webform-component-webform_grid label {
background: none repeat scroll 0 0 #d9d9d9;
border-bottom: 3px solid red;
color: #e51837;
font-size: 18px;
padding: 5px;
}
/* TRACKING PAGE */
.view-tracking .view-header > div,
.view-tracking .view-header > section {
background-color: #d9d9d9;
}
.view-tracking .view-header .tracking {
padding: 0;
}
.view-tracking .view-header .left {
display: inline-block;
margin-right: 20px;
margin-bottom: 20px;
}
.view-tracking .view-header .right {
margin-bottom: 20px;
display: table;
}
.view-tracking .view-header .half {
width: 420px;
}
.view-tracking .view-header .quarter {
width: 200px;
}
.view-tracking .view-header h2.block-title {
font-size: 18px;
line-height: 25px;
margin: 5px;
}
.view-tracking #aps-geo-location {
padding: 10px;
}
.view-tracking .view-header .view-display-id-online .view-content,
.view-tracking .view-header .view-display-id-webcast .view-content {
font-size: 65pt;
line-height: 80pt;
}
.view-tracking .view-header .view-display-id-online .view-content .field-content,
.view-tracking .view-header .view-display-id-webcast .view-content .field-content {
margin: 0 10px;
}
.view-tracking .view-header .view-display-id-views .view-content ol {
margin-bottom: 10px;
}
.view-tracking .view-header .view-display-id-views .view-content li {
font-size: 10pt;
line-height: 16pt;
list-style: decimal;
}
/* responsive menu */
.responsive-menus.responsified span.toggler {
background: none repeat scroll 0 0 #e51837;
border-radius: 0;
box-shadow: none;
color: #fff;
cursor: pointer;
display: block;
font-size: 1.35em;
outline: medium none;
padding: 10px;
text-align: center;
}
.responsive-menus.responsified .responsive-menus-simple li a {
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
color: #fff;
display: block;
margin: 0;
padding: 1em 5%;
text-align: left;
text-decoration: none;
text-transform: uppercase;
background: none repeat scroll 0 0 #e51837;
}
.responsive-menus.responsified .responsive-menus-simple {
box-shadow:none;
}
|
ApsGitAdmin/GEO-J15782
|
sites/all/themes/advent_basetheme/css/global.css
|
CSS
|
gpl-2.0
| 34,547
|
<?php
//
// Created on: <17-Apr-2002 11:05:08 amos>
//
// SOFTWARE NAME: eZ Publish
// SOFTWARE RELEASE: 4.0.1
// BUILD VERSION: 22260
// COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
// SOFTWARE LICENSE: GNU General Public License v2.0
// NOTICE: >
// This program is free software; you can redistribute it and/or
// modify it under the terms of version 2.0 of the GNU General
// Public License as published by the Free Software Foundation.
//
// This program 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 version 2.0 of the GNU General
// Public License along with this program; if not, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
// MA 02110-1301, USA.
//
//
$Module = array( "name" => "eZWorkflow" );
$ViewList = array();
$ViewList["view"] = array(
"script" => "view.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowID" ) );
$ViewList["edit"] = array(
"script" => "edit.php",
'ui_context' => 'edit',
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowID", "GroupID", "GroupName" ) );
$ViewList["groupedit"] = array(
"script" => "groupedit.php",
'ui_context' => 'edit',
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowGroupID" ) );
$ViewList["down"] = array(
"script" => "edit.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowID", "EventID" ) );
$ViewList["up"] = array(
"script" => "edit.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowID", "EventID" ) );
$ViewList["workflowlist"] = array(
"script" => "workflowlist.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "GroupID" ) );
$ViewList["grouplist"] = array(
"script" => "grouplist.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array() );
$ViewList["process"] = array(
"script" => "process.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowProcessID" ) );
$ViewList["run"] = array(
"script" => "run.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowProcessID" ) );
$ViewList["event"] = array(
"script" => "event.php",
"default_navigation_part" => 'ezsetupnavigationpart',
"params" => array( "WorkflowID", "EventID" ) );
$ViewList["processlist"] = array(
"script" => "processlist.php",
"default_navigation_part" => 'ezsetupnavigationpart',
'unordered_params' => array( 'offset' => 'Offset' ),
"params" => array( ) );
?>
|
mvcaaa/ssur
|
kernel/workflow/module.php
|
PHP
|
gpl-2.0
| 2,942
|
/*
* VM ops
*
* Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
* Copyright (C) 2008-2009 PetaLogix
* Copyright (C) 2006 Atmark Techno, Inc.
* Changes for MMU support:
* Copyright (C) 2007 Xilinx, Inc. All rights reserved.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/
#ifndef _ASM_MICROBLAZE_PAGE_H
#define _ASM_MICROBLAZE_PAGE_H
#include <linux/pfn.h>
#include <asm/setup.h>
#include <asm/asm-compat.h>
#include <linux/const.h>
#ifdef __KERNEL__
/* PAGE_SHIFT determines the page size */
#if defined(CONFIG_MICROBLAZE_32K_PAGES)
#define PAGE_SHIFT 15
#elif defined(CONFIG_MICROBLAZE_16K_PAGES)
#define PAGE_SHIFT 14
#elif defined(CONFIG_MICROBLAZE_8K_PAGES)
#define PAGE_SHIFT 13
#else
#define PAGE_SHIFT 12
#endif
#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
#define LOAD_OFFSET ASM_CONST((CONFIG_KERNEL_START-CONFIG_KERNEL_BASE_ADDR))
#ifndef __ASSEMBLY__
/* MS be sure that SLAB allocates aligned objects */
#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
#define ARCH_SLAB_MINALIGN L1_CACHE_BYTES
#define PAGE_UP(addr) (((addr)+((PAGE_SIZE)-1))&(~((PAGE_SIZE)-1)))
#define PAGE_DOWN(addr) ((addr)&(~((PAGE_SIZE)-1)))
#ifndef CONFIG_MMU
/*
* PAGE_OFFSET -- the first address of the first page of memory. When not
* using MMU this corresponds to the first free page in physical memory (aligned
* on a page boundary).
*/
extern unsigned int __page_offset;
#define PAGE_OFFSET __page_offset
#else /* CONFIG_MMU */
/*
* PAGE_OFFSET -- the first address of the first page of memory. With MMU
* it is set to the kernel start address (aligned on a page boundary).
*
* CONFIG_KERNEL_START is defined in arch/microblaze/config.in and used
* in arch/microblaze/Makefile.
*/
#define PAGE_OFFSET CONFIG_KERNEL_START
/*
* The basic type of a PTE - 32 bit physical addressing.
*/
typedef unsigned long pte_basic_t;
#define PTE_SHIFT (PAGE_SHIFT - 2) /* 1024 ptes per page */
#define PTE_FMT "%.8lx"
#endif /* CONFIG_MMU */
# define copy_page(to, from) memcpy((to), (from), PAGE_SIZE)
# define clear_page(pgaddr) memset((pgaddr), 0, PAGE_SIZE)
# define clear_user_page(pgaddr, vaddr, page) memset((pgaddr), 0, PAGE_SIZE)
# define copy_user_page(vto, vfrom, vaddr, topg) \
memcpy((vto), (vfrom), PAGE_SIZE)
/*
* These are used to make use of C type-checking..
*/
typedef struct page *pgtable_t;
typedef struct { unsigned long pte; } pte_t;
typedef struct { unsigned long pgprot; } pgprot_t;
/* FIXME this can depend on linux kernel version */
# ifdef CONFIG_MMU
typedef struct { unsigned long pmd; } pmd_t;
typedef struct { unsigned long pgd; } pgd_t;
# else /* CONFIG_MMU */
typedef struct { unsigned long ste[64]; } pmd_t;
typedef struct { pmd_t pue[1]; } pud_t;
typedef struct { pud_t pge[1]; } pgd_t;
# endif /* CONFIG_MMU */
# define pte_val(x) ((x).pte)
# define pgprot_val(x) ((x).pgprot)
# ifdef CONFIG_MMU
# define pmd_val(x) ((x).pmd)
# define pgd_val(x) ((x).pgd)
# else /* CONFIG_MMU */
# define pmd_val(x) ((x).ste[0])
# define pud_val(x) ((x).pue[0])
# define pgd_val(x) ((x).pge[0])
# endif /* CONFIG_MMU */
# define __pte(x) ((pte_t) { (x) })
# define __pmd(x) ((pmd_t) { (x) })
# define __pgd(x) ((pgd_t) { (x) })
# define __pgprot(x) ((pgprot_t) { (x) })
/**
* Conversions for virtual address, physical address, pfn, and struct
* page are defined in the following files.
*
* virt -+
* | asm-microblaze/page.h
* phys -+
* | linux/pfn.h
* pfn -+
* | asm-generic/memory_model.h
* page -+
*
*/
extern unsigned long max_low_pfn;
extern unsigned long min_low_pfn;
extern unsigned long max_pfn;
extern unsigned long memory_start;
extern unsigned long memory_size;
extern unsigned long lowmem_size;
extern unsigned long kernel_tlb;
extern int page_is_ram(unsigned long pfn);
# define phys_to_pfn(phys) (PFN_DOWN(phys))
# define pfn_to_phys(pfn) (PFN_PHYS(pfn))
# define virt_to_pfn(vaddr) (phys_to_pfn((__pa(vaddr))))
# define pfn_to_virt(pfn) __va(pfn_to_phys((pfn)))
# ifdef CONFIG_MMU
# define virt_to_page(kaddr) (pfn_to_page(__pa(kaddr) >> PAGE_SHIFT))
# define page_to_virt(page) __va(page_to_pfn(page) << PAGE_SHIFT)
# define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
# else /* CONFIG_MMU */
# define virt_to_page(vaddr) (pfn_to_page(virt_to_pfn(vaddr)))
# define page_to_virt(page) (pfn_to_virt(page_to_pfn(page)))
# define page_to_phys(page) (pfn_to_phys(page_to_pfn(page)))
# define page_to_bus(page) (page_to_phys(page))
# define phys_to_page(paddr) (pfn_to_page(phys_to_pfn(paddr)))
# endif /* CONFIG_MMU */
# ifndef CONFIG_MMU
# define pfn_valid(pfn) (((pfn) >= min_low_pfn) && \
((pfn) <= (min_low_pfn + max_mapnr)))
# define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
# else /* CONFIG_MMU */
# define ARCH_PFN_OFFSET (memory_start >> PAGE_SHIFT)
# define pfn_valid(pfn) ((pfn) < (max_mapnr + ARCH_PFN_OFFSET))
# define VALID_PAGE(page) ((page - mem_map) < max_mapnr)
# endif /* CONFIG_MMU */
# endif /* __ASSEMBLY__ */
#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr)))
# define __pa(x) __virt_to_phys((unsigned long)(x))
# define __va(x) ((void *)__phys_to_virt((unsigned long)(x)))
/* Convert between virtual and physical address for MMU. */
/* Handle MicroBlaze processor with virtual memory. */
#ifndef CONFIG_MMU
#define __virt_to_phys(addr) addr
#define __phys_to_virt(addr) addr
#define tophys(rd, rs) addik rd, rs, 0
#define tovirt(rd, rs) addik rd, rs, 0
#else
#define __virt_to_phys(addr) \
((addr) + CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START)
#define __phys_to_virt(addr) \
((addr) + CONFIG_KERNEL_START - CONFIG_KERNEL_BASE_ADDR)
#define tophys(rd, rs) \
addik rd, rs, (CONFIG_KERNEL_BASE_ADDR - CONFIG_KERNEL_START)
#define tovirt(rd, rs) \
addik rd, rs, (CONFIG_KERNEL_START - CONFIG_KERNEL_BASE_ADDR)
#endif /* CONFIG_MMU */
#define TOPHYS(addr) __virt_to_phys(addr)
#ifdef CONFIG_MMU
#define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | VM_EXEC | \
VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
#endif /* CONFIG_MMU */
#endif /* __KERNEL__ */
#include <asm-generic/memory_model.h>
#include <asm-generic/getorder.h>
#endif /* _ASM_MICROBLAZE_PAGE_H */
|
Jackeagle/android_kernel_sony_c2305
|
arch/microblaze/include/asm/page.h
|
C
|
gpl-2.0
| 6,556
|
# -*- coding: utf-8 -*-
"""
Estimate the international "visibility" of countries by retrieving the
average number of articles the New York Times returns in its search query.
For each year and each country, a query is send to the NYT api and the
number of returned hits (i.e. articles) is taken as estimate for the
international "visibility". To ensure optimal coverage, for each country
synonyms have been defined (see CountryCodeMapper.py) and the average of
the count is taken.
----
Copyright (C) 2015 Niklas Berliner
This program 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 2 of the License, or
(at your option) any later version.
This program 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 this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
import sys
import os
import pickle
from time import sleep
from countryCodeMapper import CountryCodeMapper
from utils import Country, CountryContainer
from nytimesarticles import articleAPI, DeveloperOverRate
api = articleAPI('/* Your API access key here */')
# Use tmp folder to keep intermediate results. Final output will be placed there as well
tmpFolder = "../data/newspaper/raw/"
## Read the temporary folder content
done = [ int(fname[8:-2]) for fname in os.listdir(tmpFolder) if fname != "country_aggregate.p" ]
# Initialise some variables
C = CountryCodeMapper()
countries = C.countryNames()
container = CountryContainer()
# Run the scrape for the years 1980 to 2014 (including)
dates = range(1980,2015)
for date in dates:
if date in done:
print("Loading year", date)
a = pickle.load(open(tmpFolder + "country_%s.p" %str(date), "rb"))
else:
print("Processing year", date)
a = Country(date)
for idx, country in enumerate(countries):
success = False
i = 0
while i<=3 and not success:
try:
query = api.search( q = country,
begin_date = str(date) + '0101',
end_date = str(date) + '1231'
)
sleep(.1)
assert( query["status"] == "OK" )
count = query["response"]["meta"]["hits"]
a(country, count)
i += 1
success = True
except DeveloperOverRate:
print("You most probably exceeded you api key limit\n")
sys.exit()
except:
success = False
i += 1
sleep(1) # allow the server some quiet time
if not success:
print("Error in %s, %s" %(date, country))
# Store the year as pickle in case something breaks during the run
pickle.dump(a, open(tmpFolder + "country_%s.p" %str(date), "wb"))
# Save the original data as csv file
a.save(tmpFolder + "country_%s.csv" %str(date))
# Add the country to the container
container(a)
pickle.dump(container, open(tmpFolder + "country_aggregate.p", "wb"))
# Save everything to a csv file. The columns will be the countries, the rows
# will be the years. One column contains the years (sanity check to ensure
# that the row order is not messed up).
container.save(tmpFolder + "/NYT_scrape.csv")
|
nberliner/delveData
|
lib/countryMentionNYT.py
|
Python
|
gpl-2.0
| 3,856
|
.class-almost-full {
background-color: #857296;
color: white;
}
.class-full {
background-color: #e46558;
color: white;
}
|
School-Of-Future-Applications/SOFA
|
SOFA/Content/class-capacity.css
|
CSS
|
gpl-2.0
| 141
|
<?php
/*
Support class Add Link to Facebook plugin
Copyright (c) 2011-2015 by Marcel Bokhorst
*/
/*
GNU General Public License version 3
Copyright (c) 2011-2014 Marcel Bokhorst
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once('add-link-to-facebook-const.php');
// Define class
if (!class_exists('WPAL2Facebook')) {
class WPAL2Facebook {
// Class variables
var $main_file = null;
var $debug = null;
var $site_id = '';
var $blog_id = '';
// Constructor
function __construct() {
global $wp_version, $blog_id;
// Get main file name
$this->main_file = str_replace('-class', '', __FILE__);
$this->filename = plugin_basename($this->main_file);
$this->filenames = explode("/", $this->filename);
$this->main_plugin_name = $this->filenames[0];
// Log
$this->debug = get_option(c_al2fb_option_debug);
// Get site & blog id
if (is_multisite()) {
$current_site = get_current_site();
$this->site_id = $current_site->id;
}
$this->blog_id = $blog_id;
// register for de-activation
register_deactivation_hook($this->main_file, array(&$this, 'Deactivate'));
// Register actions
add_action('init', array(&$this, 'Init'), 0);
if (is_admin()) {
add_action('admin_menu', array(&$this, 'Admin_menu'));
add_filter('plugin_action_links', array(&$this, 'Plugin_action_links'), 10, 2);
add_action('admin_notices', array(&$this, 'Admin_notices'));
add_action('post_submitbox_misc_actions', array(&$this, 'Post_submitbox_misc_actions'));
add_filter('manage_posts_columns', array(&$this, 'Manage_posts_columns'));
add_action('manage_posts_custom_column', array(&$this, 'Manage_posts_custom_column'), 10, 2);
add_filter('manage_pages_columns', array(&$this, 'Manage_posts_columns'));
add_action('manage_pages_custom_column', array(&$this, 'Manage_posts_custom_column'), 10, 2);
add_action('add_meta_boxes', array(&$this, 'Add_meta_boxes'));
add_action('personal_options', array(&$this, 'Personal_options'));
add_action('personal_options_update', array(&$this, 'Personal_options_update'));
add_action('edit_user_profile_update', array(&$this, 'Personal_options_update'));
}
add_action('transition_post_status', array(&$this, 'Transition_post_status'), 10, 3);
add_action('xmlrpc_publish_post', array(&$this, 'Remote_publish'));
add_action('app_publish_post', array(&$this, 'Remote_publish'));
add_action('future_to_publish', array(&$this, 'Future_to_publish'));
add_action('before_delete_post', array(&$this, 'Before_delete_post'));
add_action('al2fb_publish', array(&$this, 'Remote_publish'));
if (get_option(c_al2fb_option_use_pp))
add_action('publish_post', array(&$this, 'Remote_publish'));
add_action('comment_post', array(&$this, 'Comment_post'), 999);
add_action('comment_unapproved_to_approved', array(&$this, 'Comment_approved'));
add_action('comment_approved_to_unapproved', array(&$this, 'Comment_unapproved'));
add_action('trash_comment', array(&$this, 'Comment_trash'));
add_action('untrash_comment', array(&$this, 'Comment_untrash'));
add_action('spam_comment', array(&$this, 'Comment_spam'));
add_action('unspam_comment', array(&$this, 'Comment_unspam'));
add_action('delete_comment', array(&$this, 'Delete_comment'));
$fprio = intval(get_option(c_al2fb_option_filter_prio));
if ($fprio <= 0)
$fprio = 999;
// Content
add_action('wp_head', array(&$this, 'WP_head'));
add_filter('the_content', array(&$this, 'The_content'), $fprio);
add_filter('bbp_get_topic_content', array(&$this, 'The_content'), $fprio);
add_filter('bbp_get_reply_content', array(&$this, 'The_content'), $fprio);
add_filter('comments_array', array(&$this, 'Comments_array'), 10, 2);
add_filter('get_comments_number', array(&$this, 'Get_comments_number'), 10, 2);
add_filter('comment_class', array(&$this, 'Comment_class'));
add_filter('get_avatar', array(&$this, 'Get_avatar'), 11, 5);
// Shortcodes
add_shortcode('al2fb_likers', array(&$this, 'Shortcode_likers'));
add_shortcode('al2fb_anchor', array(&$this, 'Shortcode_anchor'));
add_shortcode('al2fb_like_count', array(&$this, 'Shortcode_like_count'));
add_shortcode('al2fb_like_button', array(&$this, 'Shortcode_like_button'));
add_shortcode('al2fb_like_box', array(&$this, 'Shortcode_like_box'));
add_shortcode('al2fb_send_button', array(&$this, 'Shortcode_send_button'));
add_shortcode('al2fb_subscribe_button', array(&$this, 'Shortcode_subscribe_button'));
add_shortcode('al2fb_comments_plugin', array(&$this, 'Shortcode_comments_plugin'));
add_shortcode('al2fb_face_pile', array(&$this, 'Shortcode_face_pile'));
add_shortcode('al2fb_profile_link', array(&$this, 'Shortcode_profile_link'));
add_shortcode('al2fb_registration', array(&$this, 'Shortcode_registration'));
add_shortcode('al2fb_login', array(&$this, 'Shortcode_login'));
add_shortcode('al2fb_activity_feed', array(&$this, 'Shortcode_activity_feed'));
if (get_option(c_al2fb_option_shortcode_widget))
add_filter('widget_text', 'do_shortcode');
// Custom filters
add_filter('al2fb_excerpt', array(&$this, 'Filter_excerpt'), 10, 2);
add_filter('al2fb_content', array(&$this, 'Filter_content'), 10, 2);
add_filter('al2fb_comment', array(&$this, 'Filter_comment'), 10, 3);
add_filter('al2fb_fb_feed', array(&$this, 'Filter_feed'), 10, 1);
add_filter('al2fb_preprocess_comment', array(&$this, 'Preprocess_comment'), 10, 2);
add_filter('al2fb_video', array(&$this, 'Filter_video'), 10, 2);
// Widget
add_action('widgets_init', create_function('', 'return register_widget("AL2FB_Widget");'));
if (!is_admin())
add_action('wp_print_styles', array(&$this, 'WP_print_styles'));
// Cron
add_filter('cron_schedules', array(&$this, 'Cron_schedules'));
// Misc.
add_filter('puc_request_info_result-add-link-to-facebook', array(&$this, 'Update'), 10, 2);
}
// Handle plugin activation
function Activate() {
self::Upgrade();
add_option('readygraph_tutorial', 'true');
add_option('rg_al2fb_plugin_do_activation_redirect', true);
}
function Upgrade() {
global $wpdb;
$version = get_option(c_al2fb_option_version);
if (empty($version))
update_option(c_al2fb_option_siteurl, true);
if ($version <= 1) {
delete_option(c_al2fb_meta_client_id);
delete_option(c_al2fb_meta_app_secret);
delete_option(c_al2fb_meta_access_token);
delete_option(c_al2fb_meta_picture_type);
delete_option(c_al2fb_meta_picture);
delete_option(c_al2fb_meta_page);
delete_option(c_al2fb_meta_donated);
}
if ($version <= 2) {
$rows = $wpdb->get_results("SELECT user_id, meta_value FROM " . $wpdb->usermeta . " WHERE meta_key='al2fb_integrate'");
foreach ($rows as $row) {
update_user_meta($row->user_id, c_al2fb_meta_fb_comments, $row->meta_value);
update_user_meta($row->user_id, c_al2fb_meta_fb_likes, $row->meta_value);
delete_user_meta($row->user_id, 'al2fb_integrate');
}
}
if ($version <= 3) {
global $wpdb;
$rows = $wpdb->get_results("SELECT ID FROM " . $wpdb->users);
foreach ($rows as $row)
update_user_meta($row->ID, c_al2fb_meta_like_faces, true);
}
if ($version <= 4) {
$rows = $wpdb->get_results("SELECT user_id, meta_value FROM " . $wpdb->usermeta . " WHERE meta_key='" . c_al2fb_meta_trailer . "'");
foreach ($rows as $row) {
$value = get_user_meta($row->user_id, c_al2fb_meta_trailer, true);
update_user_meta($row->user_id, c_al2fb_meta_trailer, ' ' . $value);
}
}
if ($version <= 5) {
if (!get_option(c_al2fb_option_css))
update_option(c_al2fb_option_css,
'.al2fb_widget_comments { }
.al2fb_widget_comments li { }
.al2fb_widget_picture { width: 32px; height: 32px; }
.al2fb_widget_name { }
.al2fb_widget_comment { }
.al2fb_widget_date { font-size: smaller; }
');
}
if ($version <= 7) {
update_option(c_al2fb_option_noshortcode, true);
update_option(c_al2fb_option_nofilter, true);
}
if ($version <= 8)
update_option(c_al2fb_option_nofilter_comments, true);
if ($version < 10)
update_option(c_al2fb_option_version, 10);
// 11 when authorizing with 10
if ($version == 11) {
//update_option(c_al2fb_option_uselinks, true);
update_option(c_al2fb_option_version, 12);
}
if ($version <= 12) {
if (empty($version))
add_option(c_al2fb_option_exclude_custom, true);
update_option(c_al2fb_option_version, 13);
}
}
// Handle plugin deactivation
function Deactivate() {
// Stop cron job
wp_clear_scheduled_hook('al2fb_cron');
// Cleanup data
if (get_option(c_al2fb_option_clean)) {
global $wpdb;
// Delete options
$rows = $wpdb->get_results("SELECT option_name FROM " . $wpdb->options . " WHERE option_name LIKE 'al2fb_%'");
foreach ($rows as $row)
delete_option($row->option_name);
// Delete user meta values
$rows = $wpdb->get_results("SELECT user_id, meta_key FROM " . $wpdb->usermeta . " WHERE meta_key LIKE 'al2fb_%'");
foreach ($rows as $row)
delete_user_meta($row->user_id, $row->meta_key);
}
}
// Initialization
function Init() {
// I18n
load_plugin_textdomain(c_al2fb_text_domain, false, dirname(plugin_basename(__FILE__)) . '/language/');
// Image request
if (isset($_GET['al2fb_image'])) {
$img = dirname(__FILE__) . '/wp-blue-s.png';
header('Content-type: image/png');
readfile($img);
exit();
}
// Data URI request
if (isset($_GET['al2fb_data_uri'])) {
$post = get_post($_GET['al2fb_data_uri']);
$data_uri = self::Get_first_image($post);
// data:image/png;base64,
// data:[<MIME-type>][;charset=<encoding>][;base64],<data>
$semi = strpos($data_uri, ';');
$comma = strpos($data_uri, ',');
$content_type = substr($data_uri, 5, $semi - 5);
$data = substr($data_uri, $comma + 1);
header('Content-type: ' . $content_type);
echo base64_decode($data);
exit();
}
// Facebook registration
if (isset($_REQUEST['al2fb_reg'])) {
WPAL2Int::Facebook_registration();
exit();
}
// Facebook login
if (isset($_REQUEST['al2fb_login'])) {
WPAL2Int::Facebook_login();
exit();
}
// Facebook subscription
if (isset($_REQUEST['al2fb_subscription'])) {
self::Handle_fb_subscription();
exit();
}
// Set default capability
if (!get_option(c_al2fb_option_min_cap))
update_option(c_al2fb_option_min_cap, 'edit_posts');
// Enqueue style sheet
if (is_admin()) {
$css_name = $this->Change_extension(basename($this->main_file), '-admin.css');
$css_url = plugins_url($css_name, __FILE__);
wp_register_style('al2fb_style_admin', $css_url);
wp_enqueue_style('al2fb_style_admin');
}
else {
$upload_dir = wp_upload_dir();
$css_name = $this->Change_extension(basename($this->main_file), '.css');
if (file_exists($upload_dir['basedir'] . '/' . $css_name))
$css_url = $upload_dir['baseurl'] . '/' . $css_name;
else if (file_exists(TEMPLATEPATH . '/' . $css_name))
$css_url = get_bloginfo('template_directory') . '/' . $css_name;
else
$css_url = plugins_url($css_name, __FILE__);
wp_register_style('al2fb_style', $css_url);
wp_enqueue_style('al2fb_style');
}
if (get_option(c_al2fb_option_use_ssp) || is_admin())
wp_enqueue_script('jquery');
// Social share privacy
if (get_option(c_al2fb_option_use_ssp))
wp_enqueue_script('socialshareprivacy', plugins_url('/js/jquery.socialshareprivacy.js', __FILE__), array('jquery'));
// Check user capability
if (current_user_can(get_option(c_al2fb_option_min_cap))) {
if (is_admin()) {
// Initiate Facebook authorization
if (isset($_REQUEST['al2fb_action']) && $_REQUEST['al2fb_action'] == 'init') {
// Debug info
update_option(c_al2fb_log_redir_init, date('c'));
// Get current user
global $user_ID;
get_currentuserinfo();
// Clear cache
WPAL2Int::Clear_fb_pages_cache($user_ID);
WPAL2Int::Clear_fb_groups_cache($user_ID);
WPAL2Int::Clear_fb_friends_cache($user_ID);
// Redirect
$auth_url = WPAL2Int::Authorize_url($user_ID);
try {
// Check
if (ini_get('safe_mode') || ini_get('open_basedir') || $this->debug)
update_option(c_al2fb_log_redir_check, 'No');
else {
$response = WPAL2Int::Request($auth_url, '', 'GET');
update_option(c_al2fb_log_redir_check, date('c'));
}
// Redirect
wp_redirect($auth_url);
exit();
}
catch (Exception $e) {
// Register error
update_option(c_al2fb_log_redir_check, $e->getMessage());
update_option(c_al2fb_last_error, $e->getMessage());
update_option(c_al2fb_last_error_time, date('c'));
// Redirect
if (is_multisite()) {
global $blog_id;
$error_url = get_admin_url($blog_id, 'admin.php?page=' . $this->main_plugin_name, 'admin');
}
else
$error_url = admin_url('admin.php?page=' . $this->main_plugin_name);
$error_url .= '&al2fb_action=error';
$error_url .= '&error=' . urlencode($e->getMessage());
wp_redirect($error_url);
exit();
}
}
}
// Handle Facebook authorization
WPAL2Int::Authorize();
}
self::Upgrade();
}
// Display admin messages
function Admin_notices() {
// Check user capability
if (current_user_can(get_option(c_al2fb_option_min_cap))) {
// Get current user
global $user_ID;
get_currentuserinfo();
// Check actions
if (isset($_REQUEST['al2fb_action'])) {
// Configuration
if ($_REQUEST['al2fb_action'] == 'config')
self::Action_config();
// Authorization
else if ($_REQUEST['al2fb_action'] == 'authorize')
self::Action_authorize();
// Mail debug info
else if ($_REQUEST['al2fb_action'] == 'mail')
self::Action_mail();
}
self::Check_config();
}
}
// Save settings
function Action_config() {
// Security check
check_admin_referer(c_al2fb_nonce_action, c_al2fb_nonce_name);
// Get current user
global $user_ID;
get_currentuserinfo();
// Default values
$consts = get_defined_constants(true);
foreach ($consts['user'] as $name => $value) {
if (strpos($value, 'al2fb_') === 0 &&
$value != c_al2fb_meta_trailer &&
$value != c_al2fb_meta_fb_comments_trailer)
if (isset($_POST[$value]) && is_string($_POST[$value]))
$_POST[$value] = trim($_POST[$value]);
else if (empty($_POST[$value]))
$_POST[$value] = null;
}
if (empty($_POST[c_al2fb_meta_picture_type]))
$_POST[c_al2fb_meta_picture_type] = 'post';
// Prevent losing selected page
if (!self::Is_authorized($user_ID) ||
(!WPAL2Int::Check_multiple() &&
get_user_meta($user_ID, c_al2fb_meta_use_groups, true) &&
get_user_meta($user_ID, c_al2fb_meta_group, true))) {
$_POST[c_al2fb_meta_page] = get_user_meta($user_ID, c_al2fb_meta_page, true);
$_POST[c_al2fb_meta_page_extra] = get_user_meta($user_ID, c_al2fb_meta_page_extra, true);
}
// Prevent losing selected group
if (!self::Is_authorized($user_ID) || !get_user_meta($user_ID, c_al2fb_meta_use_groups, true)) {
$_POST[c_al2fb_meta_group] = get_user_meta($user_ID, c_al2fb_meta_group, true);
$_POST[c_al2fb_meta_group_extra] = get_user_meta($user_ID, c_al2fb_meta_group_extra, true);
}
// Prevent losing selected friends
if (!self::Is_authorized($user_ID))
$_POST[c_al2fb_meta_friend_extra] = get_user_meta($user_ID, c_al2fb_meta_friend_extra, true);
// App ID or secret changed
if (get_user_meta($user_ID, c_al2fb_meta_client_id, true) != $_POST[c_al2fb_meta_client_id] ||
get_user_meta($user_ID, c_al2fb_meta_app_secret, true) != $_POST[c_al2fb_meta_app_secret]) {
delete_user_meta($user_ID, c_al2fb_meta_access_token);
WPAL2Int::Clear_fb_pages_cache($user_ID);
WPAL2Int::Clear_fb_groups_cache($user_ID);
WPAL2Int::Clear_fb_friends_cache($user_ID);
}
// Like or send button enabled
if ((!get_user_meta($user_ID, c_al2fb_meta_post_like_button, true) && !empty($_POST[c_al2fb_meta_post_like_button])) ||
(!get_user_meta($user_ID, c_al2fb_meta_post_send_button, true) && !empty($_POST[c_al2fb_meta_post_send_button])))
$_POST[c_al2fb_meta_open_graph] = true;
// Update user options
update_user_meta($user_ID, c_al2fb_meta_client_id, sanitize_text_field($_POST[c_al2fb_meta_client_id]));
update_user_meta($user_ID, c_al2fb_meta_app_secret, sanitize_text_field($_POST[c_al2fb_meta_app_secret]));
update_user_meta($user_ID, c_al2fb_meta_picture_type, $_POST[c_al2fb_meta_picture_type]);
update_user_meta($user_ID, c_al2fb_meta_picture, sanitize_text_field($_POST[c_al2fb_meta_picture]));
update_user_meta($user_ID, c_al2fb_meta_picture_default, sanitize_text_field($_POST[c_al2fb_meta_picture_default]));
update_user_meta($user_ID, c_al2fb_meta_picture_size, $_POST[c_al2fb_meta_picture_size]);
update_user_meta($user_ID, c_al2fb_meta_icon, sanitize_text_field($_POST[c_al2fb_meta_icon]));
update_user_meta($user_ID, c_al2fb_meta_page, $_POST[c_al2fb_meta_page]);
update_user_meta($user_ID, c_al2fb_meta_page_extra, $_POST[c_al2fb_meta_page_extra]);
update_user_meta($user_ID, c_al2fb_meta_use_groups, $_POST[c_al2fb_meta_use_groups]);
update_user_meta($user_ID, c_al2fb_meta_group, $_POST[c_al2fb_meta_group]);
update_user_meta($user_ID, c_al2fb_meta_group_extra, $_POST[c_al2fb_meta_group_extra]);
update_user_meta($user_ID, c_al2fb_meta_friend_extra, $_POST[c_al2fb_meta_friend_extra]);
update_user_meta($user_ID, c_al2fb_meta_caption, $_POST[c_al2fb_meta_caption]);
update_user_meta($user_ID, c_al2fb_meta_msg, $_POST[c_al2fb_meta_msg]);
update_user_meta($user_ID, c_al2fb_meta_auto_excerpt, $_POST[c_al2fb_meta_auto_excerpt]);
update_user_meta($user_ID, c_al2fb_meta_shortlink, $_POST[c_al2fb_meta_shortlink]);
update_user_meta($user_ID, c_al2fb_meta_privacy, $_POST[c_al2fb_meta_privacy]);
update_user_meta($user_ID, c_al2fb_meta_some_friends, $_POST[c_al2fb_meta_some_friends]);
update_user_meta($user_ID, c_al2fb_meta_add_new_page, $_POST[c_al2fb_meta_add_new_page]);
update_user_meta($user_ID, c_al2fb_meta_show_permalink, $_POST[c_al2fb_meta_show_permalink]);
update_user_meta($user_ID, c_al2fb_meta_social_noexcerpt, $_POST[c_al2fb_meta_social_noexcerpt]);
update_user_meta($user_ID, c_al2fb_meta_trailer, $_POST[c_al2fb_meta_trailer]);
update_user_meta($user_ID, c_al2fb_meta_hyperlink, $_POST[c_al2fb_meta_hyperlink]);
update_user_meta($user_ID, c_al2fb_meta_fb_comments, $_POST[c_al2fb_meta_fb_comments]);
update_user_meta($user_ID, c_al2fb_meta_fb_comments_trailer, $_POST[c_al2fb_meta_fb_comments_trailer]);
update_user_meta($user_ID, c_al2fb_meta_fb_comments_postback, $_POST[c_al2fb_meta_fb_comments_postback]);
update_user_meta($user_ID, c_al2fb_meta_fb_comments_only, $_POST[c_al2fb_meta_fb_comments_only]);
update_user_meta($user_ID, c_al2fb_meta_fb_comments_copy, $_POST[c_al2fb_meta_fb_comments_copy]);
update_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, $_POST[c_al2fb_meta_fb_comments_nolink]);
update_user_meta($user_ID, c_al2fb_meta_fb_likes, $_POST[c_al2fb_meta_fb_likes]);
update_user_meta($user_ID, c_al2fb_meta_post_likers, $_POST[c_al2fb_meta_post_likers]);
update_user_meta($user_ID, c_al2fb_meta_post_like_button, $_POST[c_al2fb_meta_post_like_button]);
update_user_meta($user_ID, c_al2fb_meta_like_nohome, $_POST[c_al2fb_meta_like_nohome]);
update_user_meta($user_ID, c_al2fb_meta_like_noposts, $_POST[c_al2fb_meta_like_noposts]);
update_user_meta($user_ID, c_al2fb_meta_like_nopages, $_POST[c_al2fb_meta_like_nopages]);
update_user_meta($user_ID, c_al2fb_meta_like_noarchives, $_POST[c_al2fb_meta_like_noarchives]);
update_user_meta($user_ID, c_al2fb_meta_like_nocategories, $_POST[c_al2fb_meta_like_nocategories]);
update_user_meta($user_ID, c_al2fb_meta_like_layout, $_POST[c_al2fb_meta_like_layout]);
update_user_meta($user_ID, c_al2fb_meta_like_faces, $_POST[c_al2fb_meta_like_faces]);
update_user_meta($user_ID, c_al2fb_meta_like_width, $_POST[c_al2fb_meta_like_width]);
update_user_meta($user_ID, c_al2fb_meta_like_action, $_POST[c_al2fb_meta_like_action]);
update_user_meta($user_ID, c_al2fb_meta_like_font, $_POST[c_al2fb_meta_like_font]);
update_user_meta($user_ID, c_al2fb_meta_like_colorscheme, $_POST[c_al2fb_meta_like_colorscheme]);
update_user_meta($user_ID, c_al2fb_meta_like_link, $_POST[c_al2fb_meta_like_link]);
update_user_meta($user_ID, c_al2fb_meta_like_top, $_POST[c_al2fb_meta_like_top]);
update_user_meta($user_ID, c_al2fb_meta_post_send_button, $_POST[c_al2fb_meta_post_send_button]);
update_user_meta($user_ID, c_al2fb_meta_post_combine_buttons, $_POST[c_al2fb_meta_post_combine_buttons]);
update_user_meta($user_ID, c_al2fb_meta_like_share, $_POST[c_al2fb_meta_like_share]);
update_user_meta($user_ID, c_al2fb_meta_like_box_width, $_POST[c_al2fb_meta_like_box_width]);
update_user_meta($user_ID, c_al2fb_meta_like_box_height, $_POST[c_al2fb_meta_like_box_height]);
update_user_meta($user_ID, c_al2fb_meta_like_box_border, $_POST[c_al2fb_meta_like_box_border]);
update_user_meta($user_ID, c_al2fb_meta_like_box_noheader, $_POST[c_al2fb_meta_like_box_noheader]);
update_user_meta($user_ID, c_al2fb_meta_like_box_nostream, $_POST[c_al2fb_meta_like_box_nostream]);
update_user_meta($user_ID, c_al2fb_meta_subscribe_layout, $_POST[c_al2fb_meta_subscribe_layout]);
update_user_meta($user_ID, c_al2fb_meta_subscribe_width, $_POST[c_al2fb_meta_subscribe_width]);
update_user_meta($user_ID, c_al2fb_meta_comments_posts, $_POST[c_al2fb_meta_comments_posts]);
update_user_meta($user_ID, c_al2fb_meta_comments_width, $_POST[c_al2fb_meta_comments_width]);
update_user_meta($user_ID, c_al2fb_meta_comments_auto, $_POST[c_al2fb_meta_comments_auto]);
update_user_meta($user_ID, c_al2fb_meta_pile_size, $_POST[c_al2fb_meta_pile_size]);
update_user_meta($user_ID, c_al2fb_meta_pile_width, $_POST[c_al2fb_meta_pile_width]);
update_user_meta($user_ID, c_al2fb_meta_pile_rows, $_POST[c_al2fb_meta_pile_rows]);
update_user_meta($user_ID, c_al2fb_meta_reg_width, $_POST[c_al2fb_meta_reg_width]);
update_user_meta($user_ID, c_al2fb_meta_login_width, $_POST[c_al2fb_meta_login_width]);
update_user_meta($user_ID, c_al2fb_meta_reg_success, $_POST[c_al2fb_meta_reg_success]);
update_user_meta($user_ID, c_al2fb_meta_login_regurl, $_POST[c_al2fb_meta_login_regurl]);
update_user_meta($user_ID, c_al2fb_meta_login_redir, $_POST[c_al2fb_meta_login_redir]);
update_user_meta($user_ID, c_al2fb_meta_login_html, $_POST[c_al2fb_meta_login_html]);
update_user_meta($user_ID, c_al2fb_meta_act_width, $_POST[c_al2fb_meta_act_width]);
update_user_meta($user_ID, c_al2fb_meta_act_height, $_POST[c_al2fb_meta_act_height]);
update_user_meta($user_ID, c_al2fb_meta_act_header, $_POST[c_al2fb_meta_act_header]);
update_user_meta($user_ID, c_al2fb_meta_act_recommend, $_POST[c_al2fb_meta_act_recommend]);
update_user_meta($user_ID, c_al2fb_meta_open_graph, $_POST[c_al2fb_meta_open_graph]);
update_user_meta($user_ID, c_al2fb_meta_open_graph_type, $_POST[c_al2fb_meta_open_graph_type]);
update_user_meta($user_ID, c_al2fb_meta_open_graph_admins, $_POST[c_al2fb_meta_open_graph_admins]);
update_user_meta($user_ID, c_al2fb_meta_exclude_default, $_POST[c_al2fb_meta_exclude_default]);
update_user_meta($user_ID, c_al2fb_meta_exclude_default_video, $_POST[c_al2fb_meta_exclude_default_video]);
update_user_meta($user_ID, c_al2fb_meta_not_post_list, $_POST[c_al2fb_meta_not_post_list]);
update_user_meta($user_ID, c_al2fb_meta_fb_encoding, $_POST[c_al2fb_meta_fb_encoding]);
update_user_meta($user_ID, c_al2fb_meta_fb_locale, $_POST[c_al2fb_meta_fb_locale]);
update_user_meta($user_ID, c_al2fb_meta_param_name, $_POST[c_al2fb_meta_param_name]);
update_user_meta($user_ID, c_al2fb_meta_param_value, $_POST[c_al2fb_meta_param_value]);
update_user_meta($user_ID, c_al2fb_meta_donated, $_POST[c_al2fb_meta_donated]);
if (isset($_REQUEST['debug'])) {
if (empty($_POST[c_al2fb_meta_access_token]))
$_POST[c_al2fb_meta_access_token] = null;
$_POST[c_al2fb_meta_access_token] = trim($_POST[c_al2fb_meta_access_token]);
update_user_meta($user_ID, c_al2fb_meta_access_token, $_POST[c_al2fb_meta_access_token]);
update_user_meta($user_ID, c_al2fb_meta_token_time, date('c'));
}
// Update admin options
if (current_user_can('manage_options')) {
if (empty($_POST[c_al2fb_option_app_share]))
$_POST[c_al2fb_option_app_share] = null;
else
$_POST[c_al2fb_option_app_share] = $user_ID;
if (is_multisite())
update_site_option(c_al2fb_option_app_share, $_POST[c_al2fb_option_app_share]);
else
update_option(c_al2fb_option_app_share, $_POST[c_al2fb_option_app_share]);
update_option(c_al2fb_option_timeout, $_POST[c_al2fb_option_timeout]);
update_option(c_al2fb_option_nonotice, $_POST[c_al2fb_option_nonotice]);
update_option(c_al2fb_option_min_cap, $_POST[c_al2fb_option_min_cap]);
update_option(c_al2fb_option_no_post_submit, $_POST[c_al2fb_option_no_post_submit]);
update_option(c_al2fb_option_min_cap_comment, $_POST[c_al2fb_option_min_cap_comment]);
update_option(c_al2fb_option_msg_refresh, $_POST[c_al2fb_option_msg_refresh]);
update_option(c_al2fb_option_msg_maxage, $_POST[c_al2fb_option_msg_maxage]);
update_option(c_al2fb_option_cron_enabled, $_POST[c_al2fb_option_cron_enabled]);
update_option(c_al2fb_option_max_descr, $_POST[c_al2fb_option_max_descr]);
update_option(c_al2fb_option_max_text, $_POST[c_al2fb_option_max_text]);
update_option(c_al2fb_option_max_comment, $_POST[c_al2fb_option_max_comment]);
update_option(c_al2fb_option_exclude_custom, $_POST[c_al2fb_option_exclude_custom]);
update_option(c_al2fb_option_exclude_type, $_POST[c_al2fb_option_exclude_type]);
update_option(c_al2fb_option_exclude_cat, $_POST[c_al2fb_option_exclude_cat]);
update_option(c_al2fb_option_exclude_tag, $_POST[c_al2fb_option_exclude_tag]);
update_option(c_al2fb_option_exclude_author, $_POST[c_al2fb_option_exclude_author]);
update_option(c_al2fb_option_metabox_type, $_POST[c_al2fb_option_metabox_type]);
update_option(c_al2fb_option_noverifypeer, $_POST[c_al2fb_option_noverifypeer]);
update_option(c_al2fb_option_use_cacerts, $_POST[c_al2fb_option_use_cacerts]);
update_option(c_al2fb_option_shortcode_widget, $_POST[c_al2fb_option_shortcode_widget]);
update_option(c_al2fb_option_noshortcode, $_POST[c_al2fb_option_noshortcode]);
update_option(c_al2fb_option_nofilter, $_POST[c_al2fb_option_nofilter]);
update_option(c_al2fb_option_nofilter_comments, $_POST[c_al2fb_option_nofilter_comments]);
update_option(c_al2fb_option_use_ssp, $_POST[c_al2fb_option_use_ssp]);
update_option(c_al2fb_option_ssp_info, $_POST[c_al2fb_option_ssp_info]);
update_option(c_al2fb_option_filter_prio, $_POST[c_al2fb_option_filter_prio]);
update_option(c_al2fb_option_noasync, $_POST[c_al2fb_option_noasync]);
update_option(c_al2fb_option_noscript, $_POST[c_al2fb_option_noscript]);
update_option(c_al2fb_option_uselinks, $_POST[c_al2fb_option_uselinks]);
update_option(c_al2fb_option_notoken_refresh, $_POST[c_al2fb_option_notoken_refresh]);
update_option(c_al2fb_option_clean, $_POST[c_al2fb_option_clean]);
update_option(c_al2fb_option_css, $_POST[c_al2fb_option_css]);
update_option(c_al2fb_option_login_add_links, $_POST[c_al2fb_option_login_add_links]);
if (isset($_REQUEST['debug'])) {
update_option(c_al2fb_option_siteurl, $_POST[c_al2fb_option_siteurl]);
update_option(c_al2fb_option_nocurl, $_POST[c_al2fb_option_nocurl]);
update_option(c_al2fb_option_use_pp, $_POST[c_al2fb_option_use_pp]);
update_option(c_al2fb_option_debug, $_POST[c_al2fb_option_debug]);
}
}
// Show result
echo '<div id="message" class="updated fade al2fb_notice"><p>' . __('Settings updated', c_al2fb_text_domain) . '</p></div>';
// Clear all errors
if ($_POST[c_al2fb_meta_clear_errors]) {
$query = array(
'meta_key' => c_al2fb_meta_error,
'posts_per_page' => -1);
if (!get_site_option(c_al2fb_option_app_share))
$query['author'] = $user_ID;
$posts = new WP_Query($query);
while ($posts->have_posts()) {
$posts->next_post();
delete_post_meta($posts->post->ID, c_al2fb_meta_error);
}
}
}
// Get token
function Action_authorize() {
// Get current user
global $user_ID;
get_currentuserinfo();
// Server-side flow authorization
if (isset($_REQUEST['code'])) {
try {
// Get & store token
WPAL2Int::Get_fb_token($user_ID);
update_option(c_al2fb_log_auth_time, date('c'));
if (get_option(c_al2fb_option_version) <= 6)
update_option(c_al2fb_option_version, 7);
if (get_option(c_al2fb_option_version) == 10)
update_option(c_al2fb_option_version, 11);
delete_option(c_al2fb_last_error);
delete_option(c_al2fb_last_error_time);
echo '<div id="message" class="updated fade al2fb_notice"><p>' . __('Authorized, go posting!', c_al2fb_text_domain) . '</p></div>';
}
catch (Exception $e) {
delete_user_meta($user_ID, c_al2fb_meta_access_token);
update_option(c_al2fb_last_error, $e->getMessage());
update_option(c_al2fb_last_error_time, date('c'));
echo '<div id="message" class="error fade al2fb_error"><p>' . htmlspecialchars($e->getMessage(), ENT_QUOTES, get_bloginfo('charset')) . '</p></div>';
}
}
// Authorization error
else if (isset($_REQUEST['error'])) {
delete_user_meta($user_ID, c_al2fb_meta_access_token);
$faq = 'http://wordpress.org/extend/plugins/add-link-to-facebook/faq/';
$msg = stripslashes($_REQUEST['error_description']);
$msg .= ' error: ' . stripslashes($_REQUEST['error']);
$msg .= ' reason: ' . stripslashes($_REQUEST['error_reason']);
update_option(c_al2fb_last_error, $msg);
update_option(c_al2fb_last_error_time, date('c'));
$msg .= '<br /><br />Most errors are described in <a href="' . $faq . '" target="_blank">the FAQ</a>';
echo '<div id="message" class="error fade al2fb_error"><p>' . htmlspecialchars($msg, ENT_QUOTES, get_bloginfo('charset')) . '</p></div>';
}
}
// Send debug info
function Action_mail() {
// Security check
check_admin_referer(c_al2fb_nonce_action, c_al2fb_nonce_name);
require_once('add-link-to-facebook-debug.php');
if (empty($_POST[c_al2fb_mail_topic]) ||
$_POST[c_al2fb_mail_topic] == 'http://forum.faircode.eu/' ||
!(strpos($_POST[c_al2fb_mail_topic], 'http://forum.faircode.eu/') === 0))
echo '<div id="message" class="error fade al2fb_error"><p>' . __('Forum topic link is mandatory', c_al2fb_text_domain) . '</p></div>';
else {
// Build headers
$headers = 'From: ' . stripslashes($_POST[c_al2fb_mail_name]) . ' <' . stripslashes($_POST[c_al2fb_mail_email]) . '>' . "\n";
$headers .= 'Reply-To: ' . stripslashes($_POST[c_al2fb_mail_name]) . ' <' . stripslashes($_POST[c_al2fb_mail_email]) . '>' . "\n";
$headers .= 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=' . get_bloginfo('charset') . "\n";
// Build message
$message = '<html><head><title>Add Link to Facebook</title></head><body>';
$message .= '<p>' . nl2br(htmlspecialchars(stripslashes($_POST[c_al2fb_mail_msg]), ENT_QUOTES, get_bloginfo('charset'))) . '</p>';
$message .= '<a href="' . stripslashes($_POST[c_al2fb_mail_topic]) . '">' . stripslashes($_POST[c_al2fb_mail_topic]) . '</a>';
$message .= '<hr />';
$message .= al2fb_debug_info($this);
$message .= '<hr />';
$message .= '</body></html>';
if (wp_mail('dabelon@gmail.com', '[Add Link to Facebook] Debug information', $message, $headers)) {
echo '<div id="message" class="updated fade al2fb_notice"><p>' . __('Debug information sent', c_al2fb_text_domain) . '</p></div>';
if ($this->debug)
echo '<pre>' . nl2br(htmlspecialchars($headers, ENT_QUOTES, get_bloginfo('charset'))) . '</pre>';
}
else
echo '<div id="message" class="error fade al2fb_error"><p>' . __('Sending debug information failed', c_al2fb_text_domain) . '</p></div>';
}
}
// Display notices
function Check_config() {
// Get current user
global $user_ID;
get_currentuserinfo();
// Check if reporting errors
$uri = $_SERVER['REQUEST_URI'];
$url = 'admin.php?page=' . $this->main_plugin_name;
$nonotice = get_option(c_al2fb_option_nonotice);
if (is_multisite())
$nonotice = $nonotice || get_site_option(c_al2fb_option_app_share);
else
$nonotice = $nonotice || get_option(c_al2fb_option_app_share);
$donotice = ($nonotice ? strpos($uri, $url) !== false : true);
if ($donotice) {
// Check configuration
if (!get_user_meta($user_ID, c_al2fb_meta_client_id, true) ||
!get_user_meta($user_ID, c_al2fb_meta_app_secret, true)) {
$notice = __('needs configuration', c_al2fb_text_domain);
$anchor = 'configure';
}
else if (!self::Is_authorized($user_ID) || get_option(c_al2fb_option_version) == 10) {
$notice = __('needs authorization', c_al2fb_text_domain);
$anchor = 'authorize';
}
else {
$version = get_option(c_al2fb_option_version);
if ($version && $version <= 6) {
$notice = __('should be authorized again to show Facebook messages in the widget', c_al2fb_text_domain);
$anchor = 'authorize';
}
}
// Report configuration problems
if (!empty($notice)) {
echo '<div class="error fade al2fb_error"><p>';
_e('Add Link to Facebook', c_al2fb_text_domain);
echo ' <a href="' . $url . '#' . $anchor . '">' . $notice . '</a></p></div>';
}
}
// Check for post related errors
global $post;
$ispost = ($post && strpos($uri, 'post.php') !== false);
if (!get_option(c_al2fb_option_nonotice) || $donotice || $ispost) {
$query = array(
'author' => $user_ID,
'meta_key' => c_al2fb_meta_error,
'posts_per_page' => 5);
if ($ispost)
$query['p'] = $post->ID;
$posts = new WP_Query($query);
while ($posts->have_posts()) {
$posts->next_post();
$error = get_post_meta($posts->post->ID, c_al2fb_meta_error, true);
if (!empty($error)) {
echo '<div id="message" class="error fade al2fb_error"><p>';
echo __('Add Link to Facebook', c_al2fb_text_domain) . ' - ';
edit_post_link(get_the_title($posts->post->ID), null, null, $posts->post->ID);
echo ': ' . htmlspecialchars($error, ENT_QUOTES, get_bloginfo('charset'));
echo ' @ ' . get_post_meta($posts->post->ID, c_al2fb_meta_error_time, true);
echo '</p></div>';
}
}
}
// Check for error
if (isset($_REQUEST['al2fb_action']) && $_REQUEST['al2fb_action'] == 'error') {
$faq = 'http://wordpress.org/extend/plugins/add-link-to-facebook/faq/';
$msg = htmlspecialchars(stripslashes($_REQUEST['error']), ENT_QUOTES, get_bloginfo('charset'));
$msg .= '<br /><br />Most errors are described in <a href="' . $faq . '" target="_blank">the FAQ</a>';
echo '<div id="message" class="error fade al2fb_error"><p>' . $msg . '</p></div>';
}
// Check for multiple count
$x = WPAL2Int::Get_multiple_count();
if ($x && $x['blog_count'] > $x['count']) {
echo '<div id="message" class="error fade al2fb_error"><p>';
echo __('Maximum number of sites exceeded', c_al2fb_text_domain);
echo ' (' . $x['blog_count'] . '/' . $x['count'] . ')';
echo '</p></div>';
}
}
// Register options page
function Admin_menu() {
// Get current user
global $user_ID;
get_currentuserinfo();
if (function_exists('add_management_page'))
// add_management_page(
// __('Add Link to Facebook', c_al2fb_text_domain) . ' ' . __('Administration', c_al2fb_text_domain),
// __('Add Link to Facebook', c_al2fb_text_domain),
// get_option(c_al2fb_option_min_cap),
// $this->main_file,
// array(&$this, 'Administration'));
if( file_exists(plugin_dir_path( __FILE__ ).'/readygraph-extension.php')) {
global $menu_slug;
add_menu_page( __( 'Add Link to Facebook', c_al2fb_text_domain) . ' ' . __('Administration', c_al2fb_text_domain),
__('Add Link to Facebook', c_al2fb_text_domain), get_option(c_al2fb_option_min_cap), 'add-link-to-facebook-settings', array(&$this, 'readygraph_al2fb_menu_page'));
add_submenu_page('add-link-to-facebook-settings', 'Readygraph App', __( 'Readygraph App', c_al2fb_text_domain ), 'administrator', $menu_slug, array(&$this, 'readygraph_al2fb_menu_page'));
add_submenu_page('add-link-to-facebook-settings', __( 'Add Link to Facebook', c_al2fb_text_domain) . ' ' . __('Administration', c_al2fb_text_domain), __('Add Link to Facebook Configuration', c_al2fb_text_domain), get_option(c_al2fb_option_min_cap), $this->main_plugin_name, array(&$this, 'Administration'));
add_submenu_page('add-link-to-facebook-settings', 'Go Premium', __( 'Go Premium', c_al2fb_text_domain ), 'administrator', 'readygraph-go-premium', array(&$this, 'readygraph_al2fb_premium_page'));
}
else {
add_menu_page( __( 'Add Link to Facebook', c_al2fb_text_domain) . ' ' . __('Administration', c_al2fb_text_domain),
__('Add Link to Facebook', c_al2fb_text_domain), get_option(c_al2fb_option_min_cap), $this->main_plugin_name, array(&$this, 'Administration')) ;
}
}
function Plugin_action_links($links, $file) {
if ($file == plugin_basename($this->main_file)) {
if (current_user_can(get_option(c_al2fb_option_min_cap))) {
// Get current user
global $user_ID;
get_currentuserinfo();
// Check for shared app
if (is_multisite())
$shared_user_ID = get_site_option(c_al2fb_option_app_share);
else
$shared_user_ID = get_option(c_al2fb_option_app_share);
if (!$shared_user_ID || $shared_user_ID == $user_ID) {
// Add settings link
if (is_multisite()) {
global $blog_id;
$config_url = get_admin_url($blog_id, 'admin.php?page=' . $this->main_plugin_name, 'admin');
}
else
$config_url = admin_url('admin.php?page=' . $this->main_plugin_name);
$links[] = '<a href="' . $config_url . '">' . __('Settings', c_al2fb_text_domain) . '</a>';
}
}
}
return $links;
}
// Handle option page
function Administration() {
// Security check
if (!current_user_can(get_option(c_al2fb_option_min_cap)))
die('Unauthorized');
require_once('add-link-to-facebook-admin.php');
al2fb_render_admin($this);
global $updates_al2fb;
if (isset($updates_al2fb))
$updates_al2fb->checkForUpdates();
}
function readygraph_al2fb_premium_page(){
require_once('extension/readygraph/go-premium.php');
}
function readygraph_al2fb_menu_page(){
$current_page = isset($_GET['ac']) ? $_GET['ac'] : '';
switch($current_page)
{
case 'signup-popup':
include('extension/readygraph/signup-popup.php');
break;
case 'invite-screen':
include('extension/readygraph/invite-screen.php');
break;
case 'social-feed':
include('extension/readygraph/social-feed.php');
break;
case 'site-profile':
include('extension/readygraph/site-profile.php');
break;
case 'customize-emails':
include('extension/readygraph/customize-emails.php');
break;
case 'deactivate-readygraph':
include('extension/readygraph/deactivate-readygraph.php');
break;
case 'welcome-email':
include('extension/readygraph/welcome-email.php');
break;
case 'retention-email':
include('extension/readygraph/retention-email.php');
break;
case 'invitation-email':
include('extension/readygraph/invitation-email.php');
break;
case 'faq':
include('extension/readygraph/faq.php');
break;
case 'monetization-settings':
include('extension/readygraph/monetization.php');
break;
default:
include('extension/readygraph/admin.php');
break;
}
}
// Add checkboxes
function Post_submitbox_misc_actions() {
global $post;
// Check exclusion
if (get_option(c_al2fb_option_exclude_custom))
if ($post->post_type != 'post' && $post->post_type != 'page')
return;
$ex_custom_types = explode(',', get_option(c_al2fb_option_exclude_type));
if (in_array($post->post_type, $ex_custom_types))
return;
// Security
if (get_option(c_al2fb_option_no_post_submit) &&
!current_user_can(get_option(c_al2fb_option_min_cap)))
return;
// Get user/link
$user_ID = self::Get_user_ID($post);
$link_ids = get_post_meta($post->ID, c_al2fb_meta_link_id, false);
$charset = get_bloginfo('charset');
// Get exclude indication
$exclude = get_post_meta($post->ID, c_al2fb_meta_exclude, true);
if (!$link_ids && get_user_meta($user_ID, c_al2fb_meta_exclude_default, true))
$exclude = true;
$chk_exclude = ($exclude ? ' checked' : '');
$exclude_video = get_post_meta($post->ID, c_al2fb_meta_exclude_video, true);
if (!$link_ids && get_user_meta($user_ID, c_al2fb_meta_exclude_default_video, true))
$exclude_video = true;
$chk_exclude_video = ($exclude_video ? ' checked' : '');
// Get no like button indication
$chk_nolike = (get_post_meta($post->ID, c_al2fb_meta_nolike, true) ? ' checked' : '');
$chk_nointegrate = (get_post_meta($post->ID, c_al2fb_meta_nointegrate, true) ? ' checked' : '');
// Check if errors
$error = get_post_meta($post->ID, c_al2fb_meta_error, true);
?>
<div class="al2fb_post_submit">
<div class="misc-pub-section">
<input type="hidden" id="al2fb_form" name="al2fb_form" value="true">
<?php
wp_nonce_field(c_al2fb_nonce_action, c_al2fb_nonce_name);
if (get_option(c_al2fb_option_login_add_links))
if (self::Is_login_authorized($user_ID, false)) {
// Get personal page
try {
$me = WPAL2Int::Get_fb_me_cached($user_ID, true);
}
catch (Exception $e) {
$me = null;
}
// Get other pages
try {
$pages = WPAL2Int::Get_fb_pages_cached($user_ID);
}
catch (Exception $e) {
$pages = null;
}
// Get groups
try {
$groups = WPAL2Int::Get_fb_groups_cached($user_ID);
}
catch (Exception $e) {
$groups = null;
}
// Get previous selected page
$selected_page = get_user_meta($user_ID, c_al2fb_meta_facebook_page, true);
// Debug info
if ($this->debug) {
echo 'sel=' . $selected_page . '<br />';
echo 'me=' . print_r($me, true) . '<br />';
}
?>
<label for="al2fb_page"><?php _e('Add to page:', c_al2fb_text_domain); ?></label>
<select class="al2fb_select" id="al2fb_page" name="<?php echo c_al2fb_meta_facebook_page; ?>">
<?php
echo '<option value=""' . ($selected_page ? '' : ' selected') . '>' . __('None', c_al2fb_text_domain) . '</option>';
if ($me)
echo '<option value="' . $me->id . '"' . ($selected_page == $me->id ? ' selected' : '') . '>' . htmlspecialchars($me->name, ENT_QUOTES, $charset) . ' (' . __('Personal', c_al2fb_text_domain) . ')</option>';
if ($pages && $pages->data)
foreach ($pages->data as $page) {
echo '<option value="' . $page->id . '"';
if ($page->id == $selected_page)
echo ' selected';
if (empty($page->name))
$page->name = '?';
echo '>' . htmlspecialchars($page->name, ENT_QUOTES, $charset) . ' (' . htmlspecialchars($page->category, ENT_QUOTES, $charset) . ')</option>';
}
if ($groups && $groups->data)
foreach ($groups->data as $group) {
echo '<option value="' . $group->id . '"';
if ($group->id == $selected_page)
echo ' selected';
echo '>' . htmlspecialchars($group->name, ENT_QUOTES, $charset) . ' (' . __('Group', c_al2fb_text_domain) . ')</option>';
}
?>
</select>
<br />
<?php
}
else
echo '<strong>' . __('Not logged in with Facebook (anymore)', c_al2fb_text_domain) . '</strong><br />';
?>
<input id="al2fb_exclude" type="checkbox" name="<?php echo c_al2fb_meta_exclude; ?>"<?php echo $chk_exclude; ?> />
<label for="al2fb_exclude"><?php _e('Do not add link to Facebook', c_al2fb_text_domain); ?></label>
<br />
<input id="al2fb_exclude_video" type="checkbox" name="<?php echo c_al2fb_meta_exclude_video; ?>"<?php echo $chk_exclude_video; ?> />
<label for="al2fb_exclude_video"><?php _e('Do not add video to Facebook', c_al2fb_text_domain); ?></label>
<br />
<input id="al2fb_nolike" type="checkbox" name="<?php echo c_al2fb_meta_nolike; ?>"<?php echo $chk_nolike; ?> />
<label for="al2fb_nolike"><?php _e('Do not add like button', c_al2fb_text_domain); ?></label>
<br />
<input id="al2fb_nointegrate" type="checkbox" name="<?php echo c_al2fb_meta_nointegrate; ?>"<?php echo $chk_nointegrate; ?> />
<label for="al2fb_nointegrate"><?php _e('Do not integrate comments', c_al2fb_text_domain); ?></label>
<?php
if (!empty($link_ids)) {
?>
<br />
<input id="al2fb_update" type="checkbox" name="<?php echo c_al2fb_action_update; ?>"/>
<label for="al2fb_update"><?php _e('Update existing Facebook link', c_al2fb_text_domain); ?></label>
<br />
<span class="al2fb_explanation"><strong><?php _e('Comments and likes will be lost!', c_al2fb_text_domain); ?></strong></span>
<br />
<input id="al2fb_delete" type="checkbox" name="<?php echo c_al2fb_action_delete; ?>"/>
<label for="al2fb_delete"><?php _e('Delete existing Facebook link', c_al2fb_text_domain); ?></label>
<?php
foreach ($link_ids as $link_id) {
$page_id = WPAL2Int::Get_page_from_link_id($link_id);
try {
$info = WPAL2Int::Get_fb_info_cached($user_ID, empty($page_id) ? 'me' : $page_id);
}
catch (Exception $e) {
$info = false;
}
?>
<br />
<a href="<?php echo WPAL2Int::Get_fb_permalink($link_id); ?>" target="_blank"><?php _e('Link on Facebook', c_al2fb_text_domain); ?></a>
<?php
if ($info)
echo ' (<a href="' . $info->link . '" target="_blank">' . htmlspecialchars($info->name, ENT_QUOTES, $charset) . '</a>)';
}
?>
<br />
<span class="al2fb_explanation"><em><?php _e('Due to limitations of Facebook not all links might work', c_al2fb_text_domain); ?></em></span>
<?php
}
if (!empty($error)) {
?>
<br />
<input id="al2fb_clear" type="checkbox" name="<?php echo c_al2fb_action_clear; ?>"/>
<label for="al2fb_clear"><?php _e('Clear error messages', c_al2fb_text_domain); ?></label>
<?php
}
?>
</div>
</div>
<?php
}
// Add post Facebook column
function Manage_posts_columns($posts_columns) {
// Get current user
global $user_ID;
get_currentuserinfo();
if (current_user_can(get_option(c_al2fb_option_min_cap)) &&
!get_user_meta($user_ID, c_al2fb_meta_not_post_list, true))
$posts_columns['al2fb'] = __('Facebook', c_al2fb_text_domain);
return $posts_columns;
}
function Is_recent($post) {
// Maximum age for Facebook comments/likes
$maxage = intval(get_option(c_al2fb_option_msg_maxage));
if (!$maxage)
$maxage = 7;
// Link added time
$link_time = strtotime(get_post_meta($post->ID, c_al2fb_meta_link_time, true));
if ($link_time <= 0)
$link_time = strtotime($post->post_date_gmt);
$old = ($link_time + ($maxage * 24 * 60 * 60) < time());
return !$old;
}
// Populate post facebook column
function Manage_posts_custom_column($column_name, $post_ID) {
if ($column_name == 'al2fb') {
$charset = get_bloginfo('charset');
$post = get_post($post_ID);
$user_ID = self::Get_user_ID($post);
$link_ids = get_post_meta($post->ID, c_al2fb_meta_link_id, false);
if ($link_ids)
foreach ($link_ids as $link_id)
try {
$page_id = WPAL2Int::Get_page_from_link_id($link_id);
$link = WPAL2Int::Get_fb_permalink($link_id);
$info = WPAL2Int::Get_fb_info_cached($user_ID, $page_id);
echo '<a href="' . $link . '" target="_blank">' . htmlspecialchars($info->name, ENT_QUOTES, $charset) . '</a><br />';
}
catch (Exception $e) {
echo htmlspecialchars($e->getMessage(), ENT_QUOTES, $charset);
}
else
echo '<span>' . __('No', c_al2fb_text_domain) . '</span>';
$link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true);
if ($link_id && self::Is_recent($post)) {
// Show number of comments
if (get_user_meta($user_ID, c_al2fb_meta_fb_comments, true)) {
$count = 0;
$fb_comments = WPAL2Int::Get_comments_or_likes($post, false);
if ($fb_comments && $fb_comments->data)
$count = count($fb_comments->data);
echo '<span>' . $count . ' ' . __('comments', c_al2fb_text_domain) . '</span><br />';
}
// Show number of likes
if ($post->ping_status == 'open' &&
get_user_meta($user_ID, c_al2fb_meta_fb_likes, true)) {
$count = 0;
$fb_likes = WPAL2Int::Get_comments_or_likes($post, true);
if ($fb_likes && $fb_likes->data)
$count = count($fb_likes->data);
echo '<span>' . $count . ' ' . __('likes', c_al2fb_text_domain) . '</span><br />';
}
}
}
}
// Add post meta box
function Add_meta_boxes() {
$types = explode(',', get_option(c_al2fb_option_metabox_type));
$types[] = 'post';
$types[] = 'page';
foreach ($types as $type)
add_meta_box(
'al2fb_meta',
__('Add Link to Facebook', c_al2fb_text_domain),
array(&$this, 'Meta_box'),
$type);
}
// Display attached image selector
function Meta_box() {
global $post;
if (!empty($post)) {
$user_ID = self::Get_user_ID($post);
$texts = self::Get_texts($post);
// Security
wp_nonce_field(c_al2fb_nonce_action, c_al2fb_nonce_name);
if ($this->debug) {
echo '<strong>Type:</strong> ' . $post->post_type . '<br />';;
$texts = self::Get_texts($post);
echo '<strong>Original:</strong> ' . htmlspecialchars($post->post_content, ENT_QUOTES, get_bloginfo('charset')) . '<br />';
echo '<strong>Processed:</strong> ' . htmlspecialchars($texts['content'], ENT_QUOTES, get_bloginfo('charset')) . '<br />';
echo '<strong>Video:</strong> ' . htmlspecialchars(self::Get_link_video($post, $user_ID), ENT_QUOTES, get_bloginfo('charset')) . '<br />';
}
if (function_exists('wp_get_attachment_image_src')) {
// Get attached images
$images = get_children('post_type=attachment&post_mime_type=image&order=ASC&post_parent=' . $post->ID);
if (empty($images))
echo '<span>' . __('No images in the media library for this post', c_al2fb_text_domain) . '</span><br />';
else {
// Display image selector
$image_id = get_post_meta($post->ID, c_al2fb_meta_image_id, true);
// Header
echo '<h4>' . __('Select link image:', c_al2fb_text_domain) . '</h4>';
echo '<div class="al2fb_images">';
// None
echo '<div class="al2fb_image">';
echo '<input type="radio" name="al2fb_image_id" id="al2fb_image_0"';
if (empty($image_id))
echo ' checked';
echo ' value="0">';
echo '<br />';
echo '<label for="al2fb_image_0">';
echo __('None', c_al2fb_text_domain) . '</label>';
echo '</div>';
// Images
if ($images)
foreach ($images as $attachment_id => $attachment) {
// Get image size
$image_size = get_user_meta($user_ID, c_al2fb_meta_picture_size, true);
if (empty($image_size))
$image_size = 'medium';
$picture = wp_get_attachment_image_src($attachment_id, $image_size);
$thumbnail = wp_get_attachment_image_src($attachment_id, 'thumbnail');
echo '<div class="al2fb_image">';
echo '<input type="radio" name="al2fb_image_id" id="al2fb_image_' . $attachment_id . '"';
if ($attachment_id == $image_id)
echo ' checked';
echo ' value="' . $attachment_id . '">';
echo '<br />';
echo '<label for="al2fb_image_' . $attachment_id . '">';
echo '<img src="' . $thumbnail[0] . '" alt=""></label>';
echo '<br />';
echo '<span>' . $picture[1] . ' x ' . $picture[2] . '</span>';
echo '</div>';
}
echo '</div>';
}
}
else
echo 'wp_get_attachment_image_src does not exist';
// Debug texts
if ($this->debug)
echo '<pre>' . print_r($texts, true) . '</pre>';
// Custom excerpt
$excerpt = get_post_meta($post->ID, c_al2fb_meta_excerpt, true);
echo '<h4>' . __('Custom excerpt', c_al2fb_text_domain) . '</h4>';
echo '<textarea id="al2fb_excerpt" name="al2fb_excerpt" cols="40" rows="1" class="attachmentlinks">';
echo $excerpt . '</textarea>';
// Custom text
$text = get_post_meta($post->ID, c_al2fb_meta_text, true);
echo '<h4>' . __('Custom text', c_al2fb_text_domain) . '</h4>';
echo '<textarea id="al2fb_text" name="al2fb_text" cols="40" rows="1" class="attachmentlinks">';
echo $text . '</textarea>';
// URL parameters
$url_param_name = get_post_meta($post->ID, c_al2fb_meta_url_param_name, true);
$url_param_value = get_post_meta($post->ID, c_al2fb_meta_url_param_value, true);
echo '<h4>' . __('Extra URL parameter', c_al2fb_text_domain) . '</h4>';
echo __('For example for Google Anaylytics', c_al2fb_text_domain) . '<br>';
echo '<input type="text" id="al2fb_url_param_name" name="al2fb_url_param_name" value="' . $url_param_name . '" />';
echo ' = ';
echo '<input type="text" id="al2fb_url_param_value" name="al2fb_url_param_value" value="' . $url_param_value . '" />';
// Video link
$video = get_post_meta($post->ID, c_al2fb_meta_video, true);
echo '<h4>' . __('Video URL', c_al2fb_text_domain) . '</h4>';
echo '<input type="text" id="al2fb_video" name="al2fb_video" value="' . $video . '" />';
// Current link picture
echo '<h4>' . __('Link picture', c_al2fb_text_domain) . '</h4>';
$picture_info = self::Get_link_picture($post, $user_ID);
if (!empty($picture_info['picture']))
echo '<img src="' . $picture_info['picture'] . '" alt="Link picture">';
if ($this->debug)
echo '<br /><span style="font-size: smaller;">' . $picture_info['picture_type'] . ': ' . $picture_info['picture'] . '</span>';
// Error messages
if ($this->debug) {
$logs = get_post_meta($post->ID, c_al2fb_meta_log, false);
echo '<pre>log=' . print_r($logs, true) . '</pre>';
$logs = get_post_meta($post->ID, c_al2fb_meta_link_id, false);
echo '<pre>fbid=' . print_r($logs, true) . '</pre>';
$logs = get_post_meta($post->ID, c_al2fb_meta_fb_comment_id, false);
echo '<pre>fbcid=' . print_r($logs, true) . '</pre>';
}
}
}
// Save indications & selected attached image
function Save_post($post_id) {
if ($this->debug)
add_post_meta($post_id, c_al2fb_meta_log, date('c') . ' Save post');
// Security checks
$nonce = (isset($_POST[c_al2fb_nonce_name]) ? $_POST[c_al2fb_nonce_name] : null);
if (!wp_verify_nonce($nonce, c_al2fb_nonce_action))
return $post_id;
if (!current_user_can('edit_post', $post_id))
return $post_id;
// Skip auto save
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
return $post_id;
// Check exclusion
$post = get_post($post_id);
if (get_option(c_al2fb_option_exclude_custom))
if ($post->post_type != 'post' && $post->post_type != 'page')
return;
$ex_custom_types = explode(',', get_option(c_al2fb_option_exclude_type));
if (in_array($post->post_type, $ex_custom_types))
return $post_id;
// Persist selected page
$user_ID = self::Get_user_ID($post);
if (get_option(c_al2fb_option_login_add_links) &&
self::Is_login_authorized($user_ID, false))
update_user_meta($user_ID, c_al2fb_meta_facebook_page, $_POST[c_al2fb_meta_facebook_page]);
// Process exclude indication
if (isset($_POST[c_al2fb_meta_exclude]) && $_POST[c_al2fb_meta_exclude])
update_post_meta($post_id, c_al2fb_meta_exclude, true);
else
delete_post_meta($post_id, c_al2fb_meta_exclude);
if (isset($_POST[c_al2fb_meta_exclude_video]) && $_POST[c_al2fb_meta_exclude_video])
update_post_meta($post_id, c_al2fb_meta_exclude_video, true);
else
delete_post_meta($post_id, c_al2fb_meta_exclude_video);
// Process no like indication
if (isset($_POST[c_al2fb_meta_nolike]) && $_POST[c_al2fb_meta_nolike])
update_post_meta($post_id, c_al2fb_meta_nolike, true);
else
delete_post_meta($post_id, c_al2fb_meta_nolike);
// Process no integrate indication
if (isset($_POST[c_al2fb_meta_nointegrate]) && $_POST[c_al2fb_meta_nointegrate])
update_post_meta($post_id, c_al2fb_meta_nointegrate, true);
else
delete_post_meta($post_id, c_al2fb_meta_nointegrate);
// Clear errors
if (isset($_POST[c_al2fb_action_clear]) && $_POST[c_al2fb_action_clear]) {
delete_post_meta($post_id, c_al2fb_meta_error);
delete_post_meta($post_id, c_al2fb_meta_error_time);
}
// Persist data
if (empty($_POST['al2fb_image_id']))
delete_post_meta($post_id, c_al2fb_meta_image_id);
else
update_post_meta($post_id, c_al2fb_meta_image_id, $_POST['al2fb_image_id']);
if (isset($_POST['al2fb_excerpt']) && !empty($_POST['al2fb_excerpt']))
update_post_meta($post_id, c_al2fb_meta_excerpt, trim($_POST['al2fb_excerpt']));
else
delete_post_meta($post_id, c_al2fb_meta_excerpt);
if (isset($_POST['al2fb_text']) && !empty($_POST['al2fb_text']))
update_post_meta($post_id, c_al2fb_meta_text, trim($_POST['al2fb_text']));
else
delete_post_meta($post_id, c_al2fb_meta_text);
if (isset($_POST['al2fb_url_param_name']) && !empty($_POST['al2fb_url_param_name']))
update_post_meta($post_id, c_al2fb_meta_url_param_name, trim($_POST['al2fb_url_param_name']));
else
delete_post_meta($post_id, c_al2fb_meta_url_param_name);
if (isset($_POST['al2fb_url_param_value']) && !empty($_POST['al2fb_url_param_value']))
update_post_meta($post_id, c_al2fb_meta_url_param_value, trim($_POST['al2fb_url_param_value']));
else
delete_post_meta($post_id, c_al2fb_meta_url_param_value);
if (isset($_POST['al2fb_video']) && !empty($_POST['al2fb_video']))
update_post_meta($post_id, c_al2fb_meta_video, trim($_POST['al2fb_video']));
else
delete_post_meta($post_id, c_al2fb_meta_video);
}
// Remote publish & custom action
function Remote_publish($post_ID) {
if ($this->debug)
add_post_meta($post_ID, c_al2fb_meta_log, date('c') . ' Remote publish');
$post = get_post($post_ID);
// Only if published
if ($post->post_status == 'publish')
self::Publish_post($post);
}
// Workaround
function Future_to_publish($post_ID) {
if ($this->debug)
add_post_meta($post_ID, c_al2fb_meta_log, date('c') . ' Future to publish');
$post = get_post($post_ID);
// Delegate
self::Transition_post_status('publish', 'future', $post);
}
function Before_delete_post($post_ID) {
if ($this->debug)
add_post_meta($post_ID, c_al2fb_meta_log, date('c') . ' Before delete post');
$post = get_post($post_ID);
$user_ID = self::Get_user_ID($post);
$link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true);
if (!empty($link_id) &&
(self::Is_authorized($user_ID) || self::Is_login_authorized($user_ID, false)))
WPAL2Int::Delete_fb_link($post);
}
// Handle post status change
function Transition_post_status($new_status, $old_status, $post) {
if ($this->debug)
add_post_meta($post->ID, c_al2fb_meta_log, date('c') . ' ' . $old_status . '->' . $new_status);
self::Save_post($post->ID);
$user_ID = self::Get_user_ID($post);
$update = (isset($_POST[c_al2fb_action_update]) && $_POST[c_al2fb_action_update]);
$delete = (isset($_POST[c_al2fb_action_delete]) && $_POST[c_al2fb_action_delete]);
$link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true);
// Security check
if (self::user_can($user_ID, get_option(c_al2fb_option_min_cap))) {
// Add, update or delete link
if ($update || $delete || $new_status == 'trash') {
if (!empty($link_id) &&
(self::Is_authorized($user_ID) || self::Is_login_authorized($user_ID, false))) {
WPAL2Int::Delete_fb_link($post);
$link_id = null;
}
}
if (!$delete) {
// Check post status
if (empty($link_id) &&
(self::Is_authorized($user_ID) || self::Is_login_authorized($user_ID, true)) &&
$new_status == 'publish' &&
($new_status != $old_status || $update ||
get_post_meta($post->ID, c_al2fb_meta_error, true)))
self::Publish_post($post);
}
}
}
// Handle publish post / XML-RPC publish post
function Publish_post($post) {
if ($this->debug)
add_post_meta($post->ID, c_al2fb_meta_log, date('c') . ' Publish');
$user_ID = self::Get_user_ID($post);
// Checks
if (self::user_can($user_ID, get_option(c_al2fb_option_min_cap)) &&
(self::Is_authorized($user_ID) || self::Is_login_authorized($user_ID, true))) {
// Apply defaults if no form
if (!isset($_POST['al2fb_form'])) {
if (!get_post_meta($post->ID, c_al2fb_meta_exclude, true))
update_post_meta($post->ID, c_al2fb_meta_exclude, get_user_meta($user_ID, c_al2fb_meta_exclude_default, true));
if (!get_post_meta($post->ID, c_al2fb_meta_exclude_video, true))
update_post_meta($post->ID, c_al2fb_meta_exclude_video, get_user_meta($user_ID, c_al2fb_meta_exclude_default_video, true));
}
// Check if not added/excluded
if (!get_post_meta($post->ID, c_al2fb_meta_link_id, true) &&
!get_post_meta($post->ID, c_al2fb_meta_exclude, true)) {
$add_new_page = get_user_meta($user_ID, c_al2fb_meta_add_new_page, true);
// Check if public post
if (empty($post->post_password) &&
($post->post_type != 'page' || $add_new_page) &&
!self::Is_excluded($post))
if ($post->post_type == 'reply')
WPAL2Int::Add_fb_link_reply($post);
else
WPAL2Int::Add_fb_link($post);
}
}
}
function Is_excluded($post) {
return
self::Is_excluded_post_type($post) ||
self::Is_excluded_tag($post) ||
self::Is_excluded_category($post) ||
self::Is_excluded_author($post);
}
function Is_excluded_post_type($post) {
// All excluded?
if (get_option(c_al2fb_option_exclude_custom))
if ($post->post_type != 'post' && $post->post_type != 'page')
return true;
$ex_custom_types = explode(',', get_option(c_al2fb_option_exclude_type));
// Compatibility
$ex_custom_types[] = 'nav_menu_item';
$ex_custom_types[] = 'recipe';
$ex_custom_types[] = 'recipeingredient';
$ex_custom_types[] = 'recipestep';
$ex_custom_types[] = 'wpcf7_contact_form';
$ex_custom_types[] = 'feedback';
$ex_custom_types[] = 'spam';
$ex_custom_types[] = 'twitter';
$ex_custom_types[] = 'mscr_ban';
// bbPress
$ex_custom_types[] = 'forum';
//$ex_custom_types[] = 'topic';
//$ex_custom_types[] = 'reply';
$ex_custom_types[] = 'tweet';
$ex_custom_types = apply_filters('al2fb_excluded_post_types', $ex_custom_types);
return in_array($post->post_type, $ex_custom_types);
}
function Is_excluded_tag($post) {
// Exclude tags
$exclude_tag = false;
$tags = get_the_tags($post->ID);
$excluding_tags = explode(',', get_option(c_al2fb_option_exclude_tag));
$excluding_tags = apply_filters('al2fb_excluded_tags', $excluding_tags);
if ($tags)
foreach ($tags as $tag)
if (in_array($tag->name, $excluding_tags))
$exclude_tag = true;
return $exclude_tag;
}
function Is_excluded_category($post) {
$exclude_category = false;
$categories = get_the_category($post->ID);
$excluding_categories = explode(',', get_option(c_al2fb_option_exclude_cat));
$excluding_categories = apply_filters('al2fb_excluded_categories', $excluding_categories);
if ($categories)
foreach ($categories as $category)
if (in_array($category->cat_ID, $excluding_categories))
$exclude_category = true;
return $exclude_category;
}
function Is_excluded_author($post) {
if (empty($post->post_author))
return false;
$excluding_authors = explode(',', get_option(c_al2fb_option_exclude_author));
$excluding_authors = apply_filters('al2fb_excluded_authors', $excluding_authors);
$author = get_the_author_meta('user_login', $post->post_author);
return in_array($author, $excluding_authors);
}
// Build texts for link/ogp
function Get_texts($post) {
$user_ID = self::Get_user_ID($post);
// Filter excerpt
$excerpt = get_post_meta($post->ID, c_al2fb_meta_excerpt, true);
if (empty($excerpt)) {
$excerpt = strip_tags($post->post_excerpt);
if (!get_option(c_al2fb_option_nofilter))
$excerpt = apply_filters('the_excerpt', $excerpt);
else
$excerpt = strip_shortcodes($excerpt);
if (empty($excerpt) && get_user_meta($user_ID, c_al2fb_meta_auto_excerpt, true)) {
$excerpt = strip_tags(strip_shortcodes($post->post_content));
$words = explode(' ', $excerpt, 55 + 1);
if (count($words) > 55) {
array_pop($words);
array_push($words, '…');
$excerpt = implode(' ', $words);
}
}
}
$excerpt = apply_filters('al2fb_excerpt', $excerpt, $post);
// Filter post text
$content = get_post_meta($post->ID, c_al2fb_meta_text, true);
$content = strip_tags($content);
if (empty($content)) {
$content = strip_tags($post->post_content);
if (!get_option(c_al2fb_option_nofilter))
$content = apply_filters('the_content', $content);
else
$content = strip_shortcodes($content);
}
$content = apply_filters('al2fb_content', $content, $post);
// Get body
$description = '';
if (get_user_meta($user_ID, c_al2fb_meta_msg, true))
$description = $content;
else
$description = ($excerpt ? $excerpt : $content);
// Trailer
$trailer = get_user_meta($user_ID, c_al2fb_meta_trailer, true);
$trailer = strip_tags($trailer);
if ($trailer) {
// Get maximum FB text size
$maxlen = get_option(c_al2fb_option_max_descr);
if (!$maxlen)
$maxlen = 256;
// Limit body size
$description = self::Limit_text_size($description, $trailer, $maxlen);
}
// Build result
$texts = array(
'excerpt' => $excerpt,
'content' => $content,
'description' => $description
);
return $texts;
}
// Limit text size
function Limit_text_size($text, $trailer, $maxlen) {
if (self::_strlen($text) > $maxlen) {
// Filter HTML
$trailer = preg_replace('/<[^>]*>/', '', $trailer);
// Add maximum number of sentences
$text = trim($text);
$lines = explode('.', $text);
if ($lines) {
$count = 0;
$text = '';
foreach ($lines as $sentence) {
$count++;
$line = $sentence;
if ($count < count($lines) || self::_substr($text, -1, 1) == '.')
$line .= '.';
if (self::_strlen($text) + self::_strlen($line) + self::_strlen($trailer) < $maxlen)
$text .= $line;
else
break;
}
if (empty($text) && count($lines) > 0)
$text = self::_substr($lines[0], 0, $maxlen - self::_strlen($trailer));
// Append trailer
$text .= $trailer;
}
}
return $text;
}
// Get link picture
function Get_link_picture($post, $user_ID) {
// Get image size
$image_size = get_user_meta($user_ID, c_al2fb_meta_picture_size, true);
if (empty($image_size))
$image_size = 'medium';
// Get selected image
$image_id = get_post_meta($post->ID, c_al2fb_meta_image_id, true);
if (!empty($image_id) && function_exists('wp_get_attachment_image_src')) {
$picture_type = 'meta';
$picture = wp_get_attachment_image_src($image_id, $image_size);
if ($picture)
$picture = $picture[0]; // url
}
if (empty($picture)) {
// Default picture
$picture = get_user_meta($user_ID, c_al2fb_meta_picture_default, true);
if (empty($picture))
$picture = WPAL2Int::Redirect_uri() . '?al2fb_image=1';
// Check picture type
$picture_type = get_user_meta($user_ID, c_al2fb_meta_picture_type, true);
if ($picture_type == 'media') {
$images = array_values(get_children('post_type=attachment&post_mime_type=image&order=ASC&post_parent=' . $post->ID));
if (!empty($images) && function_exists('wp_get_attachment_image_src')) {
$picture = wp_get_attachment_image_src($images[0]->ID, $image_size);
if ($picture && $picture[0])
$picture = $picture[0];
}
}
else if ($picture_type == 'featured') {
if (current_theme_supports('post-thumbnails') &&
function_exists('get_post_thumbnail_id') &&
function_exists('wp_get_attachment_image_src')) {
$picture_id = get_post_thumbnail_id($post->ID);
if ($picture_id) {
if (stripos($picture_id, 'ngg-') !== false && class_exists('nggdb') && class_exists('nggMeta')) {
$nggMeta = new nggMeta(str_replace('ngg-', '', $picture_id));
if (!empty($nggMeta->image) && !empty($nggMeta->image->imageURL))
$picture = $nggMeta->image->imageURL;
}
else {
$picture = wp_get_attachment_image_src($picture_id, $image_size);
if ($picture && $picture[0])
$picture = $picture[0];
}
}
}
}
else if ($picture_type == 'facebook')
$picture = '';
else if ($picture_type == 'post' || empty($picture_type)) {
$picture_post = self::Get_first_image($post);
if (strpos($picture_post, 'data:') === 0 && strpos($picture_post, 'base64') > 0)
$picture = WPAL2Int::Redirect_uri() . '?al2fb_data_uri=' . $post->ID;
else if ($picture_post)
$picture = $picture_post;
}
else if ($picture_type == 'avatar') {
$userdata = get_userdata($post->post_author);
$avatar = get_avatar($userdata->user_email);
if (!empty($avatar))
if (preg_match('/< *img[^>]*src *= *["\']([^"\']*)["\']/i', $avatar, $matches))
$picture = $matches[1];
}
else if ($picture_type == 'userphoto') {
$userdata = get_userdata($post->post_author);
if ($userdata->userphoto_approvalstatus == USERPHOTO_APPROVED) {
$image_file = $userdata->userphoto_image_file;
$upload_dir = wp_upload_dir();
$picture = trailingslashit($upload_dir['baseurl']) . 'userphoto/' . $image_file;
}
}
else if ($picture_type == 'custom') {
$custom = get_user_meta($user_ID, c_al2fb_meta_picture, true);
if ($custom)
$picture = $custom;
}
}
$picture = apply_filters('al2fb_picture', $picture, $post);
return array(
'picture' => $picture,
'picture_type' => $picture_type
);
}
function Get_first_image($post) {
$content = $post->post_content;
if (!get_option(c_al2fb_option_nofilter))
$content = apply_filters('the_content', $content);
if (preg_match('/< *img[^>]*src *= *["\']([^"\']*)["\']/i', $content, $matches))
return $matches[1];
return false;
}
// Get link video
function Get_link_video($post, $user_ID) {
if (get_post_meta($post->ID, c_al2fb_meta_exclude_video, true))
return;
$video = get_post_meta($post->ID, c_al2fb_meta_video, true);
if (empty($video)) {
// http://wordpress.org/extend/plugins/vipers-video-quicktags/
global $VipersVideoQuicktags;
if (isset($VipersVideoQuicktags)) {
do_shortcode($post->post_content);
if (!empty($VipersVideoQuicktags->swfobjects)) {
$video = reset($VipersVideoQuicktags->swfobjects);
if (!empty($video) && !empty($video['url']))
$video = $video['url'];
}
}
}
$video = apply_filters('al2fb_video', $video, $post);
return $video;
}
function Filter_excerpt($excerpt, $post) {
return self::Filter_standard($excerpt, $post);
}
function Filter_content($content, $post) {
return self::Filter_standard($content, $post);
}
function Filter_comment($message, $comment, $post) {
return self::Filter_standard($message, $post);
}
// Filter messages
function Filter_feed($fb_messages) {
if ($fb_messages && $fb_messages->data)
for ($i = 0; $i < count($fb_messages->data); $i++)
if ($fb_messages->data[$i]->type != 'status')
unset($fb_messages->data[$i]);
return $fb_messages;
}
function Filter_standard($text, $post) {
$user_ID = self::Get_user_ID($post);
// Execute shortcodes
if (get_option(c_al2fb_option_noshortcode))
$text = strip_shortcodes($text);
else
$text = do_shortcode($text);
// http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
// Remove scripts
$text = preg_replace('/<script.+?<\/script>/ims', '', $text);
// Remove styles
$text = preg_replace('/<style.+?<\/style>/ims', '', $text);
// Replace hyperlinks
if (get_user_meta($user_ID, c_al2fb_meta_hyperlink, true))
$text = preg_replace('/< *a[^>]*href *= *["\']([^"\']*)["\'][^<]*/i', '$1<a>', $text);
// Remove image captions
$text = preg_replace('/<p[^>]*class="wp-caption-text"[^>]*>[^<]*<\/p>/i', '', $text);
// Get plain texts
$text = preg_replace('/<[^>]*>/', '', $text);
// Decode HTML entities
$text = html_entity_decode($text, ENT_QUOTES, get_bloginfo('charset'));
// Prevent starting with with space
$text = trim($text);
// Truncate text
if (!empty($text)) {
$maxtext = get_option(c_al2fb_option_max_text);
if (!$maxtext)
$maxtext = 10000;
$text = self::_substr($text, 0, $maxtext);
}
return $text;
}
function Filter_video($video, $post) {
$components = parse_url($video);
if (isset($components['host'])) {
// Normalize YouTube URL
if ($components['host'] == 'www.youtube.com') {
// http://www.youtube.com/watch?v=RVUxgqH-y4s -> http://www.youtube.com/v/RVUxgqH-y4s
parse_str($components['query']);
if (isset($v))
return $components['scheme'] . '://' . $components['host'] . '/v/' . $v;
}
// Normalize Vimeo URL
if ($components['host'] == 'vimeo.com') {
// http://vimeo.com/240975 -> http://www.vimeo.com/moogaloop.swf?server=www.vimeo.com&clip_id=240975
return $components['scheme'] . '://www.' . $components['host'] . '/moogaloop.swf?server=www.vimeo.com&clip_id=' . substr($components['path'], 1);
}
}
return $video;
}
// New comment
function Comment_post($comment_ID) {
$comment = get_comment($comment_ID);
if ($comment->comment_approved == '1' &&
$comment->comment_agent != 'AL2FB')
WPAL2Int::Add_fb_link_comment($comment);
}
// Approved comment
function Comment_approved($comment) {
if ($comment->comment_agent != 'AL2FB')
WPAL2Int::Add_fb_link_comment($comment);
}
// Disapproved comment
function Comment_unapproved($comment) {
if ($comment->comment_agent != 'AL2FB')
WPAL2Int::Delete_fb_link_comment($comment);
}
function Comment_trash($comment_ID) {
$comment = get_comment($comment_ID);
self::Comment_unapproved($comment);
}
function Comment_untrash($comment_ID) {
$comment = get_comment($comment_ID);
self::Comment_approved($comment);
}
function Comment_spam($comment_ID) {
self::Comment_trash($comment_ID);
}
function Comment_unspam($comment_ID) {
self::Comment_untrash($comment_ID);
}
// Permanently delete comment
function Delete_comment($comment_ID) {
// Get data
$comment = get_comment($comment_ID);
$fb_comment_id = get_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id, true);
// Save Facebook ID to prevent import again
if (!empty($fb_comment_id))
if ($comment->comment_agent == 'AL2FB')
add_post_meta($comment->comment_post_ID, c_al2fb_meta_fb_comment_id, $fb_comment_id, false);
}
function Is_authorized($user_ID) {
return get_user_meta($user_ID, c_al2fb_meta_access_token, true);
}
function Is_login_authorized($user_ID, $page_selected) {
if ($page_selected &&
!get_user_meta($user_ID, c_al2fb_meta_facebook_page, true))
return false;
return WPAL2Int::Get_login_access_token($user_ID);
}
// HTML header
function WP_head() {
if (is_single() || is_page()) {
global $post;
$user_ID = self::Get_user_ID($post);
if (get_user_meta($user_ID, c_al2fb_meta_open_graph, true)) {
$charset = get_bloginfo('charset');
$title = html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset'));
$post_title = html_entity_decode(get_the_title($post->ID), ENT_QUOTES, get_bloginfo('charset'));
// Get link picture
$link_picture = get_post_meta($post->ID, c_al2fb_meta_link_picture, true);
if (empty($link_picture)) {
$picture_info = self::Get_link_picture($post, $user_ID);
$picture = $picture_info['picture'];
}
else
$picture = substr($link_picture, strpos($link_picture, '=') + 1);
if (empty($picture))
$picture = WPAL2Int::Redirect_uri() . '?al2fb_image=1';
// Video
$video = self::Get_link_video($post, $user_ID);
// Get type
$ogp_type = get_user_meta($user_ID, c_al2fb_meta_open_graph_type, true);
if (empty($ogp_type))
$ogp_type = 'article';
// Generate meta tags
echo '<!-- Start AL2FB OGP -->' . PHP_EOL;
echo '<meta property="og:title" content="' . htmlspecialchars($post_title, ENT_COMPAT, $charset) . '" />' . PHP_EOL;
echo '<meta property="og:type" content="' . $ogp_type . '" />' . PHP_EOL;
echo '<meta property="og:image" content="' . $picture . '" />' . PHP_EOL;
echo '<meta property="og:url" content="' . get_permalink($post->ID) . '" />' . PHP_EOL;
echo '<meta property="og:site_name" content="' . htmlspecialchars($title, ENT_COMPAT, $charset) . '" />' . PHP_EOL;
if ($video)
echo '<meta property="og:video" content="' . $video . '" />' . PHP_EOL;
$texts = self::Get_texts($post);
$maxlen = get_option(c_al2fb_option_max_descr);
$description = self::_substr($texts['description'], 0, $maxlen ? $maxlen : 256);
echo '<meta property="og:description" content="' . htmlspecialchars($description, ENT_COMPAT, $charset) . '" />' . PHP_EOL;
$appid = get_user_meta($user_ID, c_al2fb_meta_client_id, true);
if (!empty($appid))
echo '<meta property="fb:app_id" content="' . $appid . '" />' . PHP_EOL;
$admins = get_user_meta($user_ID, c_al2fb_meta_open_graph_admins, true);
if (!empty($admins))
echo '<meta property="fb:admins" content="' . $admins . '" />' . PHP_EOL;
// Facebook i18n
echo '<meta property="og:locale" content="' . WPAL2Int::Get_locale($user_ID) . '" />' . PHP_EOL;
echo '<!-- End AL2FB OGP -->' . PHP_EOL;
}
}
else if (is_home())
{
// Check if any user has enabled the OGP
global $wpdb;
$opg = 0;
$user_ID = null;
$rows = $wpdb->get_results("SELECT user_id, meta_value FROM " . $wpdb->usermeta . " WHERE meta_key='" . c_al2fb_meta_open_graph . "'");
foreach ($rows as $row)
if ($row->meta_value) {
$opg++;
$user_ID = $row->user_id;
}
if ($opg) {
$charset = get_bloginfo('charset');
$title = html_entity_decode(get_bloginfo('title'), ENT_QUOTES, $charset);
$description = html_entity_decode(get_bloginfo('description'), ENT_QUOTES, $charset);
// Get link picture
$picture_type = get_user_meta($user_ID, c_al2fb_meta_picture_type, true);
if ($picture_type == 'custom')
$picture = get_user_meta($user_ID, c_al2fb_meta_picture, true);
if (empty($picture)) {
$picture = get_user_meta($user_ID, c_al2fb_meta_picture_default, true);
if (empty($picture))
$picture = WPAL2Int::Redirect_uri() . '?al2fb_image=1';
}
// Generate meta tags
echo '<!-- Start AL2FB OGP -->' . PHP_EOL;
echo '<meta property="og:title" content="' . htmlspecialchars($title, ENT_COMPAT, $charset) . '" />' . PHP_EOL;
echo '<meta property="og:type" content="blog" />' . PHP_EOL;
echo '<meta property="og:image" content="' . $picture . '" />' . PHP_EOL;
echo '<meta property="og:url" content="' . get_home_url(null, '/') . '" />' . PHP_EOL;
echo '<meta property="og:site_name" content="' . htmlspecialchars($title, ENT_COMPAT, $charset) . '" />' . PHP_EOL;
echo '<meta property="og:description" content="' . htmlspecialchars(empty($description) ? $title : $description, ENT_COMPAT, $charset) . '" />' . PHP_EOL;
// Single user blog
if ($opg == 1) {
$appid = get_user_meta($user_ID, c_al2fb_meta_client_id, true);
if (!empty($appid))
echo '<meta property="fb:app_id" content="' . $appid . '" />' . PHP_EOL;
$admins = get_user_meta($user_ID, c_al2fb_meta_open_graph_admins, true);
if (!empty($admins))
echo '<meta property="fb:admins" content="' . $admins . '" />' . PHP_EOL;
// Facebook i18n
echo '<meta property="og:locale" content="' . WPAL2Int::Get_locale($user_ID) . '" />' . PHP_EOL;
}
else
echo '<meta property="og:locale" content="' . WPAL2Int::Get_locale(-1) . '" />' . PHP_EOL;
echo '<!-- End AL2FB OGP -->' . PHP_EOL;
}
}
}
// Additional styles
function WP_print_styles() {
$css = get_option(c_al2fb_option_css);
if (!empty($css)) {
echo '<!-- AL2FB CSS -->' . PHP_EOL;
echo '<style type="text/css" media="screen">' . PHP_EOL;
echo $css;
echo '</style>' . PHP_EOL;
}
}
// Post content
function The_content($content = '') {
global $post;
// Do not process feed / excerpt
if (is_feed() || WPAL2Int::in_excerpt())
return $content;
$user_ID = self::Get_user_ID($post);
if (!self::Is_excluded($post) &&
!(get_user_meta($user_ID, c_al2fb_meta_like_nohome, true) && is_home()) &&
!(get_user_meta($user_ID, c_al2fb_meta_like_noposts, true) && is_single()) &&
!(get_user_meta($user_ID, c_al2fb_meta_like_nopages, true) && is_page()) &&
!(get_user_meta($user_ID, c_al2fb_meta_like_noarchives, true) && is_archive()) &&
!(get_user_meta($user_ID, c_al2fb_meta_like_nocategories, true) && is_category())) {
// Show likers
if (get_user_meta($user_ID, c_al2fb_meta_post_likers, true)) {
$likers = self::Get_likers($post);
if (!empty($likers))
if (get_user_meta($user_ID, c_al2fb_meta_like_top, true))
$content = $likers . $content;
else
$content .= $likers;
}
// Show permalink
if (get_user_meta($user_ID, c_al2fb_meta_show_permalink, true)) {
$anchor = WPAL2Int::Get_fb_anchor($post);
if (get_user_meta($user_ID, c_al2fb_meta_like_top, true))
$content = $anchor . $content;
else
$content .= $anchor;
}
// Show like button
if (!get_post_meta($post->ID, c_al2fb_meta_nolike, true)) {
if (get_user_meta($user_ID, c_al2fb_meta_post_like_button, true))
$button = WPAL2Int::Get_like_button($post, false);
if (get_user_meta($user_ID, c_al2fb_meta_post_send_button, true) &&
!get_user_meta($user_ID, c_al2fb_meta_post_combine_buttons, true))
$button .= WPAL2Int::Get_send_button($post);
}
if (!empty($button))
if (get_user_meta($user_ID, c_al2fb_meta_like_top, true))
$content = $button . $content;
else
$content .= $button;
// Show comments plugin
if (get_user_meta($user_ID, c_al2fb_meta_comments_auto, true))
$content .= WPAL2Int::Get_comments_plugin($post);
}
return $content;
}
// Shortcode likers names
function Shortcode_likers($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return self::Get_likers($post);
else
return '';
}
// Shortcode amchor
function Shortcode_anchor($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_fb_anchor($post);
else
return '';
}
// Shortcode like count
function Shortcode_like_count($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return self::Get_like_count($post);
else
return '';
}
// Shortcode like button
function Shortcode_like_button($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_like_button($post, false);
else
return '';
}
// Shortcode like box
function Shortcode_like_box($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_like_button($post, true);
else
return '';
}
// Shortcode send button
function Shortcode_send_button($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_send_button($post);
else
return '';
}
// Shortcode send button
function Shortcode_subscribe_button($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_subscribe_button($post);
else
return '';
}
// Shortcode comments plugin
function Shortcode_comments_plugin($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_comments_plugin($post);
else
return '';
}
// Shortcode face pile
function Shortcode_face_pile($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_face_pile($post);
else
return '';
}
// Shortcode profile link
function Shortcode_profile_link($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_profile_link($post);
else
return '';
}
// Shortcode Facebook registration
function Shortcode_registration($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_registration($post);
else
return '';
}
// Shortcode Facebook login
function Shortcode_login($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_login($post);
else
return '';
}
// Shortcode Facebook activity feed
function Shortcode_activity_feed($atts) {
extract(shortcode_atts(array('post_id' => null), $atts));
if (empty($post_id))
global $post;
else
$post = get_post($post_id);
if (isset($post))
return WPAL2Int::Get_activity_feed($post);
else
return '';
}
// Get HTML for likers
function Get_likers($post) {
$likers = '';
$user_ID = self::Get_user_ID($post);
if ($user_ID && !self::Is_excluded($post) && !WPAL2Int::social_in_excerpt($user_ID)) {
$charset = get_bloginfo('charset');
$fb_likes = WPAL2Int::Get_comments_or_likes($post, true);
if ($fb_likes && $fb_likes->data) {
foreach ($fb_likes->data as $fb_like) {
if (!empty($likers))
$likers .= ', ';
if (get_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, true) == 'author') {
$link = WPAL2Int::Get_fb_profilelink($fb_like->id);
$likers .= '<a href="' . $link . '" rel="nofollow">' . htmlspecialchars($fb_like->name, ENT_QUOTES, $charset) . '</a>';
}
else
$likers .= htmlspecialchars($fb_like->name, ENT_QUOTES, $charset);
}
if (!empty($likers)) {
$likers .= ' <span class="al2fb_liked">' . _n('liked this post', 'liked this post', count($fb_likes->data), c_al2fb_text_domain) . '</span>';
$likers = '<div class="al2fb_likers">' . $likers . '</div>';
}
}
}
return $likers;
}
// Get HTML for like count
function Get_like_count($post) {
$user_ID = self::Get_user_ID($post);
if ($user_ID && !self::Is_excluded($post) && !WPAL2Int::social_in_excerpt($user_ID)) {
$link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true);
$fb_likes = WPAL2Int::Get_comments_or_likes($post, true);
if ($fb_likes && $fb_likes->data && count($fb_likes->data) > 0)
return '<div class="al2fb_like_count"><a href="' . WPAL2Int::Get_fb_permalink($link_id) . '" rel="nofollow">' . count($fb_likes->data) . ' ' . _n('liked this post', 'liked this post', count($fb_likes->data), c_al2fb_text_domain) . '</a></div>';
}
return '';
}
// Profile personal options
function Personal_options($user) {
$fid = get_user_meta($user->ID, c_al2fb_meta_facebook_id, true);
echo '<th scope="row">' . __('Facebook ID', c_al2fb_text_domain) . '</th><td>';
echo '<input type="text" name="' . c_al2fb_meta_facebook_id . '" id="' . c_al2fb_meta_facebook_id . '" value="' . $fid . '">';
if ($fid)
echo '<br><a href="' . WPAL2Int::Get_fb_profilelink($fid) . '" target="_blank">' . $fid . '</a>';
if ($this->debug)
echo '<br><span>token=' . get_user_meta($user->ID, c_al2fb_meta_facebook_token, true) . '</span>';
echo '</td></tr>';
}
// Handle personal options change
function Personal_options_update($user_id) {
update_user_meta($user_id, c_al2fb_meta_facebook_id, trim($_REQUEST[c_al2fb_meta_facebook_id]));
}
// Modify comment list
function Comments_array($comments, $post_ID) {
$post = get_post($post_ID);
$user_ID = self::Get_user_ID($post);
update_option(c_al2fb_log_importing, true);
// Integration?
if ($user_ID && !self::Is_excluded($post) &&
$post->post_type != 'reply' &&
!get_post_meta($post->ID, c_al2fb_meta_nointegrate, true) &&
$post->comment_status == 'open') {
// Get time zone offset
$tz_off = get_option('gmt_offset');
if (empty($tz_off))
$tz_off = 0;
$tz_off = apply_filters('al2fb_gmt_offset', $tz_off);
$tz_off = $tz_off * 3600;
// Get Facebook comments
if (self::Is_recent($post) && get_user_meta($user_ID, c_al2fb_meta_fb_comments, true)) {
$fb_comments = WPAL2Int::Get_comments_or_likes($post, false);
if ($fb_comments && $fb_comments->data) {
// Get WordPress comments
$stored_comments = get_comments('post_id=' . $post->ID);
$stored_comments = array_merge($stored_comments,
get_comments('status=spam&post_id=' . $post->ID));
$stored_comments = array_merge($stored_comments,
get_comments('status=trash&post_id=' . $post->ID));
$stored_comments = array_merge($stored_comments,
get_comments('status=hold&post_id=' . $post->ID));
$deleted_fb_comment_ids = get_post_meta($post->ID, c_al2fb_meta_fb_comment_id, false);
foreach ($fb_comments->data as $fb_comment)
if (!empty($fb_comment->id)) {
$search_comment_id = end(explode('_', $fb_comment->id));
// Check if stored comment
$stored = false;
if ($stored_comments)
foreach ($stored_comments as $comment) {
$fb_comment_id = get_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id, true);
if ($search_comment_id == end(explode('_', $fb_comment_id))) {
$stored = true;
break;
}
}
// Check if deleted comment
if (!$stored && $deleted_fb_comment_ids)
foreach ($deleted_fb_comment_ids as $deleted_fb_comment_id)
if ($search_comment_id == end(explode('_', $deleted_fb_comment_id))) {
$stored = true;
break;
}
// Create new comment
if (!$stored) {
$name = $fb_comment->from->name . ' ' . __('on Facebook', c_al2fb_text_domain);
if ($post->post_type == 'topic') {
// bbPress
$reply_id = bbp_insert_reply(array(
'post_parent' => $post_ID,
'post_content' => $fb_comment->message,
'post_status' => 'draft'
),
array(
'forum_id' => bbp_get_topic_forum_id($post_ID),
'topic_id' => $post_ID,
'anonymous_name' => $name
));
// Add data
add_post_meta($reply_id, c_al2fb_meta_link_id, $fb_comment->id);
add_post_meta($post_ID, c_al2fb_meta_fb_comment_id, $fb_comment->id);
// Publish
$reply = array();
$reply['ID'] = $reply_id;
$reply['post_status'] = 'publish';
wp_update_post($reply);
}
else {
$comment_ID = $fb_comment->id;
$commentdata = array(
'comment_post_ID' => $post_ID,
'comment_author' => $name,
'comment_author_email' => $fb_comment->from->id . '@facebook.com',
'comment_author_url' => WPAL2Int::Get_fb_profilelink($fb_comment->from->id),
'comment_author_IP' => '',
'comment_date' => date('Y-m-d H:i:s', strtotime($fb_comment->created_time) + $tz_off),
'comment_date_gmt' => date('Y-m-d H:i:s', strtotime($fb_comment->created_time)),
'comment_content' => $fb_comment->message,
'comment_karma' => 0,
'comment_approved' => 1,
'comment_agent' => 'AL2FB',
'comment_type' => '', // pingback|trackback
'comment_parent' => 0,
'user_id' => 0
);
// Assign parent comment id
if (!empty($fb_comment->parent->id)) {
$parent_args = array(
'post_id' => $post_ID,
'meta_query' => array(array(
'key' => c_al2fb_meta_fb_comment_id,
'value' => $fb_comment->parent->id
))
);
$parent_comments_query = new WP_Comment_Query;
$parent_comments = $parent_comments_query->query($parent_args);
if (isset($parent_comments) && count($parent_comments) == 1)
$commentdata['comment_parent'] = $parent_comments[0]->comment_ID;
}
$commentdata = apply_filters('al2fb_preprocess_comment', $commentdata, $post);
// Copy Facebook comment to WordPress database
if (get_user_meta($user_ID, c_al2fb_meta_fb_comments_copy, true)) {
// Apply filters
if (get_option(c_al2fb_option_nofilter_comments))
$commentdata['comment_approved'] = '1';
else {
$commentdata = apply_filters('preprocess_comment', $commentdata);
$commentdata = wp_filter_comment($commentdata);
$commentdata['comment_approved'] = wp_allow_comment($commentdata);
}
// Insert comment in database
$comment_ID = wp_insert_comment($commentdata);
add_comment_meta($comment_ID, c_al2fb_meta_fb_comment_id, $fb_comment->id);
do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
// Notify
if ('spam' !== $commentdata['comment_approved']) {
if ('0' == $commentdata['comment_approved'])
wp_notify_moderator($comment_ID);
if (get_option('comments_notify') && $commentdata['comment_approved'])
wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
}
}
else
$commentdata['comment_approved'] = '1';
// Add comment to array
if ($commentdata['comment_approved'] == 1) {
$new = new stdClass();
$new->comment_ID = $comment_ID;
$new->comment_post_ID = $commentdata['comment_post_ID'];
$new->comment_author = $commentdata['comment_author'];
$new->comment_author_email = $commentdata['comment_author_email'];
$new->comment_author_url = $commentdata['comment_author_url'];
$new->comment_author_ip = $commentdata['comment_author_IP'];
$new->comment_date = $commentdata['comment_date'];
$new->comment_date_gmt = $commentdata['comment_date_gmt'];
$new->comment_content = stripslashes($commentdata['comment_content']);
$new->comment_karma = $commentdata['comment_karma'];
$new->comment_approved = $commentdata['comment_approved'];
$new->comment_agent = $commentdata['comment_agent'];
$new->comment_type = $commentdata['comment_type'];
$new->comment_parent = $commentdata['comment_parent'];
$new->user_id = $commentdata['user_id'];
$comments[] = $new;
}
}
}
}
else
if ($this->debug)
add_post_meta($post->ID, c_al2fb_meta_log, date('c') . ' Missing FB comment id: ' . print_r($fb_comment, true));
}
}
// Get likes
if (self::Is_recent($post) &&
$post->ping_status == 'open' &&
get_user_meta($user_ID, c_al2fb_meta_fb_likes, true)) {
$fb_likes = WPAL2Int::Get_comments_or_likes($post, true);
if ($fb_likes && $fb_likes->data)
foreach ($fb_likes->data as $fb_like) {
// Create new virtual comment
$link = WPAL2Int::Get_fb_profilelink($fb_like->id);
$new = new stdClass();
$new->comment_ID = $fb_like->id;
$new->comment_post_ID = $post_ID;
$new->comment_author = $fb_like->name . ' ' . __('on Facebook', c_al2fb_text_domain);
$new->comment_author_email = '';
$new->comment_author_url = $link;
$new->comment_author_ip = '';
$new->comment_date_gmt = date('Y-m-d H:i:s', time());
$new->comment_date = $new->comment_date_gmt;
$new->comment_content = '<em>' . __('Liked this post', c_al2fb_text_domain) . '</em>';
$new->comment_karma = 0;
$new->comment_approved = 1;
$new->comment_agent = 'AL2FB';
$new->comment_type = 'pingback';
$new->comment_parent = 0;
$new->user_id = 0;
$comments[] = $new;
}
}
// Sort comments by time
if (!empty($fb_comments) || !empty($fb_likes)) {
usort($comments, array(&$this, 'Comment_compare'));
if (get_option('comment_order') == 'desc')
array_reverse($comments);
}
}
// Comment link type
$link_id = get_post_meta($post->ID, c_al2fb_meta_link_id, true);
$comments_nolink = get_user_meta($user_ID, c_al2fb_meta_fb_comments_nolink, true);
if (empty($comments_nolink))
$comments_nolink = 'author';
else if ($comments_nolink == 'on' || empty($link_id))
$comments_nolink = 'none';
if ($comments_nolink == 'none' || $comments_nolink == 'link') {
$link = WPAL2Int::Get_fb_permalink($link_id);
if ($comments)
foreach ($comments as $comment)
if ($comment->comment_agent == 'AL2FB')
if ($comments_nolink == 'none')
$comment->comment_author_url = '';
else if ($comments_nolink == 'link')
$comment->comment_author_url = $link;
}
// Permission to view?
$min_cap = get_option(c_al2fb_option_min_cap_comment);
if ($min_cap && !current_user_can($min_cap))
if ($comments)
for ($i = 0; $i < count($comments); $i++)
if ($comments[$i]->comment_agent == 'AL2FB')
unset($comments[$i]);
return $comments;
}
// Pre process comment: limit text size
function Preprocess_comment($commentdata, $post) {
$user_ID = self::Get_user_ID($post);
$trailer = get_user_meta($user_ID, c_al2fb_meta_fb_comments_trailer, true);
if ($trailer) {
// Get maximum comment text size
$maxlen = get_option(c_al2fb_option_max_comment);
if (!$maxlen)
$maxlen = 256;
// Limit comment size
$commentdata['comment_content'] = self::Limit_text_size($commentdata['comment_content'], $trailer, $maxlen);
}
return $commentdata;
}
// Sort helper
function Comment_compare($a, $b) {
return strcmp($a->comment_date_gmt, $b->comment_date_gmt);
}
// Get comment count with FB comments/likes
function Get_comments_number($count, $post_ID) {
$post = get_post($post_ID);
$user_ID = self::Get_user_ID($post);
// Permission to view?
$min_cap = get_option(c_al2fb_option_min_cap_comment);
if ($min_cap && !current_user_can($min_cap)) {
$stored_comments = get_comments('post_id=' . $post->ID);
if ($stored_comments)
foreach ($stored_comments as $comment)
if ($comment->comment_agent == 'AL2FB')
$count--;
}
// Integration turned off?
if (!$user_ID || self::Is_excluded($post) ||
get_post_meta($post->ID, c_al2fb_meta_nointegrate, true) ||
$post->comment_status != 'open')
return $count;
if (self::Is_recent($post)) {
// Comment count
if (get_user_meta($user_ID, c_al2fb_meta_fb_comments, true)) {
$fb_comments = WPAL2Int::Get_comments_or_likes($post, false);
if ($fb_comments && $fb_comments->data) {
$stored_comments = get_comments('post_id=' . $post->ID);
$stored_comments = array_merge($stored_comments,
get_comments('status=spam&post_id=' . $post->ID));
$stored_comments = array_merge($stored_comments,
get_comments('status=trash&post_id=' . $post->ID));
$stored_comments = array_merge($stored_comments,
get_comments('status=hold&post_id=' . $post->ID));
$deleted_fb_comment_ids = get_post_meta($post->ID, c_al2fb_meta_fb_comment_id, false);
foreach ($fb_comments->data as $fb_comment) {
$search_comment_id = end(explode('_', $fb_comment->id));
// Check if stored comment
$stored = false;
if ($stored_comments)
foreach ($stored_comments as $comment) {
$fb_comment_id = get_comment_meta($comment->comment_ID, c_al2fb_meta_fb_comment_id, true);
if ($search_comment_id == end(explode('_', $fb_comment_id))) {
$stored = true;
break;
}
}
// Check if deleted comment
if (!$stored && $deleted_fb_comment_ids)
foreach ($deleted_fb_comment_ids as $deleted_fb_comment_id)
if ($search_comment_id == end(explode('_', $deleted_fb_comment_id))) {
$stored = true;
break;
}
// Only count if not in database or deleted
if (!$stored)
$count++;
}
}
}
// Like count
if (self::Is_recent($post) &&
$post->ping_status == 'open' &&
get_user_meta($user_ID, c_al2fb_meta_fb_likes, true)) {
$fb_likes = WPAL2Int::Get_comments_or_likes($post, true);
if ($fb_likes && $fb_likes->data)
$count += count($fb_likes->data);
}
}
return $count;
}
// Annotate FB comments/likes
function Comment_class($classes) {
global $comment;
if (!empty($comment) && $comment->comment_agent == 'AL2FB')
$classes[] = 'facebook-comment';
return $classes;
}
// Get FB picture as avatar
function Get_avatar($avatar, $id_or_email, $size, $default) {
$fb_picture_url = null;
if (is_object($id_or_email)) {
$comment = $id_or_email;
if ($comment->comment_agent == 'AL2FB' &&
($comment->comment_type == '' || $comment->comment_type == 'comment')) {
// Get picture url
$id = explode('id/', str_replace('id=','id/',$comment->comment_author_url));
if (count($id) == 2) {
$fb_picture_url = WPAL2Int::Get_fb_picture_url_cached($id[1], 'normal');
}
}
}
else if (stripos($id_or_email,'@facebook.com') !== false) {
$id_or_email = strtolower($id_or_email);
// Get picture url
$id = explode('@facebook.com', $id_or_email);
if (count($id) == 2)
$fb_picture_url = WPAL2Int::Get_fb_picture_url_cached($id[0], 'normal');
}
// Build avatar image
if ($fb_picture_url) {
$avatar = '<img alt="' . esc_attr($comment->comment_author) . '"';
$avatar .= ' src="' . $fb_picture_url . '"';
$avatar .= ' class="avatar avatar-' . $size . ' photo al2fb"';
$avatar .= ' height="' . $size . '"';
$avatar .= ' width="' . $size . '"';
$avatar .= ' />';
}
return $avatar;
}
static function Get_user_ID($post) {
if (is_multisite())
$shared_user_ID = get_site_option(c_al2fb_option_app_share);
else
$shared_user_ID = get_option(c_al2fb_option_app_share);
if ($shared_user_ID)
return $shared_user_ID;
return $post->post_author;
}
function user_can($user, $capability) {
if (!is_object($user))
$user = new WP_User($user);
if (!$user || !$user->ID)
return false;
$args = array_slice(func_get_args(), 2 );
$args = array_merge(array($capability), $args);
return call_user_func_array(array(&$user, 'has_cap'), $args);
}
// Add cron schedule
function Cron_schedules($schedules) {
if (get_option(c_al2fb_option_cron_enabled)) {
$duration = WPAL2Int::Get_duration(false);
$schedules['al2fb_schedule'] = array(
'interval' => $duration,
'display' => __('Add Link to Facebook', c_al2fb_text_domain));
}
return $schedules;
}
function Cron_filter($where = '') {
$maxage = intval(get_option(c_al2fb_option_msg_maxage));
if (!$maxage)
$maxage = 7;
return $where . " AND post_date > '" . date('Y-m-d', strtotime('-' . $maxage . ' days')) . "'";
}
function Cron() {
$posts = 0;
$comments = 0;
$likes = 0;
// Query recent posts
add_filter('posts_where', array(&$this, 'Cron_filter'));
$query = new WP_Query('post_type=any&meta_key=' . c_al2fb_meta_link_id);
remove_filter('posts_where', array(&$this, 'Cron_filter'));
while ($query->have_posts()) {
$posts++;
$query->the_post();
$post = $query->post;
// Integration?
if (!get_post_meta($post->ID, c_al2fb_meta_nointegrate, true) &&
$post->comment_status == 'open') {
$user_ID = self::Get_user_ID($post);
// Get Facebook comments
if (get_user_meta($user_ID, c_al2fb_meta_fb_comments, true)) {
$fb_comments = WPAL2Int::Get_comments_or_likes($post, false, false);
if ($fb_comments && $fb_comments->data)
$comments += count($fb_comments->data);
}
// Get likes
if ($post->ping_status == 'open' &&
get_user_meta($user_ID, c_al2fb_meta_fb_likes, true)) {
$fb_likes = WPAL2Int::Get_comments_or_likes($post, true, false);
if ($fb_likes && $fb_likes->data)
$likes += count($fb_likes->data);
}
}
}
// Debug info
update_option(c_al2fb_option_cron_time, date('c'));
update_option(c_al2fb_option_cron_posts, $posts);
update_option(c_al2fb_option_cron_comments, $comments);
update_option(c_al2fb_option_cron_likes, $likes);
}
function Update($pluginInfo, $result) {
if (isset($pluginInfo->disable))
update_option(c_al2fb_option_multiple_disable, $pluginInfo->disable);
else
delete_option(c_al2fb_option_multiple_disable);
return $pluginInfo;
}
// String helpers
function _strlen($str) {
if (function_exists('mb_strlen'))
return mb_strlen($str);
else
return strlen($str);
}
function _substr($str, $start, $length) {
if (function_exists('mb_substr'))
return mb_substr($str, $start, $length);
else
return substr($str, $start, $length);
}
// Check environment
static function Check_prerequisites() {
// Check WordPress version
global $wp_version;
if (version_compare($wp_version, '3.0') < 0)
die('Add Link to Facebook requires at least WordPress 3.0');
// Check basic prerequisities
self::Check_function('add_action');
self::Check_function('add_filter');
self::Check_function('wp_register_style');
self::Check_function('wp_enqueue_style');
self::Check_function('file_get_contents');
self::Check_function('json_decode');
self::Check_function('md5');
}
static function Check_function($name) {
if (!function_exists($name))
die('Required WordPress function "' . $name . '" does not exist');
}
// Change file extension
function Change_extension($filename, $new_extension) {
return preg_replace('/\..+$/', $new_extension, $filename);
}
}
}
?>
|
DencoDance/wpdndz
|
wp-content/plugins/add-link-to-facebook/add-link-to-facebook-class.php
|
PHP
|
gpl-2.0
| 109,204
|
#!/bin/sh
#
# Makefile for MIPS-XXL v 2.0. Based on the Makefile for FF v1.0.
#
####### FLAGS
TYPE =
ADDONS = ## -DFREEMEM -- Disabled for competition version.
#-DVERIFY_FLUSH
CC = gcc
CFLAGS = -Wall -ansi $(TYPE) $(ADDONS) -O3 -funroll-loops #-DTESTING_EX # -g -pg
LIBS = -lm
MIPSFLAGS = -DTESTING_EX #-DFASTER_HEURISTIC_IN_EXTERNAL
####### Files
PDDL_PARSER_SRC = scan-fct_pddl.tab.c \
scan-ops_pddl.tab.c \
scan-xml.tab.c\
scan-probname.tab.c \
lex.fct_pddl.c \
lex.ops_pddl.c \
lex.xml.c
PDDL_PARSER_OBJ = scan-fct_pddl.tab.o \
scan-ops_pddl.tab.o \
scan-xml.tab.o
SOURCES = main.c \
memory.c \
output.c \
parse.c \
grounded.c \
expressions.c \
inst_pre.c \
inst_easy.c \
inst_hard.c \
inst_final.c \
relax.c \
file.c \
bucket.c \
plan_reconstruction.c \
duplicates_removal.c \
external_prio_queue.c \
external.c \
search.c
EXTERNAL_SOURCES = file.c \
bucket.c \
plan_reconstruction.c \
duplicates_removal.c \
external_prio_queue.c \
external.c
OBJECTS = $(SOURCES:.c=.o)
HEADERS = $(SOURCES:.c=.h)
EXTERNAL_HEADERS = $(EXTERNAL_SOURCES:.c=.h)
####### Implicit rules
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:; $(CC) -c $(CFLAGS) $(MIPSFLAGS) $<
####### Build rules
ff: $(OBJECTS) $(PDDL_PARSER_OBJ)
$(CC) -o mips-xxl $(OBJECTS) $(PDDL_PARSER_OBJ) $(CFLAGS) $(MIPSFLAGS) $(LIBS)
# pddl syntax
scan-xml.tab.c: scan-xml.y lex.xml.c
bison -pxml -bscan-xml scan-xml.y
scan-fct_pddl.tab.c: scan-fct_pddl.y lex.fct_pddl.c
bison -pfct_pddl -bscan-fct_pddl scan-fct_pddl.y
scan-ops_pddl.tab.c: scan-ops_pddl.y lex.ops_pddl.c
bison -pops_pddl -bscan-ops_pddl scan-ops_pddl.y
lex.fct_pddl.c: lex-fct_pddl.l
flex -Pfct_pddl lex-fct_pddl.l
lex.ops_pddl.c: lex-ops_pddl.l
flex -Pops_pddl lex-ops_pddl.l
lex.xml.c: lex-xml.l
flex -Pxml lex-xml.l
# misc
clean:
rm -f $(OBJECTS) $(PDDL_PARSER_OBJ)
exclean:
rm bucket.o duplicates_removal.o file.o external.o plan_reconstruction.o
backup:
rm mips-xxlv3.tgz
tar -czf mips-xxlv3.tgz $(EXTERNAL_SOURCES) $(EXTERNAL_HEADERS)
veryclean: clean
rm -f ff H* J* K* L* O* graph.* *.symbex gmon.out \
$(PDDL_PARSER_SRC) \
lex.fct_pddl.c lex.ops_pddl.c lex.xml.c lex.probname.c \
*.output
depend:
makedepend -- $(SOURCES) $(PDDL_PARSER_SRC)
lint:
lclint -booltype Bool $(SOURCES) 2> output.lint
# DO NOT DELETE
|
PlanTool/plantool
|
code/Uncertainty/MIPS/MIPS-XXL-IPC6/Makefile
|
Makefile
|
gpl-2.0
| 2,339
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.