diff --git a/COPYING b/COPYING
index 94a9ed024..d159169d1 100644
--- a/COPYING
+++ b/COPYING
@@ -1,622 +1,281 @@
GNU GENERAL PUBLIC LICENSE
- Version 3, 29 June 2007
+ Version 2, June 1991
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
this License.
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
- 13. Use with the GNU Affero General Public License.
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
- 14. Revised Versions of this License.
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
+ NO WARRANTY
- 15. Disclaimer of Warranty.
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
@@ -628,15 +287,15 @@ free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
+convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
- This program is free software: you can redistribute it and/or modify
+ 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
+ the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -644,31 +303,37 @@ the "copyright" line and a pointer to where the full notice is found.
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 .
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
- If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
- Copyright (C)
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License. Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
- .
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
- The GNU General Public License does not permit incorporating your program
-into proprietary programs. If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library. If this is what you want to do, use the GNU Lesser General
-Public License instead of this License. But first, please read
-.
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/configure.ac b/configure.ac
index f8c467db0..507019067 100644
--- a/configure.ac
+++ b/configure.ac
@@ -162,6 +162,12 @@ AC_ARG_ENABLE(pip,
[AC_DEFINE(ENABLE_PIP,1,[enable picture in picture support])])
+AM_CONDITIONAL(ENABLE_TEST_MENU,test "$enable_testmenu" = "yes")
+if test "$enable_testmenu" = "yes"; then
+ AC_DEFINE(ENABLE_TEST_MENU,1,[include test menu in neutrino main menu - not recommended for general users!])
+fi
+
+
if test "$BOXTYPE" = "coolstream"; then
if test -e ${srcdir}/lib/libcoolstream/nevis_ir.h; then
AC_DEFINE(HAVE_COOLSTREAM_NEVIS_IR_H,1,[Define to 1 if you have the header file.])
@@ -218,6 +224,7 @@ lib/libcoolstream/Makefile
lib/libtuxtxt/Makefile
lib/libdvbsub/Makefile
lib/libupnpclient/Makefile
+lib/libiw/Makefile
src/lcddisplay/Makefile
src/nhttpd/Makefile
src/nhttpd/web/Makefile
diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale
index c5ca174f6..d210619d7 100644
--- a/data/locale/deutsch.locale
+++ b/data/locale/deutsch.locale
@@ -511,6 +511,7 @@ flashupdate.namemode2_default +.img
flashupdate.namemode2_hostname_time ++.img
flashupdate.new_found Updates verfügbar!
flashupdate.new_notfound Keine Updates verfügbar!
+flashupdate.noversion Bei Updates werden Versionsüberprüfungen derzeit nur über Web-Updates unterstützt.\nWollen Sie das ausgewählte Image wirklich installieren?
flashupdate.programmingflash programmiere Flash
flashupdate.proxypassword Passwort
flashupdate.proxypassword_hint1 Geben sie das Proxy-Passwort ein
@@ -532,7 +533,6 @@ flashupdate.reallyflashmtd Wollen Sie den Flashvorgang wirklich durchführen?\n\
flashupdate.savesuccess Das Image wurde erfolgreich unter dem\nDateinamen %s gespeichert.
flashupdate.selectimage Verfügbare Images/Files
flashupdate.settings Update-Einstellungen
-flashupdate.squashfs.noversion Bei Updates werden Versionsüberprüfungen derzeit nur über Web-Updates unterstützt.\nWollen Sie das ausgewählte Image wirklich installieren?
flashupdate.titlereadflash Flash auslesen
flashupdate.titlewriteflash Flash schreiben
flashupdate.update_with_settings_del_skipped Ordner [%s] kann nicht gelöscht werden. Eintrag wird übersprungen.
@@ -722,6 +722,7 @@ ledcontroler.on.all LED1 & LED2 an
ledcontroler.on.led1 LED1 an
ledcontroler.on.led2 LED2 an
mainmenu.audioplayer Audioplayer
+mainmenu.channels Kanalliste
mainmenu.clearsectionsd Lösche EPG Cache
mainmenu.games Spiele
mainmenu.head Hauptmenü
@@ -738,7 +739,9 @@ mainmenu.scripts Skripte
mainmenu.service Service
mainmenu.settings Einstellungen
mainmenu.shutdown Ausschalten
+mainmenu.shutdown_menu Ausschalt Optionen
mainmenu.sleeptimer SleepTimer
+mainmenu.standby Standby
mainmenu.tvmode TV-Modus
mainmenu.tvradio_switch TV-Radio Umschaltung
mainsettings.audio Audio
@@ -796,6 +799,7 @@ menu.hint_channellist_extended Bei aktivierter Funktion wird vor dem Sendernamen
menu.hint_channellist_fonts Ändern Sie die Schriftgrößen in der Kanalliste
menu.hint_channellist_foot Definiert, welche Informationen im unteren Sendungsfenster angezeigt werden sollen
menu.hint_channellist_setup Wählen Sie die Anzeigeoptionen für die Kanalliste
+menu.hint_channels Kanalliste öffnen
menu.hint_ci Conditional-Access-Menü zum Einrichten Ihres CI-Moduls oder der eingebetteten Conax-Karte
menu.hint_colors Konfigurieren Sie die Menü-Farben
menu.hint_content_back Ändern Sie die Hintergrundfarbe für den Fensterinhalt
@@ -973,6 +977,7 @@ menu.hint_net_setupnow Weisen Sie die aktuellen Einstellungen zu oder übernehme
menu.hint_net_setuponstartup Startet das Netzwerk automatisch beim Starten der Box
menu.hint_net_show Zeigen Ihnen die aktuellen Netzwerkeinstellungen
menu.hint_net_ssid Geben Sie die SSID des WLAN ein, mit dem Sie eine Verbindung herstellen möchten
+menu.hint_net_ssid_scan Nach verfügbaren WLAN-Netzwerken suchen
menu.hint_net_telnet Aktiviert Telnet auf Ihrer Box
menu.hint_net_test Testet die Netzwerkverbindung:\nPing auf Gateway, Name-Server und externe IP-Adressen
menu.hint_net_ushare Freigabe verbundener Datenträger über UPnP
@@ -985,6 +990,7 @@ menu.hint_osd_language Wählen Sie ihre Menü-Sprache
menu.hint_osd_preset Wählen Sie zwischen Röhren-TV (CRT) oder Flachbildschirm (LCD)
menu.hint_parentallock_changepin Geben Sie den 4-stelligen PIN-Code ein, der dann ggf. abgefragt wird
menu.hint_parentallock_lockage Legen Sie fest, bei welcher Altersklasse die Abfrage der PIN erfolgt
+menu.hint_parentallock_menu Menüs mit PIN Code sichern
menu.hint_parentallock_prompt Legen Sie fest, wann die Eingabe einer PIN erfolgen soll
menu.hint_personalize Personalisieren Sie ihre Menüs und konfigurieren Sie ihre Benutzermenüs
menu.hint_pictureviewer_defdir Wählen Sie das Startverzeichnis für den Bildbetrachter
@@ -1106,11 +1112,12 @@ menu.hint_scripts Shell-Skripte ausführen
menu.hint_selected_back Ändern Sie die Hintergrundfarbe für ausgewählte Fensterinhalte
menu.hint_selected_text Ändern Sie die Textfarbe für ausgewählte Fensterinhalte
menu.hint_service Sendersuchlauf, Bouquet-Verwaltung, Software-Aktualisierung und mehr
-menu.hint_service_scan Tuner-Einstellungen und Service-Suchlauf
+menu.hint_service_scan Automatischer / manueller Service Suchlauf
menu.hint_settings Konfigurieren von Neutrino-HD,\nNetzwerk, Video, Audio, OSD und mehr
menu.hint_show_mute_icon Definiert, ob bei einem Lautstärkewert von 0 das Stumm-Symbol eingeblendet werden soll
menu.hint_shutdown Setzen Sie Ihre Box in den Standby-Modus oder schalten Sie die Box komplett aus
menu.hint_shutdown_count Die Zeit zum Herunterfahren in den Deep-Standby, wenn die Box im Standby-Modus ist
+menu.hint_shutdown_menu Versetzen des Receivers in den Standby Modus, ausschalten des Receivers, setzen des Sleep Timers
menu.hint_shutdown_rcdelay Aktiviert den Deep-Standby, wenn die Power-Taste länger als 1 Sekunde betätigt wird
menu.hint_shutdown_real Aktiviert den Standby-Modus. Ist diese Option deaktiviert, fährt die Box in den Deep-Standby
menu.hint_sleeptimer Zeitschaltuhr auf Ihrer Box aktivieren\nDie Box fährt dann in den Standby-Modus
@@ -1123,6 +1130,7 @@ menu.hint_softupdate_expert Einzelne Partitionen aus dem Flash lesen bzw. in den
menu.hint_softupdate_expert_read Einzelne Partitionen (U-Boot, Splash, Kernel, SystemFS) aus dem Flash lesen
menu.hint_softupdate_expert_write Einzelne Partitionen (Splash, Kernel, SystemFS) in den Flash schreiben
menu.hint_softupdate_settings Das lokale Update-Verzeichnis und die Konfigurationsdatei festlegen
+menu.hint_standby Receiver in den Standby Modus versetzen
menu.hint_start_tostandby Aktiviert den Standby-Modus direkt nach dem Starten der Box
menu.hint_streaminfo Aktuelle Sender-Informationen über PIDs, SNR-Verhältnis, Bitrate und mehr
menu.hint_subchannel_pos Wählen Sie die Anzeigeposition der Unterkanäle aus
@@ -1317,7 +1325,7 @@ moviebrowser.foot_options Optionen
moviebrowser.foot_play Film starten
moviebrowser.foot_refresh Liste neu laden
moviebrowser.foot_sort Sortieren:
-moviebrowser.head TS Filmarchiv (eigene Aufnahmen)
+moviebrowser.head Meine Aufnahmen
moviebrowser.head_filter Filme nach Kategorie filtern:
moviebrowser.head_playlist Zuletzt gesehen:
moviebrowser.head_recordlist Zuletzt aufgenommen:
@@ -1480,9 +1488,12 @@ networkmenu.reset_settings_now Sollen die vorherigen Einstellungen \nwieder herg
networkmenu.select_if Schnittstelle
networkmenu.services Netzwerkservice
networkmenu.setupnow Einstellungen jetzt zuweisen
-networkmenu.setuponstartup Beim Start Netzwerk setzen
+networkmenu.setuponstartup Schnittstelle beim Start aktivieren
networkmenu.show Aktive Einstellungen zeigen
networkmenu.ssid Netzwerkname (SSID)
+networkmenu.ssid_scan WLAN-Netzwerke suchen
+networkmenu.ssid_scan_error Keine WLAN-Netzwerke gefunden.
+networkmenu.ssid_scan_wait WLAN-Netzwerke werden gesucht...
networkmenu.test Netzwerk testen
neutrino_starting Neutrino wird gestartet...
nfs.alreadymounted Verzeichnis bereits gemountet.
@@ -1534,6 +1545,7 @@ parentallock.lockage16 ab 16 Jahren sperren
parentallock.lockage18 ab 18 Jahren sperren
parentallock.lockedchannel Vorgesperrter Sender...
parentallock.lockedprogram Gesperrtes Programm (FSK ab %d)
+parentallock.menu Sicherheits Menü
parentallock.never Nie
parentallock.onsignal Bei gesendeter Vorsperre
parentallock.parentallock Jugendschutz
diff --git a/data/locale/english.locale b/data/locale/english.locale
index 6da23c14d..3a30a967c 100644
--- a/data/locale/english.locale
+++ b/data/locale/english.locale
@@ -511,6 +511,7 @@ flashupdate.namemode2_default +.img
flashupdate.namemode2_hostname_time ++.img
flashupdate.new_found New image found !
flashupdate.new_notfound No new images found
+flashupdate.noversion Version checks are currently only supported when updating over the web.\nAre you sure that you wish to install this image?
flashupdate.programmingflash programming flash
flashupdate.proxypassword Password
flashupdate.proxypassword_hint1 enter the proxyserver password
@@ -532,7 +533,6 @@ flashupdate.reallyflashmtd Do you really want to flash?\n\nIf a error occurs or
flashupdate.savesuccess The image was successfully saved \nunder %s.
flashupdate.selectimage Available Images/Files
flashupdate.settings Update settings
-flashupdate.squashfs.noversion SquashFS version checks are currently only supported when updating over the web.\nAre you sure that you wish to install this image?
flashupdate.titlereadflash Reading Flash
flashupdate.titlewriteflash Writing Flash
flashupdate.update_with_settings_del_skipped Folder [%s] can not be deleted. Entry is skipped.
@@ -722,6 +722,7 @@ ledcontroler.on.all Led1 & Led2 on
ledcontroler.on.led1 Led1 on
ledcontroler.on.led2 Led2 on
mainmenu.audioplayer Audioplayer
+mainmenu.channels Channels
mainmenu.clearsectionsd Clear EPG Cache
mainmenu.games Games
mainmenu.head Main Menu
@@ -735,10 +736,12 @@ mainmenu.recording Recording
mainmenu.recording_start start
mainmenu.recording_stop stop
mainmenu.scripts Scripts
-mainmenu.service Service
-mainmenu.settings Settings
-mainmenu.shutdown Shutdown
+mainmenu.service Installation (service)
+mainmenu.settings System settings
+mainmenu.shutdown Shutdown (deep standby)
+mainmenu.shutdown_menu Shutdown
mainmenu.sleeptimer SleepTimer
+mainmenu.standby Standby
mainmenu.tvmode TV-Mode
mainmenu.tvradio_switch TV-Radio Switch
mainsettings.audio Audio
@@ -796,6 +799,7 @@ menu.hint_channellist_extended Show current event progress bar
menu.hint_channellist_fonts Change channel list font sizes
menu.hint_channellist_foot Show additional information\nin bottom box
menu.hint_channellist_setup Configure channel list GUI options
+menu.hint_channels Open channel list
menu.hint_ci Conditional access menu\nto setup your CI CAM or embeded Conax card
menu.hint_colors Configure GUI colors
menu.hint_content_back Change GUI window background color
@@ -973,6 +977,7 @@ menu.hint_net_setupnow Apply current settings
menu.hint_net_setuponstartup Start network at boot time
menu.hint_net_show Show current network settings
menu.hint_net_ssid Enter SSID of wireless network\nyou want to connect to
+menu.hint_net_ssid_scan Scan for available WLAN networks
menu.hint_net_telnet Enable telnet login to your box
menu.hint_net_test Test network connection: ping gateway,\n name server and external IP
menu.hint_net_ushare Share connected HDD over uPnp
@@ -985,6 +990,7 @@ menu.hint_osd_language Select OSD language
menu.hint_osd_preset Pre-configured screen margins for CRT and LCD TV
menu.hint_parentallock_changepin Change PIN code
menu.hint_parentallock_lockage Select age allowed to watch
+menu.hint_parentallock_menu Lock menus with pin code
menu.hint_parentallock_prompt Configure when Neutrino-HD will ask you\nfor PIN code
menu.hint_personalize Enable, disable or Protect menu items\nConfigure color-buttons user menus
menu.hint_pictureviewer_defdir Default picture viewer directory
@@ -1106,11 +1112,12 @@ menu.hint_scripts Run scripts
menu.hint_selected_back Change selected item background color
menu.hint_selected_text Change selected item text color
menu.hint_service Tuner setup, service scan,\nbouquet editor, software upgrade
-menu.hint_service_scan Tuner setup, service scan
+menu.hint_service_scan Auto / manual service scan
menu.hint_settings Configure Neutrino-HD\nNetwork, audio, video, OSD and more
menu.hint_show_mute_icon Show mute icon, when volume set to 0
menu.hint_shutdown Put your box in deep standby mode\nNo confirmation
menu.hint_shutdown_count Time to put box in deep-standby\nfrom soft-standby mode
+menu.hint_shutdown_menu Put you receiver in sleep or deep standby mode, set sleep timer
menu.hint_shutdown_rcdelay Enable deep-standby, if power button\npressed more than 1 second
menu.hint_shutdown_real Enable soft-standby mode\nIf disabled, power button put box to deep-standby
menu.hint_sleeptimer Set timer to put your box\nin sleep mode
@@ -1123,6 +1130,7 @@ menu.hint_softupdate_expert Separate partitions from the flash read / write to t
menu.hint_softupdate_expert_read Separate partitions (U-Boot, Splash, Kernel, SystemFS) from the flash read
menu.hint_softupdate_expert_write Separate partitions (Splash, Kernel, SystemFS) write to the flash
menu.hint_softupdate_settings The local update directory and the configuration file to set
+menu.hint_standby Put receiver to sleep mode
menu.hint_start_tostandby Enter standby mode after boot
menu.hint_streaminfo Current channel info: pids, signal and noise ratio\nBitrate graphs
menu.hint_subchannel_pos Select subchannels menu position
@@ -1317,7 +1325,7 @@ moviebrowser.foot_options Options
moviebrowser.foot_play Start movie
moviebrowser.foot_refresh Refresh list
moviebrowser.foot_sort Sort:
-moviebrowser.head TS MovieBrowser
+moviebrowser.head My recordings
moviebrowser.head_filter Filter movies by category:
moviebrowser.head_playlist Last played:
moviebrowser.head_recordlist Last recorded:
@@ -1480,9 +1488,12 @@ networkmenu.reset_settings_now Do you want restore the previous settings?
networkmenu.select_if Interface
networkmenu.services Network services
networkmenu.setupnow Apply network settings now
-networkmenu.setuponstartup Setup network on startup
+networkmenu.setuponstartup Setup interface on startup
networkmenu.show Show active Network settings
networkmenu.ssid Network name (SSID)
+networkmenu.ssid_scan WLAN network scan
+networkmenu.ssid_scan_error No WLAN networks are found.
+networkmenu.ssid_scan_wait WLAN network scan in progress...
networkmenu.test Test network now
neutrino_starting Neutrino starting...
nfs.alreadymounted directory already mounted
@@ -1534,6 +1545,7 @@ parentallock.lockage16 from 16 years up
parentallock.lockage18 from 18 years up
parentallock.lockedchannel Locked sender...
parentallock.lockedprogram Locked program (from %d years up)
+parentallock.menu Menu Security
parentallock.never never
parentallock.onsignal on broadcasted lock
parentallock.parentallock Parental lock
diff --git a/data/locale/nederlands.locale b/data/locale/nederlands.locale
index 4814996a1..d397e5019 100644
--- a/data/locale/nederlands.locale
+++ b/data/locale/nederlands.locale
@@ -495,6 +495,7 @@ flashupdate.msgbox_manual De volgende firmware is gevonden:\nDatum: %s, %s\nBase
flashupdate.mtdselector Partitie-selector
flashupdate.new_found Nieuwe firmware gevonden!
flashupdate.new_notfound Geen nieuwe firmware gevonden
+flashupdate.noversion Versie controle is alleen ondersteund wanneer u update via het internet. \nWeet u zeker dat u deze firmware wilt installeren?
flashupdate.programmingflash programming flash
flashupdate.proxypassword Wachtwoord
flashupdate.proxypassword_hint1 Wachtwoord van de proxyserver invoeren
@@ -513,7 +514,6 @@ flashupdate.reallyflashmtd Weet u zeker dat u wilt updaten?\nIndien er zich een
flashupdate.savesuccess De Firmware is succesvol opgeslagen \n onder %s.
flashupdate.selectimage Beschikbare firmware/bestanden
flashupdate.settings Update instellingen
-flashupdate.squashfs.noversion SquashFS versie controle is alleen ondersteund wanneer u update via het internet. \nWeet u zeker dat u deze firmware wilt installeren?
flashupdate.titlewriteflash Flash schrijven
flashupdate.update_with_settings_del_skipped Folder [%s] kan niet worden verwijderd. Folder is overgeslagen.
flashupdate.update_with_settings_error Foutmelding!\n \nNieuwe firmware heeft %ld KB (out of %ld KB) resterend.\n Onvoldoende \nruimte om opdracht af te ronden. Opdracht wordt geannuleerd.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 18cae035c..ec2663f8f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -8,6 +8,7 @@ SUBDIRS = \
libnet \
xmltree \
libtuxtxt \
+ libiw \
libdvbsub
if ENABLE_UPNP
diff --git a/lib/libconfigfile/configfile.cpp b/lib/libconfigfile/configfile.cpp
index 354d5ec97..651562335 100644
--- a/lib/libconfigfile/configfile.cpp
+++ b/lib/libconfigfile/configfile.cpp
@@ -51,7 +51,7 @@ void CConfigFile::clear()
//
// public file operation methods
//
-bool CConfigFile::loadConfig(const char * const filename)
+bool CConfigFile::loadConfig(const char * const filename, char _delimiter)
{
std::ifstream configFile(filename);
@@ -67,7 +67,7 @@ bool CConfigFile::loadConfig(const char * const filename)
if (configFile.fail())
break;
- std::string::size_type i = s.find('=');
+ std::string::size_type i = s.find(_delimiter);
if (i != std::string::npos)
{
std::string::size_type j = s.find('#');
@@ -86,12 +86,12 @@ bool CConfigFile::loadConfig(const char * const filename)
}
}
-bool CConfigFile::loadConfig(const std::string & filename)
+bool CConfigFile::loadConfig(const std::string & filename, char _delimiter)
{
- return loadConfig(filename.c_str());
+ return loadConfig(filename.c_str(), _delimiter);
}
-bool CConfigFile::saveConfig(const char * const filename)
+bool CConfigFile::saveConfig(const char * const filename, char _delimiter)
{
std::string tmpname = std::string(filename) + ".tmp";
unlink(tmpname.c_str());
@@ -102,7 +102,7 @@ bool CConfigFile::saveConfig(const char * const filename)
std::cout << "[ConfigFile] saving " << filename << std::endl;
for (ConfigDataMap::const_iterator it = configData.begin(); it != configData.end(); ++it)
{
- configFile << it->first << "=" << it->second << std::endl;
+ configFile << it->first << _delimiter << it->second << std::endl;
}
configFile.sync();
@@ -123,9 +123,9 @@ bool CConfigFile::saveConfig(const char * const filename)
}
}
-bool CConfigFile::saveConfig(const std::string & filename)
+bool CConfigFile::saveConfig(const std::string & filename, char _delimiter)
{
- return saveConfig(filename.c_str());
+ return saveConfig(filename.c_str(), _delimiter);
}
diff --git a/lib/libconfigfile/configfile.h b/lib/libconfigfile/configfile.h
index 5a247a556..6f1e052e7 100644
--- a/lib/libconfigfile/configfile.h
+++ b/lib/libconfigfile/configfile.h
@@ -50,11 +50,11 @@ class CConfigFile
public:
CConfigFile(const char p_delimiter, const bool p_saveDefaults = true);
- bool loadConfig(const char * const filename);
- bool loadConfig(const std::string & filename);
+ bool loadConfig(const char * const filename, char _delimiter = '=');
+ bool loadConfig(const std::string & filename, char _delimiter = '=');
- bool saveConfig(const char * const filename);
- bool saveConfig(const std::string & filename);
+ bool saveConfig(const char * const filename, char _delimiter = '=');
+ bool saveConfig(const std::string & filename, char _delimiter = '=');
void clear();
diff --git a/lib/libiw/Makefile.am b/lib/libiw/Makefile.am
new file mode 100644
index 000000000..65576e20d
--- /dev/null
+++ b/lib/libiw/Makefile.am
@@ -0,0 +1,6 @@
+noinst_LIBRARIES = libiw.a
+
+AM_CXXFLAGS = -I$(top_builddir) -fno-rtti -fno-exceptions
+
+libiw_a_SOURCES = iwlib.c iwscan.cpp
+
diff --git a/lib/libiw/iwlib.c b/lib/libiw/iwlib.c
new file mode 100644
index 000000000..0afa8c1e4
--- /dev/null
+++ b/lib/libiw/iwlib.c
@@ -0,0 +1,3214 @@
+/*
+ * Wireless Tools
+ *
+ * Jean II - HPLB 97->99 - HPL 99->07
+ *
+ * Common subroutines to all the wireless tools...
+ *
+ * This file is released under the GPL license.
+ * Copyright (c) 1997-2007 Jean Tourrilhes
+ */
+
+/***************************** INCLUDES *****************************/
+
+#include "iwlib.h" /* Header */
+
+/************************ CONSTANTS & MACROS ************************/
+
+/*
+ * Constants fof WE-9->15
+ */
+#define IW15_MAX_FREQUENCIES 16
+#define IW15_MAX_BITRATES 8
+#define IW15_MAX_TXPOWER 8
+#define IW15_MAX_ENCODING_SIZES 8
+#define IW15_MAX_SPY 8
+#define IW15_MAX_AP 8
+
+/****************************** TYPES ******************************/
+
+/*
+ * Struct iw_range up to WE-15
+ */
+struct iw15_range
+{
+ __u32 throughput;
+ __u32 min_nwid;
+ __u32 max_nwid;
+ __u16 num_channels;
+ __u8 num_frequency;
+ struct iw_freq freq[IW15_MAX_FREQUENCIES];
+ __s32 sensitivity;
+ struct iw_quality max_qual;
+ __u8 num_bitrates;
+ __s32 bitrate[IW15_MAX_BITRATES];
+ __s32 min_rts;
+ __s32 max_rts;
+ __s32 min_frag;
+ __s32 max_frag;
+ __s32 min_pmp;
+ __s32 max_pmp;
+ __s32 min_pmt;
+ __s32 max_pmt;
+ __u16 pmp_flags;
+ __u16 pmt_flags;
+ __u16 pm_capa;
+ __u16 encoding_size[IW15_MAX_ENCODING_SIZES];
+ __u8 num_encoding_sizes;
+ __u8 max_encoding_tokens;
+ __u16 txpower_capa;
+ __u8 num_txpower;
+ __s32 txpower[IW15_MAX_TXPOWER];
+ __u8 we_version_compiled;
+ __u8 we_version_source;
+ __u16 retry_capa;
+ __u16 retry_flags;
+ __u16 r_time_flags;
+ __s32 min_retry;
+ __s32 max_retry;
+ __s32 min_r_time;
+ __s32 max_r_time;
+ struct iw_quality avg_qual;
+};
+
+/*
+ * Union for all the versions of iwrange.
+ * Fortunately, I mostly only add fields at the end, and big-bang
+ * reorganisations are few.
+ */
+union iw_range_raw
+{
+ struct iw15_range range15; /* WE 9->15 */
+ struct iw_range range; /* WE 16->current */
+};
+
+/*
+ * Offsets in iw_range struct
+ */
+#define iwr15_off(f) ( ((char *) &(((struct iw15_range *) NULL)->f)) - \
+ (char *) NULL)
+#define iwr_off(f) ( ((char *) &(((struct iw_range *) NULL)->f)) - \
+ (char *) NULL)
+
+/**************************** VARIABLES ****************************/
+
+/* Modes as human readable strings */
+const char * const iw_operation_mode[] = { "Auto",
+ "Ad-Hoc",
+ "Managed",
+ "Master",
+ "Repeater",
+ "Secondary",
+ "Monitor",
+ "Unknown/bug" };
+
+/* Modulations as human readable strings */
+const struct iw_modul_descr iw_modul_list[] = {
+ /* Start with aggregate types, so that they display first */
+ { IW_MODUL_11AG, "11ag",
+ "IEEE 802.11a + 802.11g (2.4 & 5 GHz, up to 54 Mb/s)" },
+ { IW_MODUL_11AB, "11ab",
+ "IEEE 802.11a + 802.11b (2.4 & 5 GHz, up to 54 Mb/s)" },
+ { IW_MODUL_11G, "11g", "IEEE 802.11g (2.4 GHz, up to 54 Mb/s)" },
+ { IW_MODUL_11A, "11a", "IEEE 802.11a (5 GHz, up to 54 Mb/s)" },
+ { IW_MODUL_11B, "11b", "IEEE 802.11b (2.4 GHz, up to 11 Mb/s)" },
+
+ /* Proprietary aggregates */
+ { IW_MODUL_TURBO | IW_MODUL_11A, "turboa",
+ "Atheros turbo mode at 5 GHz (up to 108 Mb/s)" },
+ { IW_MODUL_TURBO | IW_MODUL_11G, "turbog",
+ "Atheros turbo mode at 2.4 GHz (up to 108 Mb/s)" },
+ { IW_MODUL_PBCC | IW_MODUL_11B, "11+",
+ "TI 802.11+ (2.4 GHz, up to 22 Mb/s)" },
+
+ /* Individual modulations */
+ { IW_MODUL_OFDM_G, "OFDMg",
+ "802.11g higher rates, OFDM at 2.4 GHz (up to 54 Mb/s)" },
+ { IW_MODUL_OFDM_A, "OFDMa", "802.11a, OFDM at 5 GHz (up to 54 Mb/s)" },
+ { IW_MODUL_CCK, "CCK", "802.11b higher rates (2.4 GHz, up to 11 Mb/s)" },
+ { IW_MODUL_DS, "DS", "802.11 Direct Sequence (2.4 GHz, up to 2 Mb/s)" },
+ { IW_MODUL_FH, "FH", "802.11 Frequency Hopping (2,4 GHz, up to 2 Mb/s)" },
+
+ /* Proprietary modulations */
+ { IW_MODUL_TURBO, "turbo",
+ "Atheros turbo mode, channel bonding (up to 108 Mb/s)" },
+ { IW_MODUL_PBCC, "PBCC",
+ "TI 802.11+ higher rates (2.4 GHz, up to 22 Mb/s)" },
+ { IW_MODUL_CUSTOM, "custom",
+ "Driver specific modulation (check driver documentation)" },
+};
+
+/* Disable runtime version warning in iw_get_range_info() */
+int iw_ignore_version = 0;
+
+/************************ SOCKET SUBROUTINES *************************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Open a socket.
+ * Depending on the protocol present, open the right socket. The socket
+ * will allow us to talk to the driver.
+ */
+int
+iw_sockets_open(void)
+{
+ static const int families[] = {
+ AF_INET, AF_IPX, AF_AX25, AF_APPLETALK
+ };
+ unsigned int i;
+ int sock;
+
+ /*
+ * Now pick any (exisiting) useful socket family for generic queries
+ * Note : don't open all the socket, only returns when one matches,
+ * all protocols might not be valid.
+ * Workaround by Jim Kaba
+ * Note : in 99% of the case, we will just open the inet_sock.
+ * The remaining 1% case are not fully correct...
+ */
+
+ /* Try all families we support */
+ for(i = 0; i < sizeof(families)/sizeof(int); ++i)
+ {
+ /* Try to open the socket, if success returns it */
+ sock = socket(families[i], SOCK_DGRAM, 0);
+ if(sock >= 0)
+ return sock;
+ }
+
+ return -1;
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Extract the interface name out of /proc/net/wireless or /proc/net/dev.
+ */
+static inline char *
+iw_get_ifname(char * name, /* Where to store the name */
+ int nsize, /* Size of name buffer */
+ char * buf) /* Current position in buffer */
+{
+ char * end;
+
+ /* Skip leading spaces */
+ while(isspace(*buf))
+ buf++;
+
+#ifndef IW_RESTRIC_ENUM
+ /* Get name up to the last ':'. Aliases may contain ':' in them,
+ * but the last one should be the separator */
+ end = strrchr(buf, ':');
+#else
+ /* Get name up to ": "
+ * Note : we compare to ": " to make sure to process aliased interfaces
+ * properly. Doesn't work on /proc/net/dev, because it doesn't guarantee
+ * a ' ' after the ':'*/
+ end = strstr(buf, ": ");
+#endif
+
+ /* Not found ??? To big ??? */
+ if((end == NULL) || (((end - buf) + 1) > nsize))
+ return(NULL);
+
+ /* Copy */
+ memcpy(name, buf, (end - buf));
+ name[end - buf] = '\0';
+
+ /* Return value currently unused, just make sure it's non-NULL */
+ return(end);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Enumerate devices and call specified routine
+ * The new way just use /proc/net/wireless, so get all wireless interfaces,
+ * whether configured or not. This is the default if available.
+ * The old way use SIOCGIFCONF, so get only configured interfaces (wireless
+ * or not).
+ */
+void
+iw_enum_devices(int skfd,
+ iw_enum_handler fn,
+ char * args[],
+ int count)
+{
+ char buff[1024];
+ FILE * fh;
+ struct ifconf ifc;
+ struct ifreq *ifr;
+ int i;
+
+#ifndef IW_RESTRIC_ENUM
+ /* Check if /proc/net/dev is available */
+ fh = fopen(PROC_NET_DEV, "r");
+#else
+ /* Check if /proc/net/wireless is available */
+ fh = fopen(PROC_NET_WIRELESS, "r");
+#endif
+
+ if(fh != NULL)
+ {
+ /* Success : use data from /proc/net/wireless */
+
+ /* Eat 2 lines of header */
+ fgets(buff, sizeof(buff), fh);
+ fgets(buff, sizeof(buff), fh);
+
+ /* Read each device line */
+ while(fgets(buff, sizeof(buff), fh))
+ {
+ char name[IFNAMSIZ + 1];
+ char *s;
+
+ /* Skip empty or almost empty lines. It seems that in some
+ * cases fgets return a line with only a newline. */
+ if((buff[0] == '\0') || (buff[1] == '\0'))
+ continue;
+
+ /* Extract interface name */
+ s = iw_get_ifname(name, sizeof(name), buff);
+
+ if(!s)
+ {
+ /* Failed to parse, complain and continue */
+#ifndef IW_RESTRIC_ENUM
+ fprintf(stderr, "Cannot parse " PROC_NET_DEV "\n");
+#else
+ fprintf(stderr, "Cannot parse " PROC_NET_WIRELESS "\n");
+#endif
+ }
+ else
+ /* Got it, print info about this interface */
+ (*fn)(skfd, name, args, count);
+ }
+
+ fclose(fh);
+ }
+ else
+ {
+ /* Get list of configured devices using "traditional" way */
+ ifc.ifc_len = sizeof(buff);
+ ifc.ifc_buf = buff;
+ if(ioctl(skfd, SIOCGIFCONF, &ifc) < 0)
+ {
+ fprintf(stderr, "SIOCGIFCONF: %s\n", strerror(errno));
+ return;
+ }
+ ifr = ifc.ifc_req;
+
+ /* Print them */
+ for(i = ifc.ifc_len / sizeof(struct ifreq); --i >= 0; ifr++)
+ (*fn)(skfd, ifr->ifr_name, args, count);
+ }
+}
+
+/*********************** WIRELESS SUBROUTINES ************************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Extract WE version number from /proc/net/wireless
+ * In most cases, you really want to get version information from
+ * the range info (range->we_version_compiled), see below...
+ *
+ * If we have WE-16 and later, the WE version is available at the
+ * end of the header line of the file.
+ * For version prior to that, we can only detect the change from
+ * v11 to v12, so we do an approximate job. Fortunately, v12 to v15
+ * are highly binary compatible (on the struct level).
+ */
+int
+iw_get_kernel_we_version(void)
+{
+ char buff[1024];
+ FILE * fh;
+ char * p;
+ int v;
+
+ /* Check if /proc/net/wireless is available */
+ fh = fopen(PROC_NET_WIRELESS, "r");
+
+ if(fh == NULL)
+ {
+ fprintf(stderr, "Cannot read " PROC_NET_WIRELESS "\n");
+ return(-1);
+ }
+
+ /* Read the first line of buffer */
+ fgets(buff, sizeof(buff), fh);
+
+ if(strstr(buff, "| WE") == NULL)
+ {
+ /* Prior to WE16, so explicit version not present */
+
+ /* Black magic */
+ if(strstr(buff, "| Missed") == NULL)
+ v = 11;
+ else
+ v = 15;
+ fclose(fh);
+ return(v);
+ }
+
+ /* Read the second line of buffer */
+ fgets(buff, sizeof(buff), fh);
+
+ /* Get to the last separator, to get the version */
+ p = strrchr(buff, '|');
+ if((p == NULL) || (sscanf(p + 1, "%d", &v) != 1))
+ {
+ fprintf(stderr, "Cannot parse " PROC_NET_WIRELESS "\n");
+ fclose(fh);
+ return(-1);
+ }
+
+ fclose(fh);
+ return(v);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Print the WE versions of the interface.
+ */
+static int
+print_iface_version_info(int skfd,
+ char * ifname,
+ char * args[], /* Command line args */
+ int count) /* Args count */
+{
+ struct iwreq wrq;
+ char buffer[sizeof(iwrange) * 2]; /* Large enough */
+ struct iw_range * range;
+
+ /* Avoid "Unused parameter" warning */
+ args = args; count = count;
+
+ /* If no wireless name : no wireless extensions.
+ * This enable us to treat the SIOCGIWRANGE failure below properly. */
+ if(iw_get_ext(skfd, ifname, SIOCGIWNAME, &wrq) < 0)
+ return(-1);
+
+ /* Cleanup */
+ memset(buffer, 0, sizeof(buffer));
+
+ wrq.u.data.pointer = (caddr_t) buffer;
+ wrq.u.data.length = sizeof(buffer);
+ wrq.u.data.flags = 0;
+ if(iw_get_ext(skfd, ifname, SIOCGIWRANGE, &wrq) < 0)
+ {
+ /* Interface support WE (see above), but not IWRANGE */
+ fprintf(stderr, "%-8.16s Driver has no Wireless Extension version information.\n\n", ifname);
+ return(0);
+ }
+
+ /* Copy stuff at the right place, ignore extra */
+ range = (struct iw_range *) buffer;
+
+ /* For new versions, we can check the version directly, for old versions
+ * we use magic. 300 bytes is a also magic number, don't touch... */
+ if(wrq.u.data.length >= 300)
+ {
+ /* Version is always at the same offset, so it's ok */
+ printf("%-8.16s Recommend Wireless Extension v%d or later,\n",
+ ifname, range->we_version_source);
+ printf(" Currently compiled with Wireless Extension v%d.\n\n",
+ range->we_version_compiled);
+ }
+ else
+ {
+ fprintf(stderr, "%-8.16s Wireless Extension version too old.\n\n",
+ ifname);
+ }
+
+
+ return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Print the WE versions of the tools.
+ */
+int
+iw_print_version_info(const char * toolname)
+{
+ int skfd; /* generic raw socket desc. */
+ int we_kernel_version;
+
+ /* Create a channel to the NET kernel. */
+ if((skfd = iw_sockets_open()) < 0)
+ {
+ perror("socket");
+ return -1;
+ }
+
+ /* Information about the tools themselves */
+ if(toolname != NULL)
+ printf("%-8.16s Wireless-Tools version %d\n", toolname, WT_VERSION);
+ printf(" Compatible with Wireless Extension v11 to v%d.\n\n",
+ WE_MAX_VERSION);
+
+ /* Get version from kernel */
+ we_kernel_version = iw_get_kernel_we_version();
+ /* Only version >= 16 can be verified, other are guessed */
+ if(we_kernel_version > 15)
+ printf("Kernel Currently compiled with Wireless Extension v%d.\n\n",
+ we_kernel_version);
+
+ /* Version for each device */
+ iw_enum_devices(skfd, &print_iface_version_info, NULL, 0);
+
+ iw_sockets_close(skfd);
+
+ return 0;
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Get the range information out of the driver
+ */
+int
+iw_get_range_info(int skfd,
+ const char * ifname,
+ iwrange * range)
+{
+ struct iwreq wrq;
+ char buffer[sizeof(iwrange) * 2]; /* Large enough */
+ union iw_range_raw * range_raw;
+
+ /* Cleanup */
+ bzero(buffer, sizeof(buffer));
+
+ wrq.u.data.pointer = (caddr_t) buffer;
+ wrq.u.data.length = sizeof(buffer);
+ wrq.u.data.flags = 0;
+ if(iw_get_ext(skfd, ifname, SIOCGIWRANGE, &wrq) < 0)
+ return(-1);
+
+ /* Point to the buffer */
+ range_raw = (union iw_range_raw *) buffer;
+
+ /* For new versions, we can check the version directly, for old versions
+ * we use magic. 300 bytes is a also magic number, don't touch... */
+ if(wrq.u.data.length < 300)
+ {
+ /* That's v10 or earlier. Ouch ! Let's make a guess...*/
+ range_raw->range.we_version_compiled = 9;
+ }
+
+ /* Check how it needs to be processed */
+ if(range_raw->range.we_version_compiled > 15)
+ {
+ /* This is our native format, that's easy... */
+ /* Copy stuff at the right place, ignore extra */
+ memcpy((char *) range, buffer, sizeof(iwrange));
+ }
+ else
+ {
+ /* Zero unknown fields */
+ bzero((char *) range, sizeof(struct iw_range));
+
+ /* Initial part unmoved */
+ memcpy((char *) range,
+ buffer,
+ iwr15_off(num_channels));
+ /* Frequencies pushed futher down towards the end */
+ memcpy((char *) range + iwr_off(num_channels),
+ buffer + iwr15_off(num_channels),
+ iwr15_off(sensitivity) - iwr15_off(num_channels));
+ /* This one moved up */
+ memcpy((char *) range + iwr_off(sensitivity),
+ buffer + iwr15_off(sensitivity),
+ iwr15_off(num_bitrates) - iwr15_off(sensitivity));
+ /* This one goes after avg_qual */
+ memcpy((char *) range + iwr_off(num_bitrates),
+ buffer + iwr15_off(num_bitrates),
+ iwr15_off(min_rts) - iwr15_off(num_bitrates));
+ /* Number of bitrates has changed, put it after */
+ memcpy((char *) range + iwr_off(min_rts),
+ buffer + iwr15_off(min_rts),
+ iwr15_off(txpower_capa) - iwr15_off(min_rts));
+ /* Added encoding_login_index, put it after */
+ memcpy((char *) range + iwr_off(txpower_capa),
+ buffer + iwr15_off(txpower_capa),
+ iwr15_off(txpower) - iwr15_off(txpower_capa));
+ /* Hum... That's an unexpected glitch. Bummer. */
+ memcpy((char *) range + iwr_off(txpower),
+ buffer + iwr15_off(txpower),
+ iwr15_off(avg_qual) - iwr15_off(txpower));
+ /* Avg qual moved up next to max_qual */
+ memcpy((char *) range + iwr_off(avg_qual),
+ buffer + iwr15_off(avg_qual),
+ sizeof(struct iw_quality));
+ }
+
+ /* We are now checking much less than we used to do, because we can
+ * accomodate more WE version. But, there are still cases where things
+ * will break... */
+ if(!iw_ignore_version)
+ {
+ /* We don't like very old version (unfortunately kernel 2.2.X) */
+ if(range->we_version_compiled <= 10)
+ {
+ fprintf(stderr, "Warning: Driver for device %s has been compiled with an ancient version\n", ifname);
+ fprintf(stderr, "of Wireless Extension, while this program support version 11 and later.\n");
+ fprintf(stderr, "Some things may be broken...\n\n");
+ }
+
+ /* We don't like future versions of WE, because we can't cope with
+ * the unknown */
+ if(range->we_version_compiled > WE_MAX_VERSION)
+ {
+ fprintf(stderr, "Warning: Driver for device %s has been compiled with version %d\n", ifname, range->we_version_compiled);
+ fprintf(stderr, "of Wireless Extension, while this program supports up to version %d.\n", WE_MAX_VERSION);
+ fprintf(stderr, "Some things may be broken...\n\n");
+ }
+
+ /* Driver version verification */
+ if((range->we_version_compiled > 10) &&
+ (range->we_version_compiled < range->we_version_source))
+ {
+ fprintf(stderr, "Warning: Driver for device %s recommend version %d of Wireless Extension,\n", ifname, range->we_version_source);
+ fprintf(stderr, "but has been compiled with version %d, therefore some driver features\n", range->we_version_compiled);
+ fprintf(stderr, "may not be available...\n\n");
+ }
+ /* Note : we are only trying to catch compile difference, not source.
+ * If the driver source has not been updated to the latest, it doesn't
+ * matter because the new fields are set to zero */
+ }
+
+ /* Don't complain twice.
+ * In theory, the test apply to each individual driver, but usually
+ * all drivers are compiled from the same kernel. */
+ iw_ignore_version = 1;
+
+ return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Get information about what private ioctls are supported by the driver
+ *
+ * Note : there is one danger using this function. If it return 0, you
+ * still need to free() the buffer. Beware.
+ */
+int
+iw_get_priv_info(int skfd,
+ const char * ifname,
+ iwprivargs ** ppriv)
+{
+ struct iwreq wrq;
+ iwprivargs * priv = NULL; /* Not allocated yet */
+ int maxpriv = 16; /* Minimum for compatibility WE<13 */
+ iwprivargs * newpriv;
+
+ /* Some driver may return a very large number of ioctls. Some
+ * others a very small number. We now use a dynamic allocation
+ * of the array to satisfy everybody. Of course, as we don't know
+ * in advance the size of the array, we try various increasing
+ * sizes. Jean II */
+ do
+ {
+ /* (Re)allocate the buffer */
+ newpriv = realloc(priv, maxpriv * sizeof(priv[0]));
+ if(newpriv == NULL)
+ {
+ fprintf(stderr, "%s: Allocation failed\n", __FUNCTION__);
+ break;
+ }
+ priv = newpriv;
+
+ /* Ask the driver if it's large enough */
+ wrq.u.data.pointer = (caddr_t) priv;
+ wrq.u.data.length = maxpriv;
+ wrq.u.data.flags = 0;
+ if(iw_get_ext(skfd, ifname, SIOCGIWPRIV, &wrq) >= 0)
+ {
+ /* Success. Pass the buffer by pointer */
+ *ppriv = priv;
+ /* Return the number of ioctls */
+ return(wrq.u.data.length);
+ }
+
+ /* Only E2BIG means the buffer was too small, abort on other errors */
+ if(errno != E2BIG)
+ {
+ /* Most likely "not supported". Don't barf. */
+ break;
+ }
+
+ /* Failed. We probably need a bigger buffer. Check if the kernel
+ * gave us any hints. */
+ if(wrq.u.data.length > maxpriv)
+ maxpriv = wrq.u.data.length;
+ else
+ maxpriv *= 2;
+ }
+ while(maxpriv < 1000);
+
+ /* Cleanup */
+ if(priv)
+ free(priv);
+ *ppriv = NULL;
+
+ return(-1);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Get essential wireless config from the device driver
+ * We will call all the classical wireless ioctl on the driver through
+ * the socket to know what is supported and to get the settings...
+ * Note : compare to the version in iwconfig, we extract only
+ * what's *really* needed to configure a device...
+ */
+int
+iw_get_basic_config(int skfd,
+ const char * ifname,
+ wireless_config * info)
+{
+ struct iwreq wrq;
+
+ memset((char *) info, 0, sizeof(struct wireless_config));
+
+ /* Get wireless name */
+ if(iw_get_ext(skfd, ifname, SIOCGIWNAME, &wrq) < 0)
+ /* If no wireless name : no wireless extensions */
+ return(-1);
+ else
+ {
+ strncpy(info->name, wrq.u.name, IFNAMSIZ);
+ info->name[IFNAMSIZ] = '\0';
+ }
+
+ /* Get network ID */
+ if(iw_get_ext(skfd, ifname, SIOCGIWNWID, &wrq) >= 0)
+ {
+ info->has_nwid = 1;
+ memcpy(&(info->nwid), &(wrq.u.nwid), sizeof(iwparam));
+ }
+
+ /* Get frequency / channel */
+ if(iw_get_ext(skfd, ifname, SIOCGIWFREQ, &wrq) >= 0)
+ {
+ info->has_freq = 1;
+ info->freq = iw_freq2float(&(wrq.u.freq));
+ info->freq_flags = wrq.u.freq.flags;
+ }
+
+ /* Get encryption information */
+ wrq.u.data.pointer = (caddr_t) info->key;
+ wrq.u.data.length = IW_ENCODING_TOKEN_MAX;
+ wrq.u.data.flags = 0;
+ if(iw_get_ext(skfd, ifname, SIOCGIWENCODE, &wrq) >= 0)
+ {
+ info->has_key = 1;
+ info->key_size = wrq.u.data.length;
+ info->key_flags = wrq.u.data.flags;
+ }
+
+ /* Get ESSID */
+ wrq.u.essid.pointer = (caddr_t) info->essid;
+ wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
+ wrq.u.essid.flags = 0;
+ if(iw_get_ext(skfd, ifname, SIOCGIWESSID, &wrq) >= 0)
+ {
+ info->has_essid = 1;
+ info->essid_on = wrq.u.data.flags;
+ }
+
+ /* Get operation mode */
+ if(iw_get_ext(skfd, ifname, SIOCGIWMODE, &wrq) >= 0)
+ {
+ info->has_mode = 1;
+ /* Note : event->u.mode is unsigned, no need to check <= 0 */
+ if(wrq.u.mode < IW_NUM_OPER_MODE)
+ info->mode = wrq.u.mode;
+ else
+ info->mode = IW_NUM_OPER_MODE; /* Unknown/bug */
+ }
+
+ return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Set essential wireless config in the device driver
+ * We will call all the classical wireless ioctl on the driver through
+ * the socket to know what is supported and to set the settings...
+ * We support only the restricted set as above...
+ */
+int
+iw_set_basic_config(int skfd,
+ const char * ifname,
+ wireless_config * info)
+{
+ struct iwreq wrq;
+ int ret = 0;
+
+ /* Get wireless name (check if interface is valid) */
+ if(iw_get_ext(skfd, ifname, SIOCGIWNAME, &wrq) < 0)
+ /* If no wireless name : no wireless extensions */
+ return(-2);
+
+ /* Set the current mode of operation
+ * Mode need to be first : some settings apply only in a specific mode
+ * (such as frequency).
+ */
+ if(info->has_mode)
+ {
+ strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
+ wrq.u.mode = info->mode;
+
+ if(iw_get_ext(skfd, ifname, SIOCSIWMODE, &wrq) < 0)
+ {
+ fprintf(stderr, "SIOCSIWMODE: %s\n", strerror(errno));
+ ret = -1;
+ }
+ }
+
+ /* Set frequency / channel */
+ if(info->has_freq)
+ {
+ iw_float2freq(info->freq, &(wrq.u.freq));
+
+ if(iw_set_ext(skfd, ifname, SIOCSIWFREQ, &wrq) < 0)
+ {
+ fprintf(stderr, "SIOCSIWFREQ: %s\n", strerror(errno));
+ ret = -1;
+ }
+ }
+
+ /* Set encryption information */
+ if(info->has_key)
+ {
+ int flags = info->key_flags;
+
+ /* Check if there is a key index */
+ if((flags & IW_ENCODE_INDEX) > 0)
+ {
+ /* Set the index */
+ wrq.u.data.pointer = (caddr_t) NULL;
+ wrq.u.data.flags = (flags & (IW_ENCODE_INDEX)) | IW_ENCODE_NOKEY;
+ wrq.u.data.length = 0;
+
+ if(iw_set_ext(skfd, ifname, SIOCSIWENCODE, &wrq) < 0)
+ {
+ fprintf(stderr, "SIOCSIWENCODE(%d): %s\n",
+ errno, strerror(errno));
+ ret = -1;
+ }
+ }
+
+ /* Mask out index to minimise probability of reject when setting key */
+ flags = flags & (~IW_ENCODE_INDEX);
+
+ /* Set the key itself (set current key in this case) */
+ wrq.u.data.pointer = (caddr_t) info->key;
+ wrq.u.data.length = info->key_size;
+ wrq.u.data.flags = flags;
+
+ /* Compatibility with WE<13 */
+ if(flags & IW_ENCODE_NOKEY)
+ wrq.u.data.pointer = NULL;
+
+ if(iw_set_ext(skfd, ifname, SIOCSIWENCODE, &wrq) < 0)
+ {
+ fprintf(stderr, "SIOCSIWENCODE(%d): %s\n",
+ errno, strerror(errno));
+ ret = -1;
+ }
+ }
+
+ /* Set Network ID, if available (this is for non-802.11 cards) */
+ if(info->has_nwid)
+ {
+ memcpy(&(wrq.u.nwid), &(info->nwid), sizeof(iwparam));
+ wrq.u.nwid.fixed = 1; /* Hum... When in Rome... */
+
+ if(iw_set_ext(skfd, ifname, SIOCSIWNWID, &wrq) < 0)
+ {
+ fprintf(stderr, "SIOCSIWNWID: %s\n", strerror(errno));
+ ret = -1;
+ }
+ }
+
+ /* Set ESSID (extended network), if available.
+ * ESSID need to be last : most device re-perform the scanning/discovery
+ * when this is set, and things like encryption keys are better be
+ * defined if we want to discover the right set of APs/nodes.
+ */
+ if(info->has_essid)
+ {
+ int we_kernel_version;
+ we_kernel_version = iw_get_kernel_we_version();
+
+ wrq.u.essid.pointer = (caddr_t) info->essid;
+ wrq.u.essid.length = strlen(info->essid);
+ wrq.u.data.flags = info->essid_on;
+ if(we_kernel_version < 21)
+ wrq.u.essid.length++;
+
+ if(iw_set_ext(skfd, ifname, SIOCSIWESSID, &wrq) < 0)
+ {
+ fprintf(stderr, "SIOCSIWESSID: %s\n", strerror(errno));
+ ret = -1;
+ }
+ }
+
+ return(ret);
+}
+
+/*********************** PROTOCOL SUBROUTINES ***********************/
+/*
+ * Fun stuff with protocol identifiers (SIOCGIWNAME).
+ * We assume that drivers are returning sensible values in there,
+ * which is not always the case :-(
+ */
+
+/*------------------------------------------------------------------*/
+/*
+ * Compare protocol identifiers.
+ * We don't want to know if the two protocols are the exactly same,
+ * but if they interoperate at some level, and also if they accept the
+ * same type of config (ESSID vs NWID, freq...).
+ * This is supposed to work around the alphabet soup.
+ * Return 1 if protocols are compatible, 0 otherwise
+ */
+int
+iw_protocol_compare(const char * protocol1,
+ const char * protocol2)
+{
+ const char * dot11 = "IEEE 802.11";
+ const char * dot11_ds = "Dbg";
+ const char * dot11_5g = "a";
+
+ /* If the strings are the same -> easy */
+ if(!strncmp(protocol1, protocol2, IFNAMSIZ))
+ return(1);
+
+ /* Are we dealing with one of the 802.11 variant ? */
+ if( (!strncmp(protocol1, dot11, strlen(dot11))) &&
+ (!strncmp(protocol2, dot11, strlen(dot11))) )
+ {
+ const char * sub1 = protocol1 + strlen(dot11);
+ const char * sub2 = protocol2 + strlen(dot11);
+ unsigned int i;
+ int isds1 = 0;
+ int isds2 = 0;
+ int is5g1 = 0;
+ int is5g2 = 0;
+
+ /* Check if we find the magic letters telling it's DS compatible */
+ for(i = 0; i < strlen(dot11_ds); i++)
+ {
+ if(strchr(sub1, dot11_ds[i]) != NULL)
+ isds1 = 1;
+ if(strchr(sub2, dot11_ds[i]) != NULL)
+ isds2 = 1;
+ }
+ if(isds1 && isds2)
+ return(1);
+
+ /* Check if we find the magic letters telling it's 5GHz compatible */
+ for(i = 0; i < strlen(dot11_5g); i++)
+ {
+ if(strchr(sub1, dot11_5g[i]) != NULL)
+ is5g1 = 1;
+ if(strchr(sub2, dot11_5g[i]) != NULL)
+ is5g2 = 1;
+ }
+ if(is5g1 && is5g2)
+ return(1);
+ }
+ /* Not compatible */
+ return(0);
+}
+
+/********************** FREQUENCY SUBROUTINES ***********************/
+/*
+ * Note : the two functions below are the cause of troubles on
+ * various embeeded platforms, as they are the reason we require
+ * libm (math library).
+ * In this case, please use enable BUILD_NOLIBM in the makefile
+ *
+ * FIXME : check negative mantissa and exponent
+ */
+
+/*------------------------------------------------------------------*/
+/*
+ * Convert a floating point the our internal representation of
+ * frequencies.
+ * The kernel doesn't want to hear about floating point, so we use
+ * this custom format instead.
+ */
+void
+iw_float2freq(double in,
+ iwfreq * out)
+{
+#ifdef WE_NOLIBM
+ /* Version without libm : slower */
+ out->e = 0;
+ while(in > 1e9)
+ {
+ in /= 10;
+ out->e++;
+ }
+ out->m = (long) in;
+#else /* WE_NOLIBM */
+ /* Version with libm : faster */
+ out->e = (short) (floor(log10(in)));
+ if(out->e > 8)
+ {
+ out->m = ((long) (floor(in / pow(10,out->e - 6)))) * 100;
+ out->e -= 8;
+ }
+ else
+ {
+ out->m = (long) in;
+ out->e = 0;
+ }
+#endif /* WE_NOLIBM */
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Convert our internal representation of frequencies to a floating point.
+ */
+double
+iw_freq2float(const iwfreq * in)
+{
+#ifdef WE_NOLIBM
+ /* Version without libm : slower */
+ int i;
+ double res = (double) in->m;
+ for(i = 0; i < in->e; i++)
+ res *= 10;
+ return(res);
+#else /* WE_NOLIBM */
+ /* Version with libm : faster */
+ return ((double) in->m) * pow(10,in->e);
+#endif /* WE_NOLIBM */
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Output a frequency with proper scaling
+ */
+void
+iw_print_freq_value(char * buffer,
+ int buflen,
+ double freq)
+{
+ if(freq < KILO)
+ snprintf(buffer, buflen, "%g", freq);
+ else
+ {
+ char scale;
+ int divisor;
+
+ if(freq >= GIGA)
+ {
+ scale = 'G';
+ divisor = GIGA;
+ }
+ else
+ {
+ if(freq >= MEGA)
+ {
+ scale = 'M';
+ divisor = MEGA;
+ }
+ else
+ {
+ scale = 'k';
+ divisor = KILO;
+ }
+ }
+ snprintf(buffer, buflen, "%g %cHz", freq / divisor, scale);
+ }
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Output a frequency with proper scaling
+ */
+void
+iw_print_freq(char * buffer,
+ int buflen,
+ double freq,
+ int channel,
+ int freq_flags)
+{
+ char sep = ((freq_flags & IW_FREQ_FIXED) ? '=' : ':');
+ char vbuf[16];
+
+ /* Print the frequency/channel value */
+ iw_print_freq_value(vbuf, sizeof(vbuf), freq);
+
+ /* Check if channel only */
+ if(freq < KILO)
+ snprintf(buffer, buflen, "Channel%c%s", sep, vbuf);
+ else
+ {
+ /* Frequency. Check if we have a channel as well */
+ if(channel >= 0)
+ snprintf(buffer, buflen, "Frequency%c%s (Channel %d)",
+ sep, vbuf, channel);
+ else
+ snprintf(buffer, buflen, "Frequency%c%s", sep, vbuf);
+ }
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Convert a frequency to a channel (negative -> error)
+ */
+int
+iw_freq_to_channel(double freq,
+ const struct iw_range * range)
+{
+ double ref_freq;
+ int k;
+
+ /* Check if it's a frequency or not already a channel */
+ if(freq < KILO)
+ return(-1);
+
+ /* We compare the frequencies as double to ignore differences
+ * in encoding. Slower, but safer... */
+ for(k = 0; k < range->num_frequency; k++)
+ {
+ ref_freq = iw_freq2float(&(range->freq[k]));
+ if(freq == ref_freq)
+ return(range->freq[k].i);
+ }
+ /* Not found */
+ return(-2);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Convert a channel to a frequency (negative -> error)
+ * Return the channel on success
+ */
+int
+iw_channel_to_freq(int channel,
+ double * pfreq,
+ const struct iw_range * range)
+{
+ int has_freq = 0;
+ int k;
+
+ /* Check if the driver support only channels or if it has frequencies */
+ for(k = 0; k < range->num_frequency; k++)
+ {
+ if((range->freq[k].e != 0) || (range->freq[k].m > (int) KILO))
+ has_freq = 1;
+ }
+ if(!has_freq)
+ return(-1);
+
+ /* Find the correct frequency in the list */
+ for(k = 0; k < range->num_frequency; k++)
+ {
+ if(range->freq[k].i == channel)
+ {
+ *pfreq = iw_freq2float(&(range->freq[k]));
+ return(channel);
+ }
+ }
+ /* Not found */
+ return(-2);
+}
+
+/*********************** BITRATE SUBROUTINES ***********************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Output a bitrate with proper scaling
+ */
+void
+iw_print_bitrate(char * buffer,
+ int buflen,
+ int bitrate)
+{
+ double rate = bitrate;
+ char scale;
+ int divisor;
+
+ if(rate >= GIGA)
+ {
+ scale = 'G';
+ divisor = GIGA;
+ }
+ else
+ {
+ if(rate >= MEGA)
+ {
+ scale = 'M';
+ divisor = MEGA;
+ }
+ else
+ {
+ scale = 'k';
+ divisor = KILO;
+ }
+ }
+ snprintf(buffer, buflen, "%g %cb/s", rate / divisor, scale);
+}
+
+/************************ POWER SUBROUTINES *************************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Convert a value in dBm to a value in milliWatt.
+ */
+int
+iw_dbm2mwatt(int in)
+{
+#ifdef WE_NOLIBM
+ /* Version without libm : slower */
+ int ip = in / 10;
+ int fp = in % 10;
+ int k;
+ double res = 1.0;
+
+ /* Split integral and floating part to avoid accumulating rounding errors */
+ for(k = 0; k < ip; k++)
+ res *= 10;
+ for(k = 0; k < fp; k++)
+ res *= LOG10_MAGIC;
+ return((int) res);
+#else /* WE_NOLIBM */
+ /* Version with libm : faster */
+ return((int) (floor(pow(10.0, (((double) in) / 10.0)))));
+#endif /* WE_NOLIBM */
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Convert a value in milliWatt to a value in dBm.
+ */
+int
+iw_mwatt2dbm(int in)
+{
+#ifdef WE_NOLIBM
+ /* Version without libm : slower */
+ double fin = (double) in;
+ int res = 0;
+
+ /* Split integral and floating part to avoid accumulating rounding errors */
+ while(fin > 10.0)
+ {
+ res += 10;
+ fin /= 10.0;
+ }
+ while(fin > 1.000001) /* Eliminate rounding errors, take ceil */
+ {
+ res += 1;
+ fin /= LOG10_MAGIC;
+ }
+ return(res);
+#else /* WE_NOLIBM */
+ /* Version with libm : faster */
+ return((int) (ceil(10.0 * log10((double) in))));
+#endif /* WE_NOLIBM */
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Output a txpower with proper conversion
+ */
+void
+iw_print_txpower(char * buffer,
+ int buflen,
+ struct iw_param * txpower)
+{
+ int dbm;
+
+ /* Check if disabled */
+ if(txpower->disabled)
+ {
+ snprintf(buffer, buflen, "off");
+ }
+ else
+ {
+ /* Check for relative values */
+ if(txpower->flags & IW_TXPOW_RELATIVE)
+ {
+ snprintf(buffer, buflen, "%d", txpower->value);
+ }
+ else
+ {
+ /* Convert everything to dBm */
+ if(txpower->flags & IW_TXPOW_MWATT)
+ dbm = iw_mwatt2dbm(txpower->value);
+ else
+ dbm = txpower->value;
+
+ /* Display */
+ snprintf(buffer, buflen, "%d dBm", dbm);
+ }
+ }
+}
+
+/********************** STATISTICS SUBROUTINES **********************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Read /proc/net/wireless to get the latest statistics
+ * Note : strtok not thread safe, not used in WE-12 and later.
+ */
+int
+iw_get_stats(int skfd,
+ const char * ifname,
+ iwstats * stats,
+ const iwrange * range,
+ int has_range)
+{
+ /* Fortunately, we can always detect this condition properly */
+ if((has_range) && (range->we_version_compiled > 11))
+ {
+ struct iwreq wrq;
+ wrq.u.data.pointer = (caddr_t) stats;
+ wrq.u.data.length = sizeof(struct iw_statistics);
+ wrq.u.data.flags = 1; /* Clear updated flag */
+ strncpy(wrq.ifr_name, ifname, IFNAMSIZ);
+ if(iw_get_ext(skfd, ifname, SIOCGIWSTATS, &wrq) < 0)
+ return(-1);
+
+ /* Format has not changed since WE-12, no conversion */
+ return(0);
+ }
+ else
+ {
+ FILE * f = fopen(PROC_NET_WIRELESS, "r");
+ char buf[256];
+ char * bp;
+ int t;
+
+ if(f==NULL)
+ return -1;
+ /* Loop on all devices */
+ while(fgets(buf,255,f))
+ {
+ bp=buf;
+ while(*bp&&isspace(*bp))
+ bp++;
+ /* Is it the good device ? */
+ if(strncmp(bp,ifname,strlen(ifname))==0 && bp[strlen(ifname)]==':')
+ {
+ /* Skip ethX: */
+ bp=strchr(bp,':');
+ bp++;
+ /* -- status -- */
+ bp = strtok(bp, " ");
+ sscanf(bp, "%X", &t);
+ stats->status = (unsigned short) t;
+ /* -- link quality -- */
+ bp = strtok(NULL, " ");
+ if(strchr(bp,'.') != NULL)
+ stats->qual.updated |= 1;
+ sscanf(bp, "%d", &t);
+ stats->qual.qual = (unsigned char) t;
+ /* -- signal level -- */
+ bp = strtok(NULL, " ");
+ if(strchr(bp,'.') != NULL)
+ stats->qual.updated |= 2;
+ sscanf(bp, "%d", &t);
+ stats->qual.level = (unsigned char) t;
+ /* -- noise level -- */
+ bp = strtok(NULL, " ");
+ if(strchr(bp,'.') != NULL)
+ stats->qual.updated += 4;
+ sscanf(bp, "%d", &t);
+ stats->qual.noise = (unsigned char) t;
+ /* -- discarded packets -- */
+ bp = strtok(NULL, " ");
+ sscanf(bp, "%d", &stats->discard.nwid);
+ bp = strtok(NULL, " ");
+ sscanf(bp, "%d", &stats->discard.code);
+ bp = strtok(NULL, " ");
+ sscanf(bp, "%d", &stats->discard.misc);
+ fclose(f);
+ /* No conversion needed */
+ return 0;
+ }
+ }
+ fclose(f);
+ return -1;
+ }
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Output the link statistics, taking care of formating
+ */
+void
+iw_print_stats(char * buffer,
+ int buflen,
+ const iwqual * qual,
+ const iwrange * range,
+ int has_range)
+{
+ int len;
+
+ /* People are very often confused by the 8 bit arithmetic happening
+ * here.
+ * All the values here are encoded in a 8 bit integer. 8 bit integers
+ * are either unsigned [0 ; 255], signed [-128 ; +127] or
+ * negative [-255 ; 0].
+ * Further, on 8 bits, 0x100 == 256 == 0.
+ *
+ * Relative/percent values are always encoded unsigned, between 0 and 255.
+ * Absolute/dBm values are always encoded between -192 and 63.
+ * (Note that up to version 28 of Wireless Tools, dBm used to be
+ * encoded always negative, between -256 and -1).
+ *
+ * How do we separate relative from absolute values ?
+ * The old way is to use the range to do that. As of WE-19, we have
+ * an explicit IW_QUAL_DBM flag in updated...
+ * The range allow to specify the real min/max of the value. As the
+ * range struct only specify one bound of the value, we assume that
+ * the other bound is 0 (zero).
+ * For relative values, range is [0 ; range->max].
+ * For absolute values, range is [range->max ; 63].
+ *
+ * Let's take two example :
+ * 1) value is 75%. qual->value = 75 ; range->max_qual.value = 100
+ * 2) value is -54dBm. noise floor of the radio is -104dBm.
+ * qual->value = -54 = 202 ; range->max_qual.value = -104 = 152
+ *
+ * Jean II
+ */
+
+ /* Just do it...
+ * The old way to detect dBm require both the range and a non-null
+ * level (which confuse the test). The new way can deal with level of 0
+ * because it does an explicit test on the flag. */
+ if(has_range && ((qual->level != 0)
+ || (qual->updated & (IW_QUAL_DBM | IW_QUAL_RCPI))))
+ {
+ /* Deal with quality : always a relative value */
+ if(!(qual->updated & IW_QUAL_QUAL_INVALID))
+ {
+ len = snprintf(buffer, buflen, "Quality%c%d/%d ",
+ qual->updated & IW_QUAL_QUAL_UPDATED ? '=' : ':',
+ qual->qual, range->max_qual.qual);
+ buffer += len;
+ buflen -= len;
+ }
+
+ /* Check if the statistics are in RCPI (IEEE 802.11k) */
+ if(qual->updated & IW_QUAL_RCPI)
+ {
+ /* Deal with signal level in RCPI */
+ /* RCPI = int{(Power in dBm +110)*2} for 0dbm > Power > -110dBm */
+ if(!(qual->updated & IW_QUAL_LEVEL_INVALID))
+ {
+ double rcpilevel = (qual->level / 2.0) - 110.0;
+ len = snprintf(buffer, buflen, "Signal level%c%g dBm ",
+ qual->updated & IW_QUAL_LEVEL_UPDATED ? '=' : ':',
+ rcpilevel);
+ buffer += len;
+ buflen -= len;
+ }
+
+ /* Deal with noise level in dBm (absolute power measurement) */
+ if(!(qual->updated & IW_QUAL_NOISE_INVALID))
+ {
+ double rcpinoise = (qual->noise / 2.0) - 110.0;
+ len = snprintf(buffer, buflen, "Noise level%c%g dBm",
+ qual->updated & IW_QUAL_NOISE_UPDATED ? '=' : ':',
+ rcpinoise);
+ }
+ }
+ else
+ {
+ /* Check if the statistics are in dBm */
+ if((qual->updated & IW_QUAL_DBM)
+ || (qual->level > range->max_qual.level))
+ {
+ /* Deal with signal level in dBm (absolute power measurement) */
+ if(!(qual->updated & IW_QUAL_LEVEL_INVALID))
+ {
+ int dblevel = qual->level;
+ /* Implement a range for dBm [-192; 63] */
+ if(qual->level >= 64)
+ dblevel -= 0x100;
+ len = snprintf(buffer, buflen, "Signal level%c%d dBm ",
+ qual->updated & IW_QUAL_LEVEL_UPDATED ? '=' : ':',
+ dblevel);
+ buffer += len;
+ buflen -= len;
+ }
+
+ /* Deal with noise level in dBm (absolute power measurement) */
+ if(!(qual->updated & IW_QUAL_NOISE_INVALID))
+ {
+ int dbnoise = qual->noise;
+ /* Implement a range for dBm [-192; 63] */
+ if(qual->noise >= 64)
+ dbnoise -= 0x100;
+ len = snprintf(buffer, buflen, "Noise level%c%d dBm",
+ qual->updated & IW_QUAL_NOISE_UPDATED ? '=' : ':',
+ dbnoise);
+ }
+ }
+ else
+ {
+ /* Deal with signal level as relative value (0 -> max) */
+ if(!(qual->updated & IW_QUAL_LEVEL_INVALID))
+ {
+ len = snprintf(buffer, buflen, "Signal level%c%d/%d ",
+ qual->updated & IW_QUAL_LEVEL_UPDATED ? '=' : ':',
+ qual->level, range->max_qual.level);
+ buffer += len;
+ buflen -= len;
+ }
+
+ /* Deal with noise level as relative value (0 -> max) */
+ if(!(qual->updated & IW_QUAL_NOISE_INVALID))
+ {
+ len = snprintf(buffer, buflen, "Noise level%c%d/%d",
+ qual->updated & IW_QUAL_NOISE_UPDATED ? '=' : ':',
+ qual->noise, range->max_qual.noise);
+ }
+ }
+ }
+ }
+ else
+ {
+ /* We can't read the range, so we don't know... */
+ snprintf(buffer, buflen,
+ "Quality:%d Signal level:%d Noise level:%d",
+ qual->qual, qual->level, qual->noise);
+ }
+}
+
+/*********************** ENCODING SUBROUTINES ***********************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Output the encoding key, with a nice formating
+ */
+void
+iw_print_key(char * buffer,
+ int buflen,
+ const unsigned char * key, /* Must be unsigned */
+ int key_size,
+ int key_flags)
+{
+ int i;
+
+ /* Check buffer size -> 1 bytes => 2 digits + 1/2 separator */
+ if((key_size * 3) > buflen)
+ {
+ snprintf(buffer, buflen, "");
+ return;
+ }
+
+ /* Is the key present ??? */
+ if(key_flags & IW_ENCODE_NOKEY)
+ {
+ /* Nope : print on or dummy */
+ if(key_size <= 0)
+ strcpy(buffer, "on"); /* Size checked */
+ else
+ {
+ strcpy(buffer, "**"); /* Size checked */
+ buffer +=2;
+ for(i = 1; i < key_size; i++)
+ {
+ if((i & 0x1) == 0)
+ strcpy(buffer++, "-"); /* Size checked */
+ strcpy(buffer, "**"); /* Size checked */
+ buffer +=2;
+ }
+ }
+ }
+ else
+ {
+ /* Yes : print the key */
+ sprintf(buffer, "%.2X", key[0]); /* Size checked */
+ buffer +=2;
+ for(i = 1; i < key_size; i++)
+ {
+ if((i & 0x1) == 0)
+ strcpy(buffer++, "-"); /* Size checked */
+ sprintf(buffer, "%.2X", key[i]); /* Size checked */
+ buffer +=2;
+ }
+ }
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Convert a passphrase into a key
+ * ### NOT IMPLEMENTED ###
+ * Return size of the key, or 0 (no key) or -1 (error)
+ */
+static int
+iw_pass_key(const char * input,
+ unsigned char * key)
+{
+ input = input; key = key;
+ fprintf(stderr, "Error: Passphrase not implemented\n");
+ return(-1);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Parse a key from the command line.
+ * Return size of the key, or 0 (no key) or -1 (error)
+ * If the key is too long, it's simply truncated...
+ */
+int
+iw_in_key(const char * input,
+ unsigned char * key)
+{
+ int keylen = 0;
+
+ /* Check the type of key */
+ if(!strncmp(input, "s:", 2))
+ {
+ /* First case : as an ASCII string (Lucent/Agere cards) */
+ keylen = strlen(input + 2); /* skip "s:" */
+ if(keylen > IW_ENCODING_TOKEN_MAX)
+ keylen = IW_ENCODING_TOKEN_MAX;
+ memcpy(key, input + 2, keylen);
+ }
+ else
+ if(!strncmp(input, "p:", 2))
+ {
+ /* Second case : as a passphrase (PrismII cards) */
+ return(iw_pass_key(input + 2, key)); /* skip "p:" */
+ }
+ else
+ {
+ const char * p;
+ int dlen; /* Digits sequence length */
+ unsigned char out[IW_ENCODING_TOKEN_MAX];
+
+ /* Third case : as hexadecimal digits */
+ p = input;
+ dlen = -1;
+
+ /* Loop until we run out of chars in input or overflow the output */
+ while(*p != '\0')
+ {
+ int temph;
+ int templ;
+ int count;
+ /* No more chars in this sequence */
+ if(dlen <= 0)
+ {
+ /* Skip separator */
+ if(dlen == 0)
+ p++;
+ /* Calculate num of char to next separator */
+ dlen = strcspn(p, "-:;.,");
+ }
+ /* Get each char separatly (and not by two) so that we don't
+ * get confused by 'enc' (=> '0E'+'0C') and similar */
+ count = sscanf(p, "%1X%1X", &temph, &templ);
+ if(count < 1)
+ return(-1); /* Error -> non-hex char */
+ /* Fixup odd strings such as '123' is '01'+'23' and not '12'+'03'*/
+ if(dlen % 2)
+ count = 1;
+ /* Put back two chars as one byte and output */
+ if(count == 2)
+ templ |= temph << 4;
+ else
+ templ = temph;
+ out[keylen++] = (unsigned char) (templ & 0xFF);
+ /* Check overflow in output */
+ if(keylen >= IW_ENCODING_TOKEN_MAX)
+ break;
+ /* Move on to next chars */
+ p += count;
+ dlen -= count;
+ }
+ /* We use a temporary output buffer 'out' so that if there is
+ * an error, we don't overwrite the original key buffer.
+ * Because of the way iwconfig loop on multiple key/enc arguments
+ * until it finds an error in here, this is necessary to avoid
+ * silently corrupting the encryption key... */
+ memcpy(key, out, keylen);
+ }
+
+#ifdef DEBUG
+ {
+ char buf[IW_ENCODING_TOKEN_MAX * 3];
+ iw_print_key(buf, sizeof(buf), key, keylen, 0);
+ printf("Got key : %d [%s]\n", keylen, buf);
+ }
+#endif
+
+ return(keylen);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Parse a key from the command line.
+ * Return size of the key, or 0 (no key) or -1 (error)
+ */
+int
+iw_in_key_full(int skfd,
+ const char * ifname,
+ const char * input,
+ unsigned char * key,
+ __u16 * flags)
+{
+ int keylen = 0;
+ char * p;
+
+ if(!strncmp(input, "l:", 2))
+ {
+ struct iw_range range;
+
+ /* Extra case : as a login (user:passwd - Cisco LEAP) */
+ keylen = strlen(input + 2) + 1; /* skip "l:", add '\0' */
+ /* Most user/password is 8 char, so 18 char total, < 32 */
+ if(keylen > IW_ENCODING_TOKEN_MAX)
+ keylen = IW_ENCODING_TOKEN_MAX;
+ memcpy(key, input + 2, keylen);
+
+ /* Separate the two strings */
+ p = strchr((char *) key, ':');
+ if(p == NULL)
+ {
+ fprintf(stderr, "Error: Invalid login format\n");
+ return(-1);
+ }
+ *p = '\0';
+
+ /* Extract range info */
+ if(iw_get_range_info(skfd, ifname, &range) < 0)
+ /* Hum... Maybe we should return an error ??? */
+ memset(&range, 0, sizeof(range));
+
+ if(range.we_version_compiled > 15)
+ {
+
+ printf("flags = %X, index = %X\n",
+ *flags, range.encoding_login_index);
+ if((*flags & IW_ENCODE_INDEX) == 0)
+ {
+ /* Extract range info */
+ if(iw_get_range_info(skfd, ifname, &range) < 0)
+ memset(&range, 0, sizeof(range));
+ printf("flags = %X, index = %X\n", *flags, range.encoding_login_index);
+ /* Set the index the driver expects */
+ *flags |= range.encoding_login_index & IW_ENCODE_INDEX;
+ }
+ printf("flags = %X, index = %X\n", *flags, range.encoding_login_index);
+ }
+ }
+ else
+ /* Simpler routine above */
+ keylen = iw_in_key(input, key);
+
+ return(keylen);
+}
+
+/******************* POWER MANAGEMENT SUBROUTINES *******************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Output a power management value with all attributes...
+ */
+void
+iw_print_pm_value(char * buffer,
+ int buflen,
+ int value,
+ int flags,
+ int we_version)
+{
+ /* Check size */
+ if(buflen < 25)
+ {
+ snprintf(buffer, buflen, "");
+ return;
+ }
+ buflen -= 25;
+
+ /* Modifiers */
+ if(flags & IW_POWER_MIN)
+ {
+ strcpy(buffer, " min"); /* Size checked */
+ buffer += 4;
+ }
+ if(flags & IW_POWER_MAX)
+ {
+ strcpy(buffer, " max"); /* Size checked */
+ buffer += 4;
+ }
+
+ /* Type */
+ if(flags & IW_POWER_TIMEOUT)
+ {
+ strcpy(buffer, " timeout:"); /* Size checked */
+ buffer += 9;
+ }
+ else
+ {
+ if(flags & IW_POWER_SAVING)
+ {
+ strcpy(buffer, " saving:"); /* Size checked */
+ buffer += 8;
+ }
+ else
+ {
+ strcpy(buffer, " period:"); /* Size checked */
+ buffer += 8;
+ }
+ }
+
+ /* Display value without units */
+ if(flags & IW_POWER_RELATIVE)
+ {
+ if(we_version < 21)
+ value /= MEGA;
+ snprintf(buffer, buflen, "%d", value);
+ }
+ else
+ {
+ /* Display value with units */
+ if(value >= (int) MEGA)
+ snprintf(buffer, buflen, "%gs", ((double) value) / MEGA);
+ else
+ if(value >= (int) KILO)
+ snprintf(buffer, buflen, "%gms", ((double) value) / KILO);
+ else
+ snprintf(buffer, buflen, "%dus", value);
+ }
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Output a power management mode
+ */
+void
+iw_print_pm_mode(char * buffer,
+ int buflen,
+ int flags)
+{
+ /* Check size */
+ if(buflen < 28)
+ {
+ snprintf(buffer, buflen, "");
+ return;
+ }
+
+ /* Print the proper mode... */
+ switch(flags & IW_POWER_MODE)
+ {
+ case IW_POWER_UNICAST_R:
+ strcpy(buffer, "mode:Unicast only received"); /* Size checked */
+ break;
+ case IW_POWER_MULTICAST_R:
+ strcpy(buffer, "mode:Multicast only received"); /* Size checked */
+ break;
+ case IW_POWER_ALL_R:
+ strcpy(buffer, "mode:All packets received"); /* Size checked */
+ break;
+ case IW_POWER_FORCE_S:
+ strcpy(buffer, "mode:Force sending"); /* Size checked */
+ break;
+ case IW_POWER_REPEATER:
+ strcpy(buffer, "mode:Repeat multicasts"); /* Size checked */
+ break;
+ default:
+ strcpy(buffer, ""); /* Size checked */
+ break;
+ }
+}
+
+/***************** RETRY LIMIT/LIFETIME SUBROUTINES *****************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Output a retry value with all attributes...
+ */
+void
+iw_print_retry_value(char * buffer,
+ int buflen,
+ int value,
+ int flags,
+ int we_version)
+{
+ /* Check buffer size */
+ if(buflen < 20)
+ {
+ snprintf(buffer, buflen, "");
+ return;
+ }
+ buflen -= 20;
+
+ /* Modifiers */
+ if(flags & IW_RETRY_MIN)
+ {
+ strcpy(buffer, " min"); /* Size checked */
+ buffer += 4;
+ }
+ if(flags & IW_RETRY_MAX)
+ {
+ strcpy(buffer, " max"); /* Size checked */
+ buffer += 4;
+ }
+ if(flags & IW_RETRY_SHORT)
+ {
+ strcpy(buffer, " short"); /* Size checked */
+ buffer += 6;
+ }
+ if(flags & IW_RETRY_LONG)
+ {
+ strcpy(buffer, " long"); /* Size checked */
+ buffer += 6;
+ }
+
+ /* Type lifetime of limit */
+ if(flags & IW_RETRY_LIFETIME)
+ {
+ strcpy(buffer, " lifetime:"); /* Size checked */
+ buffer += 10;
+
+ /* Display value without units */
+ if(flags & IW_RETRY_RELATIVE)
+ {
+ if(we_version < 21)
+ value /= MEGA;
+ snprintf(buffer, buflen, "%d", value);
+ }
+ else
+ {
+ /* Display value with units */
+ if(value >= (int) MEGA)
+ snprintf(buffer, buflen, "%gs", ((double) value) / MEGA);
+ else
+ if(value >= (int) KILO)
+ snprintf(buffer, buflen, "%gms", ((double) value) / KILO);
+ else
+ snprintf(buffer, buflen, "%dus", value);
+ }
+ }
+ else
+ snprintf(buffer, buflen, " limit:%d", value);
+}
+
+/************************* TIME SUBROUTINES *************************/
+
+/*------------------------------------------------------------------*/
+/*
+ * Print timestamps
+ * Inspired from irdadump...
+ */
+void
+iw_print_timeval(char * buffer,
+ int buflen,
+ const struct timeval * timev,
+ const struct timezone * tz)
+{
+ int s;
+
+ s = (timev->tv_sec - tz->tz_minuteswest * 60) % 86400;
+ snprintf(buffer, buflen, "%02d:%02d:%02d.%06u",
+ s / 3600, (s % 3600) / 60,
+ s % 60, (u_int32_t) timev->tv_usec);
+}
+
+/*********************** ADDRESS SUBROUTINES ************************/
+/*
+ * This section is mostly a cut & past from net-tools-1.2.0
+ * (Well... This has evolved over the years)
+ * manage address display and input...
+ */
+
+/*------------------------------------------------------------------*/
+/*
+ * Check if interface support the right MAC address type...
+ */
+int
+iw_check_mac_addr_type(int skfd,
+ const char * ifname)
+{
+ struct ifreq ifr;
+
+ /* Get the type of hardware address */
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ if((ioctl(skfd, SIOCGIFHWADDR, &ifr) < 0) ||
+ ((ifr.ifr_hwaddr.sa_family != ARPHRD_ETHER)
+ && (ifr.ifr_hwaddr.sa_family != ARPHRD_IEEE80211)))
+ {
+ /* Deep trouble... */
+ fprintf(stderr, "Interface %s doesn't support MAC addresses\n",
+ ifname);
+ return(-1);
+ }
+
+#ifdef DEBUG
+ {
+ char buf[20];
+ printf("Hardware : %d - %s\n", ifr.ifr_hwaddr.sa_family,
+ iw_saether_ntop(&ifr.ifr_hwaddr, buf));
+ }
+#endif
+
+ return(0);
+}
+
+
+/*------------------------------------------------------------------*/
+/*
+ * Check if interface support the right interface address type...
+ */
+int
+iw_check_if_addr_type(int skfd,
+ const char * ifname)
+{
+ struct ifreq ifr;
+
+ /* Get the type of interface address */
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ if((ioctl(skfd, SIOCGIFADDR, &ifr) < 0) ||
+ (ifr.ifr_addr.sa_family != AF_INET))
+ {
+ /* Deep trouble... */
+ fprintf(stderr, "Interface %s doesn't support IP addresses\n", ifname);
+ return(-1);
+ }
+
+#ifdef DEBUG
+ printf("Interface : %d - 0x%lX\n", ifr.ifr_addr.sa_family,
+ *((unsigned long *) ifr.ifr_addr.sa_data));
+#endif
+
+ return(0);
+}
+
+#if 0
+/*------------------------------------------------------------------*/
+/*
+ * Check if interface support the right address types...
+ */
+int
+iw_check_addr_type(int skfd,
+ char * ifname)
+{
+ /* Check the interface address type */
+ if(iw_check_if_addr_type(skfd, ifname) < 0)
+ return(-1);
+
+ /* Check the interface address type */
+ if(iw_check_mac_addr_type(skfd, ifname) < 0)
+ return(-1);
+
+ return(0);
+}
+#endif
+
+#if 0
+/*------------------------------------------------------------------*/
+/*
+ * Ask the kernel for the MAC address of an interface.
+ */
+int
+iw_get_mac_addr(int skfd,
+ const char * ifname,
+ struct ether_addr * eth,
+ unsigned short * ptype)
+{
+ struct ifreq ifr;
+ int ret;
+
+ /* Prepare request */
+ bzero(&ifr, sizeof(struct ifreq));
+ strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+
+ /* Do it */
+ ret = ioctl(skfd, SIOCGIFHWADDR, &ifr);
+
+ memcpy(eth->ether_addr_octet, ifr.ifr_hwaddr.sa_data, 6);
+ *ptype = ifr.ifr_hwaddr.sa_family;
+ return(ret);
+}
+#endif
+
+/*------------------------------------------------------------------*/
+/*
+ * Display an arbitrary length MAC address in readable format.
+ */
+char *
+iw_mac_ntop(const unsigned char * mac,
+ int maclen,
+ char * buf,
+ int buflen)
+{
+ int i;
+
+ /* Overflow check (don't forget '\0') */
+ if(buflen < (maclen * 3 - 1 + 1))
+ return(NULL);
+
+ /* First byte */
+ sprintf(buf, "%02X", mac[0]);
+
+ /* Other bytes */
+ for(i = 1; i < maclen; i++)
+ sprintf(buf + (i * 3) - 1, ":%02X", mac[i]);
+ return(buf);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Display an Ethernet address in readable format.
+ */
+void
+iw_ether_ntop(const struct ether_addr * eth,
+ char * buf)
+{
+ sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
+ eth->ether_addr_octet[0], eth->ether_addr_octet[1],
+ eth->ether_addr_octet[2], eth->ether_addr_octet[3],
+ eth->ether_addr_octet[4], eth->ether_addr_octet[5]);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Display an Wireless Access Point Socket Address in readable format.
+ * Note : 0x44 is an accident of history, that's what the Orinoco/PrismII
+ * chipset report, and the driver doesn't filter it.
+ */
+char *
+iw_sawap_ntop(const struct sockaddr * sap,
+ char * buf)
+{
+ const struct ether_addr ether_zero = {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }};
+ const struct ether_addr ether_bcast = {{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }};
+ const struct ether_addr ether_hack = {{ 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }};
+ const struct ether_addr * ether_wap = (const struct ether_addr *) sap->sa_data;
+
+ if(!iw_ether_cmp(ether_wap, ðer_zero))
+ sprintf(buf, "Not-Associated");
+ else
+ if(!iw_ether_cmp(ether_wap, ðer_bcast))
+ sprintf(buf, "Invalid");
+ else
+ if(!iw_ether_cmp(ether_wap, ðer_hack))
+ sprintf(buf, "None");
+ else
+ iw_ether_ntop(ether_wap, buf);
+ return(buf);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Input an arbitrary length MAC address and convert to binary.
+ * Return address size.
+ */
+int
+iw_mac_aton(const char * orig,
+ unsigned char * mac,
+ int macmax)
+{
+ const char * p = orig;
+ int maclen = 0;
+
+ /* Loop on all bytes of the string */
+ while(*p != '\0')
+ {
+ int temph;
+ int templ;
+ int count;
+ /* Extract one byte as two chars */
+ count = sscanf(p, "%1X%1X", &temph, &templ);
+ if(count != 2)
+ break; /* Error -> non-hex chars */
+ /* Output two chars as one byte */
+ templ |= temph << 4;
+ mac[maclen++] = (unsigned char) (templ & 0xFF);
+
+ /* Check end of string */
+ p += 2;
+ if(*p == '\0')
+ {
+#ifdef DEBUG
+ char buf[20];
+ iw_ether_ntop((const struct ether_addr *) mac, buf);
+ fprintf(stderr, "iw_mac_aton(%s): %s\n", orig, buf);
+#endif
+ return(maclen); /* Normal exit */
+ }
+
+ /* Check overflow */
+ if(maclen >= macmax)
+ {
+#ifdef DEBUG
+ fprintf(stderr, "iw_mac_aton(%s): trailing junk!\n", orig);
+#endif
+ errno = E2BIG;
+ return(0); /* Error -> overflow */
+ }
+
+ /* Check separator */
+ if(*p != ':')
+ break;
+ p++;
+ }
+
+ /* Error... */
+#ifdef DEBUG
+ fprintf(stderr, "iw_mac_aton(%s): invalid ether address!\n", orig);
+#endif
+ errno = EINVAL;
+ return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Input an Ethernet address and convert to binary.
+ */
+int
+iw_ether_aton(const char *orig, struct ether_addr *eth)
+{
+ int maclen;
+ maclen = iw_mac_aton(orig, (unsigned char *) eth, ETH_ALEN);
+ if((maclen > 0) && (maclen < ETH_ALEN))
+ {
+ errno = EINVAL;
+ maclen = 0;
+ }
+ return(maclen);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Input an Internet address and convert to binary.
+ */
+int
+iw_in_inet(char *name, struct sockaddr *sap)
+{
+ struct hostent *hp;
+ struct netent *np;
+ struct sockaddr_in *sain = (struct sockaddr_in *) sap;
+
+ /* Grmpf. -FvK */
+ sain->sin_family = AF_INET;
+ sain->sin_port = 0;
+
+ /* Default is special, meaning 0.0.0.0. */
+ if (!strcmp(name, "default")) {
+ sain->sin_addr.s_addr = INADDR_ANY;
+ return(1);
+ }
+
+ /* Try the NETWORKS database to see if this is a known network. */
+ if ((np = getnetbyname(name)) != (struct netent *)NULL) {
+ sain->sin_addr.s_addr = htonl(np->n_net);
+ strcpy(name, np->n_name);
+ return(1);
+ }
+
+ /* Always use the resolver (DNS name + IP addresses) */
+ if ((hp = gethostbyname(name)) == (struct hostent *)NULL) {
+ errno = h_errno;
+ return(-1);
+ }
+ memcpy((char *) &sain->sin_addr, (char *) hp->h_addr_list[0], hp->h_length);
+ strcpy(name, hp->h_name);
+ return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Input an address and convert to binary.
+ */
+int
+iw_in_addr(int skfd,
+ const char * ifname,
+ char * bufp,
+ struct sockaddr *sap)
+{
+ /* Check if it is a hardware or IP address */
+ if(strchr(bufp, ':') == NULL)
+ {
+ struct sockaddr if_address;
+ struct arpreq arp_query;
+
+ /* Check if we have valid interface address type */
+ if(iw_check_if_addr_type(skfd, ifname) < 0)
+ {
+ fprintf(stderr, "%-8.16s Interface doesn't support IP addresses\n", ifname);
+ return(-1);
+ }
+
+ /* Read interface address */
+ if(iw_in_inet(bufp, &if_address) < 0)
+ {
+ fprintf(stderr, "Invalid interface address %s\n", bufp);
+ return(-1);
+ }
+
+ /* Translate IP addresses to MAC addresses */
+ memcpy((char *) &(arp_query.arp_pa),
+ (char *) &if_address,
+ sizeof(struct sockaddr));
+ arp_query.arp_ha.sa_family = 0;
+ arp_query.arp_flags = 0;
+ /* The following restrict the search to the interface only */
+ /* For old kernels which complain, just comment it... */
+ strncpy(arp_query.arp_dev, ifname, IFNAMSIZ);
+ if((ioctl(skfd, SIOCGARP, &arp_query) < 0) ||
+ !(arp_query.arp_flags & ATF_COM))
+ {
+ fprintf(stderr, "Arp failed for %s on %s... (%d)\nTry to ping the address before setting it.\n",
+ bufp, ifname, errno);
+ return(-1);
+ }
+
+ /* Store new MAC address */
+ memcpy((char *) sap,
+ (char *) &(arp_query.arp_ha),
+ sizeof(struct sockaddr));
+
+#ifdef DEBUG
+ {
+ char buf[20];
+ printf("IP Address %s => Hw Address = %s\n",
+ bufp, iw_saether_ntop(sap, buf));
+ }
+#endif
+ }
+ else /* If it's an hardware address */
+ {
+ /* Check if we have valid mac address type */
+ if(iw_check_mac_addr_type(skfd, ifname) < 0)
+ {
+ fprintf(stderr, "%-8.16s Interface doesn't support MAC addresses\n", ifname);
+ return(-1);
+ }
+
+ /* Get the hardware address */
+ if(iw_saether_aton(bufp, sap) == 0)
+ {
+ fprintf(stderr, "Invalid hardware address %s\n", bufp);
+ return(-1);
+ }
+ }
+
+#ifdef DEBUG
+ {
+ char buf[20];
+ printf("Hw Address = %s\n", iw_saether_ntop(sap, buf));
+ }
+#endif
+
+ return(0);
+}
+
+/************************* MISC SUBROUTINES **************************/
+
+/* Size (in bytes) of various events */
+static const int priv_type_size[] = {
+ 0, /* IW_PRIV_TYPE_NONE */
+ 1, /* IW_PRIV_TYPE_BYTE */
+ 1, /* IW_PRIV_TYPE_CHAR */
+ 0, /* Not defined */
+ sizeof(__u32), /* IW_PRIV_TYPE_INT */
+ sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */
+ sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */
+ 0, /* Not defined */
+};
+
+/*------------------------------------------------------------------*/
+/*
+ * Max size in bytes of an private argument.
+ */
+int
+iw_get_priv_size(int args)
+{
+ int num = args & IW_PRIV_SIZE_MASK;
+ int type = (args & IW_PRIV_TYPE_MASK) >> 12;
+
+ return(num * priv_type_size[type]);
+}
+
+/************************ EVENT SUBROUTINES ************************/
+/*
+ * The Wireless Extension API 14 and greater define Wireless Events,
+ * that are used for various events and scanning.
+ * Those functions help the decoding of events, so are needed only in
+ * this case.
+ */
+
+/* -------------------------- CONSTANTS -------------------------- */
+
+/* Type of headers we know about (basically union iwreq_data) */
+#define IW_HEADER_TYPE_NULL 0 /* Not available */
+#define IW_HEADER_TYPE_CHAR 2 /* char [IFNAMSIZ] */
+#define IW_HEADER_TYPE_UINT 4 /* __u32 */
+#define IW_HEADER_TYPE_FREQ 5 /* struct iw_freq */
+#define IW_HEADER_TYPE_ADDR 6 /* struct sockaddr */
+#define IW_HEADER_TYPE_POINT 8 /* struct iw_point */
+#define IW_HEADER_TYPE_PARAM 9 /* struct iw_param */
+#define IW_HEADER_TYPE_QUAL 10 /* struct iw_quality */
+
+/* Handling flags */
+/* Most are not implemented. I just use them as a reminder of some
+ * cool features we might need one day ;-) */
+#define IW_DESCR_FLAG_NONE 0x0000 /* Obvious */
+/* Wrapper level flags */
+#define IW_DESCR_FLAG_DUMP 0x0001 /* Not part of the dump command */
+#define IW_DESCR_FLAG_EVENT 0x0002 /* Generate an event on SET */
+#define IW_DESCR_FLAG_RESTRICT 0x0004 /* GET : request is ROOT only */
+ /* SET : Omit payload from generated iwevent */
+#define IW_DESCR_FLAG_NOMAX 0x0008 /* GET : no limit on request size */
+/* Driver level flags */
+#define IW_DESCR_FLAG_WAIT 0x0100 /* Wait for driver event */
+
+/* ---------------------------- TYPES ---------------------------- */
+
+/*
+ * Describe how a standard IOCTL looks like.
+ */
+struct iw_ioctl_description
+{
+ __u8 header_type; /* NULL, iw_point or other */
+ __u8 token_type; /* Future */
+ __u16 token_size; /* Granularity of payload */
+ __u16 min_tokens; /* Min acceptable token number */
+ __u16 max_tokens; /* Max acceptable token number */
+ __u32 flags; /* Special handling of the request */
+};
+
+/* -------------------------- VARIABLES -------------------------- */
+
+/*
+ * Meta-data about all the standard Wireless Extension request we
+ * know about.
+ */
+static const struct iw_ioctl_description standard_ioctl_descr[] = {
+ [SIOCSIWCOMMIT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWNAME - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_CHAR,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWNWID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWNWID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWFREQ - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_FREQ,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWFREQ - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_FREQ,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWMODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_UINT,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWMODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_UINT,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWSENS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWSENS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRANGE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWRANGE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_range),
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWPRIV - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWPRIV - SIOCIWFIRST] = { /* (handled directly by us) */
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCSIWSTATS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_NULL,
+ },
+ [SIOCGIWSTATS - SIOCIWFIRST] = { /* (handled directly by us) */
+ .header_type = IW_HEADER_TYPE_NULL,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr),
+ .max_tokens = IW_MAX_SPY,
+ },
+ [SIOCGIWSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr) +
+ sizeof(struct iw_quality),
+ .max_tokens = IW_MAX_SPY,
+ },
+ [SIOCSIWTHRSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct iw_thrspy),
+ .min_tokens = 1,
+ .max_tokens = 1,
+ },
+ [SIOCGIWTHRSPY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct iw_thrspy),
+ .min_tokens = 1,
+ .max_tokens = 1,
+ },
+ [SIOCSIWAP - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [SIOCGIWAP - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWMLME - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_mlme),
+ .max_tokens = sizeof(struct iw_mlme),
+ },
+ [SIOCGIWAPLIST - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct sockaddr) +
+ sizeof(struct iw_quality),
+ .max_tokens = IW_MAX_AP,
+ .flags = IW_DESCR_FLAG_NOMAX,
+ },
+ [SIOCSIWSCAN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = 0,
+ .max_tokens = sizeof(struct iw_scan_req),
+ },
+ [SIOCGIWSCAN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_SCAN_MAX_DATA,
+ .flags = IW_DESCR_FLAG_NOMAX,
+ },
+ [SIOCSIWESSID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ .flags = IW_DESCR_FLAG_EVENT,
+ },
+ [SIOCGIWESSID - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ .flags = IW_DESCR_FLAG_DUMP,
+ },
+ [SIOCSIWNICKN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ },
+ [SIOCGIWNICKN - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ESSID_MAX_SIZE + 1,
+ },
+ [SIOCSIWRATE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRATE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRTS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRTS - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWFRAG - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWFRAG - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWTXPOW - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWTXPOW - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWRETRY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWRETRY - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWENCODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ENCODING_TOKEN_MAX,
+ .flags = IW_DESCR_FLAG_EVENT | IW_DESCR_FLAG_RESTRICT,
+ },
+ [SIOCGIWENCODE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_ENCODING_TOKEN_MAX,
+ .flags = IW_DESCR_FLAG_DUMP | IW_DESCR_FLAG_RESTRICT,
+ },
+ [SIOCSIWPOWER - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWPOWER - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWMODUL - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWMODUL - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWGENIE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [SIOCGIWGENIE - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [SIOCSIWAUTH - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCGIWAUTH - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_PARAM,
+ },
+ [SIOCSIWENCODEEXT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_encode_ext),
+ .max_tokens = sizeof(struct iw_encode_ext) +
+ IW_ENCODING_TOKEN_MAX,
+ },
+ [SIOCGIWENCODEEXT - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_encode_ext),
+ .max_tokens = sizeof(struct iw_encode_ext) +
+ IW_ENCODING_TOKEN_MAX,
+ },
+ [SIOCSIWPMKSA - SIOCIWFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .min_tokens = sizeof(struct iw_pmksa),
+ .max_tokens = sizeof(struct iw_pmksa),
+ },
+};
+static const unsigned int standard_ioctl_num = (sizeof(standard_ioctl_descr) /
+ sizeof(struct iw_ioctl_description));
+
+/*
+ * Meta-data about all the additional standard Wireless Extension events
+ * we know about.
+ */
+static const struct iw_ioctl_description standard_event_descr[] = {
+ [IWEVTXDROP - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVQUAL - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_QUAL,
+ },
+ [IWEVCUSTOM - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_CUSTOM_MAX,
+ },
+ [IWEVREGISTERED - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVEXPIRED - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_ADDR,
+ },
+ [IWEVGENIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVMICHAELMICFAILURE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_michaelmicfailure),
+ },
+ [IWEVASSOCREQIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVASSOCRESPIE - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = IW_GENERIC_IE_MAX,
+ },
+ [IWEVPMKIDCAND - IWEVFIRST] = {
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_pmkid_cand),
+ },
+};
+static const unsigned int standard_event_num = (sizeof(standard_event_descr) /
+ sizeof(struct iw_ioctl_description));
+
+/* Size (in bytes) of various events */
+static const int event_type_size[] = {
+ IW_EV_LCP_PK_LEN, /* IW_HEADER_TYPE_NULL */
+ 0,
+ IW_EV_CHAR_PK_LEN, /* IW_HEADER_TYPE_CHAR */
+ 0,
+ IW_EV_UINT_PK_LEN, /* IW_HEADER_TYPE_UINT */
+ IW_EV_FREQ_PK_LEN, /* IW_HEADER_TYPE_FREQ */
+ IW_EV_ADDR_PK_LEN, /* IW_HEADER_TYPE_ADDR */
+ 0,
+ IW_EV_POINT_PK_LEN, /* Without variable payload */
+ IW_EV_PARAM_PK_LEN, /* IW_HEADER_TYPE_PARAM */
+ IW_EV_QUAL_PK_LEN, /* IW_HEADER_TYPE_QUAL */
+};
+
+/*------------------------------------------------------------------*/
+/*
+ * Initialise the struct stream_descr so that we can extract
+ * individual events from the event stream.
+ */
+void
+iw_init_event_stream(struct stream_descr * stream, /* Stream of events */
+ char * data,
+ int len)
+{
+ /* Cleanup */
+ memset((char *) stream, '\0', sizeof(struct stream_descr));
+
+ /* Set things up */
+ stream->current = data;
+ stream->end = data + len;
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Extract the next event from the event stream.
+ */
+int
+iw_extract_event_stream(struct stream_descr * stream, /* Stream of events */
+ struct iw_event * iwe, /* Extracted event */
+ int we_version)
+{
+ const struct iw_ioctl_description * descr = NULL;
+ int event_type = 0;
+ unsigned int event_len = 1; /* Invalid */
+ char * pointer;
+ /* Don't "optimise" the following variable, it will crash */
+ unsigned cmd_index; /* *MUST* be unsigned */
+
+ /* Check for end of stream */
+ if((stream->current + IW_EV_LCP_PK_LEN) > stream->end)
+ return(0);
+
+#ifdef DEBUG
+ printf("DBG - stream->current = %p, stream->value = %p, stream->end = %p\n",
+ stream->current, stream->value, stream->end);
+#endif
+
+ /* Extract the event header (to get the event id).
+ * Note : the event may be unaligned, therefore copy... */
+ memcpy((char *) iwe, stream->current, IW_EV_LCP_PK_LEN);
+
+#ifdef DEBUG
+ printf("DBG - iwe->cmd = 0x%X, iwe->len = %d\n",
+ iwe->cmd, iwe->len);
+#endif
+
+ /* Check invalid events */
+ if(iwe->len <= IW_EV_LCP_PK_LEN)
+ return(-1);
+
+ /* Get the type and length of that event */
+ if(iwe->cmd <= SIOCIWLAST)
+ {
+ cmd_index = iwe->cmd - SIOCIWFIRST;
+ if(cmd_index < standard_ioctl_num)
+ descr = &(standard_ioctl_descr[cmd_index]);
+ }
+ else
+ {
+ cmd_index = iwe->cmd - IWEVFIRST;
+ if(cmd_index < standard_event_num)
+ descr = &(standard_event_descr[cmd_index]);
+ }
+ if(descr != NULL)
+ event_type = descr->header_type;
+ /* Unknown events -> event_type=0 => IW_EV_LCP_PK_LEN */
+ event_len = event_type_size[event_type];
+ /* Fixup for earlier version of WE */
+ if((we_version <= 18) && (event_type == IW_HEADER_TYPE_POINT))
+ event_len += IW_EV_POINT_OFF;
+
+ /* Check if we know about this event */
+ if(event_len <= IW_EV_LCP_PK_LEN)
+ {
+ /* Skip to next event */
+ stream->current += iwe->len;
+ return(2);
+ }
+ event_len -= IW_EV_LCP_PK_LEN;
+
+ /* Set pointer on data */
+ if(stream->value != NULL)
+ pointer = stream->value; /* Next value in event */
+ else
+ pointer = stream->current + IW_EV_LCP_PK_LEN; /* First value in event */
+
+#ifdef DEBUG
+ printf("DBG - event_type = %d, event_len = %d, pointer = %p\n",
+ event_type, event_len, pointer);
+#endif
+
+ /* Copy the rest of the event (at least, fixed part) */
+ if((pointer + event_len) > stream->end)
+ {
+ /* Go to next event */
+ stream->current += iwe->len;
+ return(-2);
+ }
+ /* Fixup for WE-19 and later : pointer no longer in the stream */
+ /* Beware of alignement. Dest has local alignement, not packed */
+ if((we_version > 18) && (event_type == IW_HEADER_TYPE_POINT))
+ memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
+ pointer, event_len);
+ else
+ memcpy((char *) iwe + IW_EV_LCP_LEN, pointer, event_len);
+
+ /* Skip event in the stream */
+ pointer += event_len;
+
+ /* Special processing for iw_point events */
+ if(event_type == IW_HEADER_TYPE_POINT)
+ {
+ /* Check the length of the payload */
+ unsigned int extra_len = iwe->len - (event_len + IW_EV_LCP_PK_LEN);
+ if(extra_len > 0)
+ {
+ /* Set pointer on variable part (warning : non aligned) */
+ iwe->u.data.pointer = pointer;
+
+ /* Check that we have a descriptor for the command */
+ if(descr == NULL)
+ /* Can't check payload -> unsafe... */
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+ else
+ {
+ /* Those checks are actually pretty hard to trigger,
+ * because of the checks done in the kernel... */
+
+ unsigned int token_len = iwe->u.data.length * descr->token_size;
+
+ /* Ugly fixup for alignement issues.
+ * If the kernel is 64 bits and userspace 32 bits,
+ * we have an extra 4+4 bytes.
+ * Fixing that in the kernel would break 64 bits userspace. */
+ if((token_len != extra_len) && (extra_len >= 4))
+ {
+ __u16 alt_dlen = *((__u16 *) pointer);
+ unsigned int alt_token_len = alt_dlen * descr->token_size;
+ if((alt_token_len + 8) == extra_len)
+ {
+#ifdef DEBUG
+ printf("DBG - alt_token_len = %d\n", alt_token_len);
+#endif
+ /* Ok, let's redo everything */
+ pointer -= event_len;
+ pointer += 4;
+ /* Dest has local alignement, not packed */
+ memcpy((char *) iwe + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
+ pointer, event_len);
+ pointer += event_len + 4;
+ iwe->u.data.pointer = pointer;
+ token_len = alt_token_len;
+ }
+ }
+
+ /* Discard bogus events which advertise more tokens than
+ * what they carry... */
+ if(token_len > extra_len)
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+ /* Check that the advertised token size is not going to
+ * produce buffer overflow to our caller... */
+ if((iwe->u.data.length > descr->max_tokens)
+ && !(descr->flags & IW_DESCR_FLAG_NOMAX))
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+ /* Same for underflows... */
+ if(iwe->u.data.length < descr->min_tokens)
+ iwe->u.data.pointer = NULL; /* Discard paylod */
+#ifdef DEBUG
+ printf("DBG - extra_len = %d, token_len = %d, token = %d, max = %d, min = %d\n",
+ extra_len, token_len, iwe->u.data.length, descr->max_tokens, descr->min_tokens);
+#endif
+ }
+ }
+ else
+ /* No data */
+ iwe->u.data.pointer = NULL;
+
+ /* Go to next event */
+ stream->current += iwe->len;
+ }
+ else
+ {
+ /* Ugly fixup for alignement issues.
+ * If the kernel is 64 bits and userspace 32 bits,
+ * we have an extra 4 bytes.
+ * Fixing that in the kernel would break 64 bits userspace. */
+ if((stream->value == NULL)
+ && ((((iwe->len - IW_EV_LCP_PK_LEN) % event_len) == 4)
+ || ((iwe->len == 12) && ((event_type == IW_HEADER_TYPE_UINT) ||
+ (event_type == IW_HEADER_TYPE_QUAL))) ))
+ {
+#ifdef DEBUG
+ printf("DBG - alt iwe->len = %d\n", iwe->len - 4);
+#endif
+ pointer -= event_len;
+ pointer += 4;
+ /* Beware of alignement. Dest has local alignement, not packed */
+ memcpy((char *) iwe + IW_EV_LCP_LEN, pointer, event_len);
+ pointer += event_len;
+ }
+
+ /* Is there more value in the event ? */
+ if((pointer + event_len) <= (stream->current + iwe->len))
+ /* Go to next value */
+ stream->value = pointer;
+ else
+ {
+ /* Go to next event */
+ stream->value = NULL;
+ stream->current += iwe->len;
+ }
+ }
+ return(1);
+}
+
+/*********************** SCANNING SUBROUTINES ***********************/
+/*
+ * The Wireless Extension API 14 and greater define Wireless Scanning.
+ * The normal API is complex, this is an easy API that return
+ * a subset of the scanning results. This should be enough for most
+ * applications that want to use Scanning.
+ * If you want to have use the full/normal API, check iwlist.c...
+ *
+ * Precaution when using scanning :
+ * The scanning operation disable normal network traffic, and therefore
+ * you should not abuse of scan.
+ * The scan need to check the presence of network on other frequencies.
+ * While you are checking those other frequencies, you can *NOT* be on
+ * your normal frequency to listen to normal traffic in the cell.
+ * You need typically in the order of one second to actively probe all
+ * 802.11b channels (do the maths). Some cards may do that in background,
+ * to reply to scan commands faster, but they still have to do it.
+ * Leaving the cell for such an extended period of time is pretty bad.
+ * Any kind of streaming/low latency traffic will be impacted, and the
+ * user will perceive it (easily checked with telnet). People trying to
+ * send traffic to you will retry packets and waste bandwidth. Some
+ * applications may be sensitive to those packet losses in weird ways,
+ * and tracing those weird behavior back to scanning may take time.
+ * If you are in ad-hoc mode, if two nodes scan approx at the same
+ * time, they won't see each other, which may create associations issues.
+ * For those reasons, the scanning activity should be limited to
+ * what's really needed, and continuous scanning is a bad idea.
+ * Jean II
+ */
+
+/*------------------------------------------------------------------*/
+/*
+ * Process/store one element from the scanning results in wireless_scan
+ */
+static inline struct wireless_scan *
+iw_process_scanning_token(struct iw_event * event,
+ struct wireless_scan * wscan)
+{
+ struct wireless_scan * oldwscan;
+
+ /* Now, let's decode the event */
+ switch(event->cmd)
+ {
+ case SIOCGIWAP:
+ /* New cell description. Allocate new cell descriptor, zero it. */
+ oldwscan = wscan;
+ wscan = (struct wireless_scan *) malloc(sizeof(struct wireless_scan));
+ if(wscan == NULL)
+ return(wscan);
+ /* Link at the end of the list */
+ if(oldwscan != NULL)
+ oldwscan->next = wscan;
+
+ /* Reset it */
+ bzero(wscan, sizeof(struct wireless_scan));
+
+ /* Save cell identifier */
+ wscan->has_ap_addr = 1;
+ memcpy(&(wscan->ap_addr), &(event->u.ap_addr), sizeof (sockaddr));
+ break;
+ case SIOCGIWNWID:
+ wscan->b.has_nwid = 1;
+ memcpy(&(wscan->b.nwid), &(event->u.nwid), sizeof(iwparam));
+ break;
+ case SIOCGIWFREQ:
+ wscan->b.has_freq = 1;
+ wscan->b.freq = iw_freq2float(&(event->u.freq));
+ wscan->b.freq_flags = event->u.freq.flags;
+ break;
+ case SIOCGIWMODE:
+ wscan->b.mode = event->u.mode;
+ if((wscan->b.mode < IW_NUM_OPER_MODE) && (wscan->b.mode >= 0))
+ wscan->b.has_mode = 1;
+ break;
+ case SIOCGIWESSID:
+ wscan->b.has_essid = 1;
+ wscan->b.essid_on = event->u.data.flags;
+ memset(wscan->b.essid, '\0', IW_ESSID_MAX_SIZE+1);
+ if((event->u.essid.pointer) && (event->u.essid.length))
+ memcpy(wscan->b.essid, event->u.essid.pointer, event->u.essid.length);
+ break;
+ case SIOCGIWENCODE:
+ wscan->b.has_key = 1;
+ wscan->b.key_size = event->u.data.length;
+ wscan->b.key_flags = event->u.data.flags;
+ if(event->u.data.pointer)
+ memcpy(wscan->b.key, event->u.essid.pointer, event->u.data.length);
+ else
+ wscan->b.key_flags |= IW_ENCODE_NOKEY;
+ break;
+ case IWEVQUAL:
+ /* We don't get complete stats, only qual */
+ wscan->has_stats = 1;
+ memcpy(&wscan->stats.qual, &event->u.qual, sizeof(struct iw_quality));
+ break;
+ case SIOCGIWRATE:
+ /* Scan may return a list of bitrates. As we have space for only
+ * a single bitrate, we only keep the largest one. */
+ if((!wscan->has_maxbitrate) ||
+ (event->u.bitrate.value > wscan->maxbitrate.value))
+ {
+ wscan->has_maxbitrate = 1;
+ memcpy(&(wscan->maxbitrate), &(event->u.bitrate), sizeof(iwparam));
+ }
+ case IWEVCUSTOM:
+ /* How can we deal with those sanely ? Jean II */
+ default:
+ break;
+ } /* switch(event->cmd) */
+
+ return(wscan);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Initiate the scan procedure, and process results.
+ * This is a non-blocking procedure and it will return each time
+ * it would block, returning the amount of time the caller should wait
+ * before calling again.
+ * Return -1 for error, delay to wait for (in ms), or 0 for success.
+ * Error code is in errno
+ */
+int
+iw_process_scan(int skfd,
+ char * ifname,
+ int we_version,
+ wireless_scan_head * context)
+{
+ struct iwreq wrq;
+ unsigned char * buffer = NULL; /* Results */
+ int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */
+ unsigned char * newbuf;
+
+ /* Don't waste too much time on interfaces (150 * 100 = 15s) */
+ context->retry++;
+ if(context->retry > 150)
+ {
+ errno = ETIME;
+ return(-1);
+ }
+
+ /* If we have not yet initiated scanning on the interface */
+ if(context->retry == 1)
+ {
+ /* Initiate Scan */
+ wrq.u.data.pointer = NULL; /* Later */
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = 0;
+ /* Remember that as non-root, we will get an EPERM here */
+ if((iw_set_ext(skfd, ifname, SIOCSIWSCAN, &wrq) < 0)
+ && (errno != EPERM))
+ return(-1);
+ /* Success : now, just wait for event or results */
+ return(250); /* Wait 250 ms */
+ }
+
+ realloc:
+ /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */
+ newbuf = realloc(buffer, buflen);
+ if(newbuf == NULL)
+ {
+ /* man says : If realloc() fails the original block is left untouched */
+ if(buffer)
+ free(buffer);
+ errno = ENOMEM;
+ return(-1);
+ }
+ buffer = newbuf;
+
+ /* Try to read the results */
+ wrq.u.data.pointer = buffer;
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = buflen;
+ if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0)
+ {
+ /* Check if buffer was too small (WE-17 only) */
+ if((errno == E2BIG) && (we_version > 16))
+ {
+ /* Some driver may return very large scan results, either
+ * because there are many cells, or because they have many
+ * large elements in cells (like IWEVCUSTOM). Most will
+ * only need the regular sized buffer. We now use a dynamic
+ * allocation of the buffer to satisfy everybody. Of course,
+ * as we don't know in advance the size of the array, we try
+ * various increasing sizes. Jean II */
+
+ /* Check if the driver gave us any hints. */
+ if(wrq.u.data.length > buflen)
+ buflen = wrq.u.data.length;
+ else
+ buflen *= 2;
+
+ /* Try again */
+ goto realloc;
+ }
+
+ /* Check if results not available yet */
+ if(errno == EAGAIN)
+ {
+ free(buffer);
+ /* Wait for only 100ms from now on */
+ return(100); /* Wait 100 ms */
+ }
+
+ free(buffer);
+ /* Bad error, please don't come back... */
+ return(-1);
+ }
+
+ /* We have the results, process them */
+ if(wrq.u.data.length)
+ {
+ struct iw_event iwe;
+ struct stream_descr stream;
+ struct wireless_scan * wscan = NULL;
+ int ret;
+#ifdef DEBUG
+ /* Debugging code. In theory useless, because it's debugged ;-) */
+ int i;
+ printf("Scan result [%02X", buffer[0]);
+ for(i = 1; i < wrq.u.data.length; i++)
+ printf(":%02X", buffer[i]);
+ printf("]\n");
+#endif
+
+ /* Init */
+ iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length);
+ /* This is dangerous, we may leak user data... */
+ context->result = NULL;
+
+ /* Look every token */
+ do
+ {
+ /* Extract an event and print it */
+ ret = iw_extract_event_stream(&stream, &iwe, we_version);
+ if(ret > 0)
+ {
+ /* Convert to wireless_scan struct */
+ wscan = iw_process_scanning_token(&iwe, wscan);
+ /* Check problems */
+ if(wscan == NULL)
+ {
+ free(buffer);
+ errno = ENOMEM;
+ return(-1);
+ }
+ /* Save head of list */
+ if(context->result == NULL)
+ context->result = wscan;
+ }
+ }
+ while(ret > 0);
+ }
+
+ /* Done with this interface - return success */
+ free(buffer);
+ return(0);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Perform a wireless scan on the specified interface.
+ * This is a blocking procedure and it will when the scan is completed
+ * or when an error occur.
+ *
+ * The scan results are given in a linked list of wireless_scan objects.
+ * The caller *must* free the result himself (by walking the list).
+ * If there is an error, -1 is returned and the error code is available
+ * in errno.
+ *
+ * The parameter we_version can be extracted from the range structure
+ * (range.we_version_compiled - see iw_get_range_info()), or using
+ * iw_get_kernel_we_version(). For performance reason, you should
+ * cache this parameter when possible rather than querying it every time.
+ *
+ * Return -1 for error and 0 for success.
+ */
+int
+iw_scan(int skfd,
+ char * ifname,
+ int we_version,
+ wireless_scan_head * context)
+{
+ int delay; /* in ms */
+
+ /* Clean up context. Potential memory leak if(context.result != NULL) */
+ context->result = NULL;
+ context->retry = 0;
+
+ /* Wait until we get results or error */
+ while(1)
+ {
+ /* Try to get scan results */
+ delay = iw_process_scan(skfd, ifname, we_version, context);
+
+ /* Check termination */
+ if(delay <= 0)
+ break;
+
+ /* Wait a bit */
+ usleep(delay * 1000);
+ }
+
+ /* End - return -1 or 0 */
+ return(delay);
+}
diff --git a/lib/libiw/iwlib.h b/lib/libiw/iwlib.h
new file mode 100644
index 000000000..31cf39b73
--- /dev/null
+++ b/lib/libiw/iwlib.h
@@ -0,0 +1,600 @@
+/*
+ * Wireless Tools
+ *
+ * Jean II - HPLB 97->99 - HPL 99->07
+ *
+ * Common header for the Wireless Extension library...
+ *
+ * This file is released under the GPL license.
+ * Copyright (c) 1997-2007 Jean Tourrilhes
+ */
+
+#ifndef IWLIB_H
+#define IWLIB_H
+
+/*#include "CHANGELOG.h"*/
+
+/***************************** INCLUDES *****************************/
+
+/* Standard headers */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include /* gethostbyname, getnetbyname */
+#include /* struct ether_addr */
+#include /* struct timeval */
+#include
+
+/* This is our header selection. Try to hide the mess and the misery :-(
+ * Don't look, you would go blind ;-)
+ * Note : compatibility with *old* distributions has been removed,
+ * you will need Glibc 2.2 and older to compile (which means
+ * Mandrake 8.0, Debian 2.3, RH 7.1 or older).
+ */
+
+/* Set of headers proposed by Dr. Michael Rietz , 27.3.2 */
+#include /* For ARPHRD_ETHER */
+#include /* For AF_INET & struct sockaddr */
+#include /* For struct sockaddr_in */
+#include
+
+/* Fixup to be able to include kernel includes in userspace.
+ * Basically, kill the sparse annotations... Jean II */
+#ifndef __user
+#define __user
+#endif
+
+#include /* for "caddr_t" et al */
+
+/* Glibc systems headers are supposedly less problematic than kernel ones */
+#include /* for "struct sockaddr" et al */
+#include /* for IFNAMSIZ and co... */
+
+/* Private copy of Wireless extensions (in this directoty) */
+#include "wireless.h"
+
+/* Make gcc understant that when we say inline, we mean it.
+ * I really hate when the compiler is trying to be more clever than me,
+ * because in this case gcc is not able to figure out functions with a
+ * single call site, so not only I have to tag those functions inline
+ * by hand, but then it refuse to inline them properly.
+ * Total saving for iwevent : 150B = 0.7%.
+ * Fortunately, in gcc 3.4, they now automatically inline static functions
+ * with a single call site. Hurrah !
+ * Jean II */
+#undef IW_GCC_HAS_BROKEN_INLINE
+#if __GNUC__ == 3
+#if __GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 4
+#define IW_GCC_HAS_BROKEN_INLINE 1
+#endif /* __GNUC_MINOR__ */
+#endif /* __GNUC__ */
+/* However, gcc 4.0 has introduce a new "feature", when compiling with
+ * '-Os', it does not want to inline iw_ether_cmp() and friends.
+ * So, we need to fix inline again !
+ * Jean II */
+#if __GNUC__ == 4
+#define IW_GCC_HAS_BROKEN_INLINE 1
+#endif /* __GNUC__ */
+/* Now, really fix the inline */
+#ifdef IW_GCC_HAS_BROKEN_INLINE
+#ifdef inline
+#undef inline
+#endif /* inline */
+#define inline inline __attribute__((always_inline))
+#endif /* IW_GCC_HAS_BROKEN_INLINE */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/****************************** DEBUG ******************************/
+
+//#define DEBUG 1
+
+/************************ CONSTANTS & MACROS ************************/
+
+/* Various versions information */
+/* Recommended Wireless Extension version */
+#define WE_VERSION 21
+/* Maximum forward compatibility built in this version of WT */
+#define WE_MAX_VERSION 22
+/* Version of Wireless Tools */
+#define WT_VERSION 29
+
+/* Paths */
+#define PROC_NET_WIRELESS "/proc/net/wireless"
+#define PROC_NET_DEV "/proc/net/dev"
+
+/* Some usefull constants */
+#define KILO 1e3
+#define MEGA 1e6
+#define GIGA 1e9
+/* For doing log10/exp10 without libm */
+#define LOG10_MAGIC 1.25892541179
+
+/* Backward compatibility for network headers */
+#ifndef ARPHRD_IEEE80211
+#define ARPHRD_IEEE80211 801 /* IEEE 802.11 */
+#endif /* ARPHRD_IEEE80211 */
+
+#ifndef IW_EV_LCP_PK_LEN
+/* Size of the Event prefix when packed in stream */
+#define IW_EV_LCP_PK_LEN (4)
+/* Size of the various events when packed in stream */
+#define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ)
+#define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(__u32))
+#define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality))
+#define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4)
+
+struct iw_pk_event
+{
+ __u16 len; /* Real lenght of this stuff */
+ __u16 cmd; /* Wireless IOCTL */
+ union iwreq_data u; /* IOCTL fixed payload */
+} __attribute__ ((packed));
+struct iw_pk_point
+{
+ void __user *pointer; /* Pointer to the data (in user space) */
+ __u16 length; /* number of fields or size in bytes */
+ __u16 flags; /* Optional params */
+} __attribute__ ((packed));
+
+#define IW_EV_LCP_PK2_LEN (sizeof(struct iw_pk_event) - sizeof(union iwreq_data))
+#define IW_EV_POINT_PK2_LEN (IW_EV_LCP_PK2_LEN + sizeof(struct iw_pk_point) - IW_EV_POINT_OFF)
+
+#endif /* IW_EV_LCP_PK_LEN */
+
+/****************************** TYPES ******************************/
+
+/* Shortcuts */
+typedef struct iw_statistics iwstats;
+typedef struct iw_range iwrange;
+typedef struct iw_param iwparam;
+typedef struct iw_freq iwfreq;
+typedef struct iw_quality iwqual;
+typedef struct iw_priv_args iwprivargs;
+typedef struct sockaddr sockaddr;
+
+/* Structure for storing all wireless information for each device
+ * This is a cut down version of the one above, containing only
+ * the things *truly* needed to configure a card.
+ * Don't add other junk, I'll remove it... */
+typedef struct wireless_config
+{
+ char name[IFNAMSIZ + 1]; /* Wireless/protocol name */
+ int has_nwid;
+ iwparam nwid; /* Network ID */
+ int has_freq;
+ double freq; /* Frequency/channel */
+ int freq_flags;
+ int has_key;
+ unsigned char key[IW_ENCODING_TOKEN_MAX]; /* Encoding key used */
+ int key_size; /* Number of bytes */
+ int key_flags; /* Various flags */
+ int has_essid;
+ int essid_on;
+ char essid[IW_ESSID_MAX_SIZE + 1]; /* ESSID (extended network) */
+ int has_mode;
+ int mode; /* Operation mode */
+} wireless_config;
+
+/* Structure for storing all wireless information for each device
+ * This is pretty exhaustive... */
+typedef struct wireless_info
+{
+ struct wireless_config b; /* Basic information */
+
+ int has_sens;
+ iwparam sens; /* sensitivity */
+ int has_nickname;
+ char nickname[IW_ESSID_MAX_SIZE + 1]; /* NickName */
+ int has_ap_addr;
+ sockaddr ap_addr; /* Access point address */
+ int has_bitrate;
+ iwparam bitrate; /* Bit rate in bps */
+ int has_rts;
+ iwparam rts; /* RTS threshold in bytes */
+ int has_frag;
+ iwparam frag; /* Fragmentation threshold in bytes */
+ int has_power;
+ iwparam power; /* Power management parameters */
+ int has_txpower;
+ iwparam txpower; /* Transmit Power in dBm */
+ int has_retry;
+ iwparam retry; /* Retry limit or lifetime */
+
+ /* Stats */
+ iwstats stats;
+ int has_stats;
+ iwrange range;
+ int has_range;
+
+ /* Auth params for WPA/802.1x/802.11i */
+ int auth_key_mgmt;
+ int has_auth_key_mgmt;
+ int auth_cipher_pairwise;
+ int has_auth_cipher_pairwise;
+ int auth_cipher_group;
+ int has_auth_cipher_group;
+} wireless_info;
+
+/* Structure for storing an entry of a wireless scan.
+ * This is only a subset of all possible information, the flexible
+ * structure of scan results make it impossible to capture all
+ * information in such a static structure. */
+typedef struct wireless_scan
+{
+ /* Linked list */
+ struct wireless_scan * next;
+
+ /* Cell identifiaction */
+ int has_ap_addr;
+ sockaddr ap_addr; /* Access point address */
+
+ /* Other information */
+ struct wireless_config b; /* Basic information */
+ iwstats stats; /* Signal strength */
+ int has_stats;
+ iwparam maxbitrate; /* Max bit rate in bps */
+ int has_maxbitrate;
+} wireless_scan;
+
+/*
+ * Context used for non-blocking scan.
+ */
+typedef struct wireless_scan_head
+{
+ wireless_scan * result; /* Result of the scan */
+ int retry; /* Retry level */
+} wireless_scan_head;
+
+/* Structure used for parsing event streams, such as Wireless Events
+ * and scan results */
+typedef struct stream_descr
+{
+ char * end; /* End of the stream */
+ char * current; /* Current event in stream of events */
+ char * value; /* Current value in event */
+} stream_descr;
+
+/* Prototype for handling display of each single interface on the
+ * system - see iw_enum_devices() */
+typedef int (*iw_enum_handler)(int skfd,
+ char * ifname,
+ char * args[],
+ int count);
+
+/* Describe a modulation */
+typedef struct iw_modul_descr
+{
+ unsigned int mask; /* Modulation bitmask */
+ char cmd[8]; /* Short name */
+ char * verbose; /* Verbose description */
+} iw_modul_descr;
+
+/**************************** PROTOTYPES ****************************/
+/*
+ * All the functions in iwcommon.c
+ */
+
+/* ---------------------- SOCKET SUBROUTINES -----------------------*/
+int
+ iw_sockets_open(void);
+void
+ iw_enum_devices(int skfd,
+ iw_enum_handler fn,
+ char * args[],
+ int count);
+/* --------------------- WIRELESS SUBROUTINES ----------------------*/
+int
+ iw_get_kernel_we_version(void);
+int
+ iw_print_version_info(const char * toolname);
+int
+ iw_get_range_info(int skfd,
+ const char * ifname,
+ iwrange * range);
+int
+ iw_get_priv_info(int skfd,
+ const char * ifname,
+ iwprivargs ** ppriv);
+int
+ iw_get_basic_config(int skfd,
+ const char * ifname,
+ wireless_config * info);
+int
+ iw_set_basic_config(int skfd,
+ const char * ifname,
+ wireless_config * info);
+/* --------------------- PROTOCOL SUBROUTINES --------------------- */
+int
+ iw_protocol_compare(const char * protocol1,
+ const char * protocol2);
+/* -------------------- FREQUENCY SUBROUTINES --------------------- */
+void
+ iw_float2freq(double in,
+ iwfreq * out);
+double
+ iw_freq2float(const iwfreq * in);
+void
+ iw_print_freq_value(char * buffer,
+ int buflen,
+ double freq);
+void
+ iw_print_freq(char * buffer,
+ int buflen,
+ double freq,
+ int channel,
+ int freq_flags);
+int
+ iw_freq_to_channel(double freq,
+ const struct iw_range * range);
+int
+ iw_channel_to_freq(int channel,
+ double * pfreq,
+ const struct iw_range * range);
+void
+ iw_print_bitrate(char * buffer,
+ int buflen,
+ int bitrate);
+/* ---------------------- POWER SUBROUTINES ----------------------- */
+int
+ iw_dbm2mwatt(int in);
+int
+ iw_mwatt2dbm(int in);
+void
+ iw_print_txpower(char * buffer,
+ int buflen,
+ struct iw_param * txpower);
+/* -------------------- STATISTICS SUBROUTINES -------------------- */
+int
+ iw_get_stats(int skfd,
+ const char * ifname,
+ iwstats * stats,
+ const iwrange * range,
+ int has_range);
+void
+ iw_print_stats(char * buffer,
+ int buflen,
+ const iwqual * qual,
+ const iwrange * range,
+ int has_range);
+/* --------------------- ENCODING SUBROUTINES --------------------- */
+void
+ iw_print_key(char * buffer,
+ int buflen,
+ const unsigned char * key,
+ int key_size,
+ int key_flags);
+int
+ iw_in_key(const char * input,
+ unsigned char * key);
+int
+ iw_in_key_full(int skfd,
+ const char * ifname,
+ const char * input,
+ unsigned char * key,
+ __u16 * flags);
+/* ----------------- POWER MANAGEMENT SUBROUTINES ----------------- */
+void
+ iw_print_pm_value(char * buffer,
+ int buflen,
+ int value,
+ int flags,
+ int we_version);
+void
+ iw_print_pm_mode(char * buffer,
+ int buflen,
+ int flags);
+/* --------------- RETRY LIMIT/LIFETIME SUBROUTINES --------------- */
+void
+ iw_print_retry_value(char * buffer,
+ int buflen,
+ int value,
+ int flags,
+ int we_version);
+/* ----------------------- TIME SUBROUTINES ----------------------- */
+void
+ iw_print_timeval(char * buffer,
+ int buflen,
+ const struct timeval * time,
+ const struct timezone * tz);
+/* --------------------- ADDRESS SUBROUTINES ---------------------- */
+int
+ iw_check_mac_addr_type(int skfd,
+ const char * ifname);
+int
+ iw_check_if_addr_type(int skfd,
+ const char * ifname);
+#if 0
+int
+ iw_check_addr_type(int skfd,
+ const char * ifname);
+#endif
+#if 0
+int
+ iw_get_mac_addr(int skfd,
+ const char * name,
+ struct ether_addr * eth,
+ unsigned short * ptype);
+#endif
+char *
+ iw_mac_ntop(const unsigned char * mac,
+ int maclen,
+ char * buf,
+ int buflen);
+void
+ iw_ether_ntop(const struct ether_addr * eth,
+ char * buf);
+char *
+ iw_sawap_ntop(const struct sockaddr * sap,
+ char * buf);
+int
+ iw_mac_aton(const char * orig,
+ unsigned char * mac,
+ int macmax);
+int
+ iw_ether_aton(const char* bufp, struct ether_addr* eth);
+int
+ iw_in_inet(char *bufp, struct sockaddr *sap);
+int
+ iw_in_addr(int skfd,
+ const char * ifname,
+ char * bufp,
+ struct sockaddr * sap);
+/* ----------------------- MISC SUBROUTINES ------------------------ */
+int
+ iw_get_priv_size(int args);
+
+/* ---------------------- EVENT SUBROUTINES ---------------------- */
+void
+ iw_init_event_stream(struct stream_descr * stream,
+ char * data,
+ int len);
+int
+ iw_extract_event_stream(struct stream_descr * stream,
+ struct iw_event * iwe,
+ int we_version);
+/* --------------------- SCANNING SUBROUTINES --------------------- */
+int
+ iw_process_scan(int skfd,
+ char * ifname,
+ int we_version,
+ wireless_scan_head * context);
+int
+ iw_scan(int skfd,
+ char * ifname,
+ int we_version,
+ wireless_scan_head * context);
+
+/**************************** VARIABLES ****************************/
+
+/* Modes as human readable strings */
+extern const char * const iw_operation_mode[];
+#define IW_NUM_OPER_MODE 7
+#define IW_NUM_OPER_MODE_EXT 8
+
+/* Modulations as human readable strings */
+extern const struct iw_modul_descr iw_modul_list[];
+#define IW_SIZE_MODUL_LIST 16
+
+/************************* INLINE FUNTIONS *************************/
+/*
+ * Functions that are so simple that it's more efficient inlining them
+ */
+
+/*
+ * Note : I've defined wrapper for the ioctl request so that
+ * it will be easier to migrate to other kernel API if needed
+ */
+
+/*------------------------------------------------------------------*/
+/*
+ * Wrapper to push some Wireless Parameter in the driver
+ */
+static inline int
+iw_set_ext(int skfd, /* Socket to the kernel */
+ const char * ifname, /* Device name */
+ int request, /* WE ID */
+ struct iwreq * pwrq) /* Fixed part of the request */
+{
+ /* Set device name */
+ strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
+ /* Do the request */
+ return(ioctl(skfd, request, pwrq));
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Wrapper to extract some Wireless Parameter out of the driver
+ */
+static inline int
+iw_get_ext(int skfd, /* Socket to the kernel */
+ const char * ifname, /* Device name */
+ int request, /* WE ID */
+ struct iwreq * pwrq) /* Fixed part of the request */
+{
+ /* Set device name */
+ strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
+ /* Do the request */
+ return(ioctl(skfd, request, pwrq));
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Close the socket used for ioctl.
+ */
+static inline void
+iw_sockets_close(int skfd)
+{
+ close(skfd);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Display an Ethernet Socket Address in readable format.
+ */
+static inline char *
+iw_saether_ntop(const struct sockaddr *sap, char* bufp)
+{
+ iw_ether_ntop((const struct ether_addr *) sap->sa_data, bufp);
+ return bufp;
+}
+/*------------------------------------------------------------------*/
+/*
+ * Input an Ethernet Socket Address and convert to binary.
+ */
+static inline int
+iw_saether_aton(const char *bufp, struct sockaddr *sap)
+{
+ sap->sa_family = ARPHRD_ETHER;
+ return iw_ether_aton(bufp, (struct ether_addr *) sap->sa_data);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Create an Ethernet broadcast address
+ */
+static inline void
+iw_broad_ether(struct sockaddr *sap)
+{
+ sap->sa_family = ARPHRD_ETHER;
+ memset((char *) sap->sa_data, 0xFF, ETH_ALEN);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Create an Ethernet NULL address
+ */
+static inline void
+iw_null_ether(struct sockaddr *sap)
+{
+ sap->sa_family = ARPHRD_ETHER;
+ memset((char *) sap->sa_data, 0x00, ETH_ALEN);
+}
+
+/*------------------------------------------------------------------*/
+/*
+ * Compare two ethernet addresses
+ */
+static inline int
+iw_ether_cmp(const struct ether_addr* eth1, const struct ether_addr* eth2)
+{
+ return memcmp(eth1, eth2, sizeof(*eth1));
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* IWLIB_H */
diff --git a/lib/libiw/iwscan.cpp b/lib/libiw/iwscan.cpp
new file mode 100644
index 000000000..ab39a56e2
--- /dev/null
+++ b/lib/libiw/iwscan.cpp
@@ -0,0 +1,294 @@
+/*
+ Copyright (C) 2013 CoolStream International Ltd
+
+ Based on iwlist.c, Copyright (c) 1997-2007 Jean Tourrilhes
+
+ License: GPLv2
+
+ 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;
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include
+extern "C" {
+#include "iwlib.h" /* Header */
+}
+
+#include
+#include "iwscan.h"
+
+static void device_up(std::string dev)
+{
+ int sockfd;
+ struct ifreq ifr;
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+
+ if (sockfd < 0) {
+ perror("socket");
+ return;
+ }
+
+ memset(&ifr, 0, sizeof ifr);
+
+ strncpy(ifr.ifr_name, dev.c_str(), IFNAMSIZ);
+ if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0)
+ perror("SIOCGIFFLAGS");
+
+ ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
+ if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0)
+ perror("SIOCSIFFLAGS");
+
+ close(sockfd);
+}
+
+bool get_wlan_list(std::string dev, std::vector &networks)
+{
+ int skfd;
+ struct iwreq wrq;
+ unsigned char * buffer = NULL; /* Results */
+ int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */
+ struct iw_range range;
+ int has_range;
+ struct timeval tv; /* Select timeout */
+ int timeout = 15000000; /* 15s */
+ const char * ifname = dev.c_str();
+
+ networks.clear();
+ device_up(dev);
+
+ if((skfd = iw_sockets_open()) < 0)
+ {
+ perror("socket");
+ return false;
+ }
+
+ /* Get range stuff */
+ has_range = (iw_get_range_info(skfd, ifname, &range) >= 0);
+
+ /* Check if the interface could support scanning. */
+ if((!has_range) || (range.we_version_compiled < 14))
+ {
+ fprintf(stderr, "%-8.16s Interface doesn't support scanning.\n\n",
+ ifname);
+ goto _return;
+ }
+
+ /* Init timeout value -> 250ms between set and first get */
+ tv.tv_sec = 0;
+ tv.tv_usec = 250000;
+
+ wrq.u.data.pointer = NULL;
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = 0;
+
+ /* Initiate Scanning */
+ if(iw_set_ext(skfd, ifname, SIOCSIWSCAN, &wrq) < 0)
+ {
+ if(errno != EPERM)
+ {
+ fprintf(stderr, "%-8.16s Interface doesn't support scanning : %s\n\n",
+ ifname, strerror(errno));
+ goto _return;
+ }
+ /* If we don't have the permission to initiate the scan, we may
+ * still have permission to read left-over results.
+ * But, don't wait !!! */
+ tv.tv_usec = 0;
+ }
+ timeout -= tv.tv_usec;
+
+ /* Forever */
+ while(1)
+ {
+ fd_set rfds; /* File descriptors for select */
+ int last_fd; /* Last fd */
+ int ret;
+
+ /* Guess what ? We must re-generate rfds each time */
+ FD_ZERO(&rfds);
+ last_fd = -1;
+
+ /* In here, add the rtnetlink fd in the list */
+
+ /* Wait until something happens */
+ ret = select(last_fd + 1, &rfds, NULL, NULL, &tv);
+
+ /* Check if there was an error */
+ if(ret < 0)
+ {
+ if(errno == EAGAIN || errno == EINTR)
+ continue;
+ fprintf(stderr, "Unhandled signal - exiting...\n");
+ goto _return;
+ }
+
+ /* Check if there was a timeout */
+ if(ret == 0)
+ {
+ unsigned char * newbuf;
+
+realloc:
+ /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */
+ newbuf = (unsigned char *) realloc(buffer, buflen);
+ if(newbuf == NULL)
+ {
+ fprintf(stderr, "%s: Allocation failed\n", __FUNCTION__);
+ goto _return;
+ }
+ buffer = newbuf;
+
+ /* Try to read the results */
+ wrq.u.data.pointer = buffer;
+ wrq.u.data.flags = 0;
+ wrq.u.data.length = buflen;
+ if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0)
+ {
+ /* Check if buffer was too small (WE-17 only) */
+ if((errno == E2BIG) && (range.we_version_compiled > 16))
+ {
+ /* Some driver may return very large scan results, either
+ * because there are many cells, or because they have many
+ * large elements in cells (like IWEVCUSTOM). Most will
+ * only need the regular sized buffer. We now use a dynamic
+ * allocation of the buffer to satisfy everybody. Of course,
+ * as we don't know in advance the size of the array, we try
+ * various increasing sizes. Jean II */
+
+ /* Check if the driver gave us any hints. */
+ if(wrq.u.data.length > buflen)
+ buflen = wrq.u.data.length;
+ else
+ buflen *= 2;
+
+ /* Try again */
+ goto realloc;
+ }
+
+ /* Check if results not available yet */
+ if(errno == EAGAIN)
+ {
+ /* Restart timer for only 100ms*/
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+ timeout -= tv.tv_usec;
+ if(timeout > 0)
+ continue; /* Try again later */
+ }
+
+ /* Bad error */
+ fprintf(stderr, "%-8.16s Failed to read scan data : %s\n\n",
+ ifname, strerror(errno));
+ goto _return;
+ }
+ else
+ /* We have the results, go to process them */
+ break;
+ }
+
+ /* In here, check if event and event type
+ * if scan event, read results. All errors bad & no reset timeout */
+ }
+
+ if(wrq.u.data.length)
+ {
+ struct iw_event iwe;
+ struct iw_event * event = &iwe;
+ struct stream_descr stream;
+ int ret;
+
+ printf("%-8.16s Scan completed :\n", ifname);
+ iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length);
+ int count = -1;
+ while(1)
+ {
+ wlan_network network;
+ /* Extract an event and print it */
+ ret = iw_extract_event_stream(&stream, &iwe,
+ range.we_version_compiled);
+ if (ret <= 0)
+ break;
+ switch(event->cmd) {
+ case SIOCGIWESSID:
+ {
+ char essid[IW_ESSID_MAX_SIZE+1];
+ memset(essid, '\0', sizeof(essid));
+ if((event->u.essid.pointer) && (event->u.essid.length))
+ memcpy(essid, event->u.essid.pointer, event->u.essid.length);
+ if(event->u.essid.flags)
+ {
+ printf(" ESSID:\"%s\"\n", essid);
+ network.ssid = essid;
+ }
+ else {
+ printf(" ESSID:off/any/hidden\n");
+ network.ssid = "(hidden)";
+ }
+ count++;
+ networks.push_back(network);
+ }
+
+ break;
+ case SIOCGIWFREQ:
+ {
+ double freq; /* Frequency/channel */
+ int channel = -1; /* Converted to channel */
+ char buf[128];
+ freq = iw_freq2float(&(event->u.freq));
+ /* Convert to channel if possible */
+ if(has_range)
+ channel = iw_freq_to_channel(freq, &range);
+ iw_print_freq(buf, sizeof(buf),
+ freq, channel, event->u.freq.flags);
+#if 0
+ if ((channel < 0) && (freq < KILO))
+ channel = freq;
+#endif
+ printf(" %s\n", buf);
+ networks[count].channel = buf;
+ }
+ break;
+ case IWEVQUAL:
+ {
+ char buf[128];
+ iw_print_stats(buf, sizeof(buf),
+ &event->u.qual, &range, has_range);
+ printf(" %s\n", buf);
+ networks[count].qual = buf;
+ std::size_t found = networks[count].qual.find_first_of(' ');
+ if (found != std::string::npos)
+ networks[count].qual = networks[count].qual.substr(0, found);
+ }
+ break;
+ case SIOCGIWENCODE:
+ if(event->u.data.flags & IW_ENCODE_DISABLED)
+ networks[count].encrypted = 0;
+ else
+ networks[count].encrypted = 1;
+
+ printf(" Encryption key:%s\n", networks[count].encrypted ? "on" : "off");
+ break;
+ }
+ }
+ printf("\n");
+ }
+ else
+ printf("%-8.16s No scan results\n\n", ifname);
+
+_return:
+ if (buffer)
+ free(buffer);
+ iw_sockets_close(skfd);
+
+ return !networks.empty();
+}
diff --git a/lib/libiw/iwscan.h b/lib/libiw/iwscan.h
new file mode 100644
index 000000000..4f9350c98
--- /dev/null
+++ b/lib/libiw/iwscan.h
@@ -0,0 +1,36 @@
+/*
+ Copyright (C) 2013 CoolStream International Ltd
+
+ License: GPLv2
+
+ 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;
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _IWSCAN_H_
+#define _IWSCAN_H_
+
+#include
+#include
+
+struct wlan_network
+{
+ std::string ssid;
+ int encrypted;
+ std::string channel;
+ std::string qual;
+ wlan_network(): encrypted(0) {}
+};
+
+bool get_wlan_list(std::string dev, std::vector &networks);
+#endif
diff --git a/lib/libiw/wireless.h b/lib/libiw/wireless.h
new file mode 100644
index 000000000..2d94fabb3
--- /dev/null
+++ b/lib/libiw/wireless.h
@@ -0,0 +1,1120 @@
+/*
+ * This file define a set of standard wireless extensions
+ *
+ * Version : 21 14.3.06
+ *
+ * Authors : Jean Tourrilhes - HPL -
+ * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
+ */
+
+#ifndef _LINUX_WIRELESS_H
+#define _LINUX_WIRELESS_H
+
+/************************** DOCUMENTATION **************************/
+/*
+ * Initial APIs (1996 -> onward) :
+ * -----------------------------
+ * Basically, the wireless extensions are for now a set of standard ioctl
+ * call + /proc/net/wireless
+ *
+ * The entry /proc/net/wireless give statistics and information on the
+ * driver.
+ * This is better than having each driver having its entry because
+ * its centralised and we may remove the driver module safely.
+ *
+ * Ioctl are used to configure the driver and issue commands. This is
+ * better than command line options of insmod because we may want to
+ * change dynamically (while the driver is running) some parameters.
+ *
+ * The ioctl mechanimsm are copied from standard devices ioctl.
+ * We have the list of command plus a structure descibing the
+ * data exchanged...
+ * Note that to add these ioctl, I was obliged to modify :
+ * # net/core/dev.c (two place + add include)
+ * # net/ipv4/af_inet.c (one place + add include)
+ *
+ * /proc/net/wireless is a copy of /proc/net/dev.
+ * We have a structure for data passed from the driver to /proc/net/wireless
+ * Too add this, I've modified :
+ * # net/core/dev.c (two other places)
+ * # include/linux/netdevice.h (one place)
+ * # include/linux/proc_fs.h (one place)
+ *
+ * New driver API (2002 -> onward) :
+ * -------------------------------
+ * This file is only concerned with the user space API and common definitions.
+ * The new driver API is defined and documented in :
+ * # include/net/iw_handler.h
+ *
+ * Note as well that /proc/net/wireless implementation has now moved in :
+ * # net/core/wireless.c
+ *
+ * Wireless Events (2002 -> onward) :
+ * --------------------------------
+ * Events are defined at the end of this file, and implemented in :
+ * # net/core/wireless.c
+ *
+ * Other comments :
+ * --------------
+ * Do not add here things that are redundant with other mechanisms
+ * (drivers init, ifconfig, /proc/net/dev, ...) and with are not
+ * wireless specific.
+ *
+ * These wireless extensions are not magic : each driver has to provide
+ * support for them...
+ *
+ * IMPORTANT NOTE : As everything in the kernel, this is very much a
+ * work in progress. Contact me if you have ideas of improvements...
+ */
+
+/***************************** INCLUDES *****************************/
+
+/* This header is used in user-space, therefore need to be sanitised
+ * for that purpose. Those includes are usually not compatible with glibc.
+ * To know which includes to use in user-space, check iwlib.h. */
+#ifdef __KERNEL__
+#include /* for "caddr_t" et al */
+#include /* for "struct sockaddr" et al */
+#include /* for IFNAMSIZ and co... */
+#endif /* __KERNEL__ */
+
+/***************************** VERSION *****************************/
+/*
+ * This constant is used to know the availability of the wireless
+ * extensions and to know which version of wireless extensions it is
+ * (there is some stuff that will be added in the future...)
+ * I just plan to increment with each new version.
+ */
+#define WIRELESS_EXT 21
+
+/*
+ * Changes :
+ *
+ * V2 to V3
+ * --------
+ * Alan Cox start some incompatibles changes. I've integrated a bit more.
+ * - Encryption renamed to Encode to avoid US regulation problems
+ * - Frequency changed from float to struct to avoid problems on old 386
+ *
+ * V3 to V4
+ * --------
+ * - Add sensitivity
+ *
+ * V4 to V5
+ * --------
+ * - Missing encoding definitions in range
+ * - Access points stuff
+ *
+ * V5 to V6
+ * --------
+ * - 802.11 support (ESSID ioctls)
+ *
+ * V6 to V7
+ * --------
+ * - define IW_ESSID_MAX_SIZE and IW_MAX_AP
+ *
+ * V7 to V8
+ * --------
+ * - Changed my e-mail address
+ * - More 802.11 support (nickname, rate, rts, frag)
+ * - List index in frequencies
+ *
+ * V8 to V9
+ * --------
+ * - Support for 'mode of operation' (ad-hoc, managed...)
+ * - Support for unicast and multicast power saving
+ * - Change encoding to support larger tokens (>64 bits)
+ * - Updated iw_params (disable, flags) and use it for NWID
+ * - Extracted iw_point from iwreq for clarity
+ *
+ * V9 to V10
+ * ---------
+ * - Add PM capability to range structure
+ * - Add PM modifier : MAX/MIN/RELATIVE
+ * - Add encoding option : IW_ENCODE_NOKEY
+ * - Add TxPower ioctls (work like TxRate)
+ *
+ * V10 to V11
+ * ----------
+ * - Add WE version in range (help backward/forward compatibility)
+ * - Add retry ioctls (work like PM)
+ *
+ * V11 to V12
+ * ----------
+ * - Add SIOCSIWSTATS to get /proc/net/wireless programatically
+ * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space
+ * - Add new statistics (frag, retry, beacon)
+ * - Add average quality (for user space calibration)
+ *
+ * V12 to V13
+ * ----------
+ * - Document creation of new driver API.
+ * - Extract union iwreq_data from struct iwreq (for new driver API).
+ * - Rename SIOCSIWNAME as SIOCSIWCOMMIT
+ *
+ * V13 to V14
+ * ----------
+ * - Wireless Events support : define struct iw_event
+ * - Define additional specific event numbers
+ * - Add "addr" and "param" fields in union iwreq_data
+ * - AP scanning stuff (SIOCSIWSCAN and friends)
+ *
+ * V14 to V15
+ * ----------
+ * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg
+ * - Make struct iw_freq signed (both m & e), add explicit padding
+ * - Add IWEVCUSTOM for driver specific event/scanning token
+ * - Add IW_MAX_GET_SPY for driver returning a lot of addresses
+ * - Add IW_TXPOW_RANGE for range of Tx Powers
+ * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points
+ * - Add IW_MODE_MONITOR for passive monitor
+ *
+ * V15 to V16
+ * ----------
+ * - Increase the number of bitrates in iw_range to 32 (for 802.11g)
+ * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a)
+ * - Reshuffle struct iw_range for increases, add filler
+ * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses
+ * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support
+ * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy"
+ * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index
+ *
+ * V16 to V17
+ * ----------
+ * - Add flags to frequency -> auto/fixed
+ * - Document (struct iw_quality *)->updated, add new flags (INVALID)
+ * - Wireless Event capability in struct iw_range
+ * - Add support for relative TxPower (yick !)
+ *
+ * V17 to V18 (From Jouni Malinen )
+ * ----------
+ * - Add support for WPA/WPA2
+ * - Add extended encoding configuration (SIOCSIWENCODEEXT and
+ * SIOCGIWENCODEEXT)
+ * - Add SIOCSIWGENIE/SIOCGIWGENIE
+ * - Add SIOCSIWMLME
+ * - Add SIOCSIWPMKSA
+ * - Add struct iw_range bit field for supported encoding capabilities
+ * - Add optional scan request parameters for SIOCSIWSCAN
+ * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA
+ * related parameters (extensible up to 4096 parameter values)
+ * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE,
+ * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND
+ *
+ * V18 to V19
+ * ----------
+ * - Remove (struct iw_point *)->pointer from events and streams
+ * - Remove header includes to help user space
+ * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64
+ * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
+ * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
+ * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
+ *
+ * V20 to V21
+ * ----------
+ * - Remove (struct net_device *)->get_wireless_stats()
+ * - Change length in ESSID and NICK to strlen() instead of strlen()+1
+ * - Add SIOCSIWMODUL/SIOCGIWMODUL for modulation setting
+ * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers
+ * - Add IW_POWER_SAVING power type
+ * - Power/Retry relative values no longer * 100000
+ * - Add bitrate flags for unicast/broadcast
+ */
+
+/**************************** CONSTANTS ****************************/
+
+/* -------------------------- IOCTL LIST -------------------------- */
+
+/* Wireless Identification */
+#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */
+#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */
+/* SIOCGIWNAME is used to verify the presence of Wireless Extensions.
+ * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"...
+ * Don't put the name of your driver there, it's useless. */
+
+/* Basic operations */
+#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */
+#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */
+#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */
+#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */
+#define SIOCSIWMODE 0x8B06 /* set operation mode */
+#define SIOCGIWMODE 0x8B07 /* get operation mode */
+#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */
+#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */
+
+/* Informative stuff */
+#define SIOCSIWRANGE 0x8B0A /* Unused */
+#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */
+#define SIOCSIWPRIV 0x8B0C /* Unused */
+#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */
+#define SIOCSIWSTATS 0x8B0E /* Unused */
+#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */
+/* SIOCGIWSTATS is strictly used between user space and the kernel, and
+ * is never passed to the driver (i.e. the driver will never see it). */
+
+/* Spy support (statistics per MAC address - used for Mobile IP support) */
+#define SIOCSIWSPY 0x8B10 /* set spy addresses */
+#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */
+#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */
+#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */
+
+/* Access Point manipulation */
+#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */
+#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */
+#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */
+#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */
+#define SIOCGIWSCAN 0x8B19 /* get scanning results */
+
+/* 802.11 specific support */
+#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */
+#define SIOCGIWESSID 0x8B1B /* get ESSID */
+#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */
+#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */
+/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit
+ * within the 'iwreq' structure, so we need to use the 'data' member to
+ * point to a string in user space, like it is done for RANGE... */
+
+/* Other parameters useful in 802.11 and some other devices */
+#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */
+#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */
+#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
+#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
+#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */
+#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */
+#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */
+#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */
+#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */
+#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */
+
+/* Encoding stuff (scrambling, hardware security, WEP...) */
+#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */
+#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */
+/* Power saving stuff (power management, unicast and multicast) */
+#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */
+#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */
+/* Modulation bitmask */
+#define SIOCSIWMODUL 0x8B2E /* set Modulations settings */
+#define SIOCGIWMODUL 0x8B2F /* get Modulations settings */
+
+/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM).
+ * This ioctl uses struct iw_point and data buffer that includes IE id and len
+ * fields. More than one IE may be included in the request. Setting the generic
+ * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers
+ * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers
+ * are required to report the used IE as a wireless event, e.g., when
+ * associating with an AP. */
+#define SIOCSIWGENIE 0x8B30 /* set generic IE */
+#define SIOCGIWGENIE 0x8B31 /* get generic IE */
+
+/* WPA : IEEE 802.11 MLME requests */
+#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses
+ * struct iw_mlme */
+/* WPA : Authentication mode parameters */
+#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */
+#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */
+
+/* WPA : Extended version of encoding configuration */
+#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */
+#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */
+
+/* WPA2 : PMKSA cache management */
+#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */
+
+/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */
+
+/* These 32 ioctl are wireless device private, for 16 commands.
+ * Each driver is free to use them for whatever purpose it chooses,
+ * however the driver *must* export the description of those ioctls
+ * with SIOCGIWPRIV and *must* use arguments as defined below.
+ * If you don't follow those rules, DaveM is going to hate you (reason :
+ * it make mixed 32/64bit operation impossible).
+ */
+#define SIOCIWFIRSTPRIV 0x8BE0
+#define SIOCIWLASTPRIV 0x8BFF
+/* Previously, we were using SIOCDEVPRIVATE, but we now have our
+ * separate range because of collisions with other tools such as
+ * 'mii-tool'.
+ * We now have 32 commands, so a bit more space ;-).
+ * Also, all 'odd' commands are only usable by root and don't return the
+ * content of ifr/iwr to user (but you are not obliged to use the set/get
+ * convention, just use every other two command). More details in iwpriv.c.
+ * And I repeat : you are not forced to use them with iwpriv, but you
+ * must be compliant with it.
+ */
+
+/* ------------------------- IOCTL STUFF ------------------------- */
+
+/* The first and the last (range) */
+#define SIOCIWFIRST 0x8B00
+#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */
+#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST)
+
+/* Even : get (world access), odd : set (root access) */
+#define IW_IS_SET(cmd) (!((cmd) & 0x1))
+#define IW_IS_GET(cmd) ((cmd) & 0x1)
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/* Those are *NOT* ioctls, do not issue request on them !!! */
+/* Most events use the same identifier as ioctl requests */
+
+#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */
+#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */
+#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */
+#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */
+#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */
+#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..)
+ * (scan results); This includes id and
+ * length fields. One IWEVGENIE may
+ * contain more than one IE. Scan
+ * results may contain one or more
+ * IWEVGENIE events. */
+#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure
+ * (struct iw_michaelmicfailure)
+ */
+#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request.
+ * The data includes id and length
+ * fields and may contain more than one
+ * IE. This event is required in
+ * Managed mode if the driver
+ * generates its own WPA/RSN IE. This
+ * should be sent just before
+ * IWEVREGISTERED event for the
+ * association. */
+#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association
+ * Response. The data includes id and
+ * length fields and may contain more
+ * than one IE. This may be sent
+ * between IWEVASSOCREQIE and
+ * IWEVREGISTERED events for the
+ * association. */
+#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN
+ * pre-authentication
+ * (struct iw_pmkid_cand) */
+
+#define IWEVFIRST 0x8C00
+#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST)
+
+/* ------------------------- PRIVATE INFO ------------------------- */
+/*
+ * The following is used with SIOCGIWPRIV. It allow a driver to define
+ * the interface (name, type of data) for its private ioctl.
+ * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV
+ */
+
+#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */
+#define IW_PRIV_TYPE_NONE 0x0000
+#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */
+#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */
+#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */
+#define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */
+#define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */
+
+#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */
+
+#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */
+
+/*
+ * Note : if the number of args is fixed and the size < 16 octets,
+ * instead of passing a pointer we will put args in the iwreq struct...
+ */
+
+/* ----------------------- OTHER CONSTANTS ----------------------- */
+
+/* Maximum frequencies in the range struct */
+#define IW_MAX_FREQUENCIES 32
+/* Note : if you have something like 80 frequencies,
+ * don't increase this constant and don't fill the frequency list.
+ * The user will be able to set by channel anyway... */
+
+/* Maximum bit rates in the range struct */
+#define IW_MAX_BITRATES 32
+
+/* Maximum tx powers in the range struct */
+#define IW_MAX_TXPOWER 8
+/* Note : if you more than 8 TXPowers, just set the max and min or
+ * a few of them in the struct iw_range. */
+
+/* Maximum of address that you may set with SPY */
+#define IW_MAX_SPY 8
+
+/* Maximum of address that you may get in the
+ list of access points in range */
+#define IW_MAX_AP 64
+
+/* Maximum size of the ESSID and NICKN strings */
+#define IW_ESSID_MAX_SIZE 32
+
+/* Modes of operation */
+#define IW_MODE_AUTO 0 /* Let the driver decides */
+#define IW_MODE_ADHOC 1 /* Single cell network */
+#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */
+#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */
+#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */
+#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */
+#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */
+
+/* Statistics flags (bitmask in updated) */
+#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */
+#define IW_QUAL_LEVEL_UPDATED 0x02
+#define IW_QUAL_NOISE_UPDATED 0x04
+#define IW_QUAL_ALL_UPDATED 0x07
+#define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */
+#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */
+#define IW_QUAL_LEVEL_INVALID 0x20
+#define IW_QUAL_NOISE_INVALID 0x40
+#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */
+#define IW_QUAL_ALL_INVALID 0x70
+
+/* Frequency flags */
+#define IW_FREQ_AUTO 0x00 /* Let the driver decides */
+#define IW_FREQ_FIXED 0x01 /* Force a specific value */
+
+/* Maximum number of size of encoding token available
+ * they are listed in the range structure */
+#define IW_MAX_ENCODING_SIZES 8
+
+/* Maximum size of the encoding token in bytes */
+#define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */
+
+/* Flags for encoding (along with the token) */
+#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */
+#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */
+#define IW_ENCODE_MODE 0xF000 /* Modes defined below */
+#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */
+#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */
+#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */
+#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */
+#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */
+#define IW_ENCODE_TEMP 0x0400 /* Temporary key */
+
+/* Power management flags available (along with the value, if any) */
+#define IW_POWER_ON 0x0000 /* No details... */
+#define IW_POWER_TYPE 0xF000 /* Type of parameter */
+#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */
+#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */
+#define IW_POWER_SAVING 0x4000 /* Value is relative (how aggressive)*/
+#define IW_POWER_MODE 0x0F00 /* Power Management mode */
+#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */
+#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */
+#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */
+#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */
+#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */
+#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */
+#define IW_POWER_MIN 0x0001 /* Value is a minimum */
+#define IW_POWER_MAX 0x0002 /* Value is a maximum */
+#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
+
+/* Transmit Power flags available */
+#define IW_TXPOW_TYPE 0x00FF /* Type of value */
+#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */
+#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */
+#define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */
+#define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */
+
+/* Retry limits and lifetime flags available */
+#define IW_RETRY_ON 0x0000 /* No details... */
+#define IW_RETRY_TYPE 0xF000 /* Type of parameter */
+#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/
+#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */
+#define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */
+#define IW_RETRY_MIN 0x0001 /* Value is a minimum */
+#define IW_RETRY_MAX 0x0002 /* Value is a maximum */
+#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */
+#define IW_RETRY_SHORT 0x0010 /* Value is for short packets */
+#define IW_RETRY_LONG 0x0020 /* Value is for long packets */
+
+/* Scanning request flags */
+#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */
+#define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */
+#define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */
+#define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */
+#define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */
+#define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */
+#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */
+#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */
+#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */
+/* struct iw_scan_req scan_type */
+#define IW_SCAN_TYPE_ACTIVE 0
+#define IW_SCAN_TYPE_PASSIVE 1
+/* Maximum size of returned data */
+#define IW_SCAN_MAX_DATA 4096 /* In bytes */
+
+/* Max number of char in custom event - use multiple of them if needed */
+#define IW_CUSTOM_MAX 256 /* In bytes */
+
+/* Generic information element */
+#define IW_GENERIC_IE_MAX 1024
+
+/* MLME requests (SIOCSIWMLME / struct iw_mlme) */
+#define IW_MLME_DEAUTH 0
+#define IW_MLME_DISASSOC 1
+
+/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */
+#define IW_AUTH_INDEX 0x0FFF
+#define IW_AUTH_FLAGS 0xF000
+/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095)
+ * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the
+ * parameter that is being set/get to; value will be read/written to
+ * struct iw_param value field) */
+#define IW_AUTH_WPA_VERSION 0
+#define IW_AUTH_CIPHER_PAIRWISE 1
+#define IW_AUTH_CIPHER_GROUP 2
+#define IW_AUTH_KEY_MGMT 3
+#define IW_AUTH_TKIP_COUNTERMEASURES 4
+#define IW_AUTH_DROP_UNENCRYPTED 5
+#define IW_AUTH_80211_AUTH_ALG 6
+#define IW_AUTH_WPA_ENABLED 7
+#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8
+#define IW_AUTH_ROAMING_CONTROL 9
+#define IW_AUTH_PRIVACY_INVOKED 10
+
+/* IW_AUTH_WPA_VERSION values (bit field) */
+#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001
+#define IW_AUTH_WPA_VERSION_WPA 0x00000002
+#define IW_AUTH_WPA_VERSION_WPA2 0x00000004
+
+/* IW_AUTH_PAIRWISE_CIPHER and IW_AUTH_GROUP_CIPHER values (bit field) */
+#define IW_AUTH_CIPHER_NONE 0x00000001
+#define IW_AUTH_CIPHER_WEP40 0x00000002
+#define IW_AUTH_CIPHER_TKIP 0x00000004
+#define IW_AUTH_CIPHER_CCMP 0x00000008
+#define IW_AUTH_CIPHER_WEP104 0x00000010
+
+/* IW_AUTH_KEY_MGMT values (bit field) */
+#define IW_AUTH_KEY_MGMT_802_1X 1
+#define IW_AUTH_KEY_MGMT_PSK 2
+
+/* IW_AUTH_80211_AUTH_ALG values (bit field) */
+#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001
+#define IW_AUTH_ALG_SHARED_KEY 0x00000002
+#define IW_AUTH_ALG_LEAP 0x00000004
+
+/* IW_AUTH_ROAMING_CONTROL values */
+#define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */
+#define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming
+ * control */
+
+/* SIOCSIWENCODEEXT definitions */
+#define IW_ENCODE_SEQ_MAX_SIZE 8
+/* struct iw_encode_ext ->alg */
+#define IW_ENCODE_ALG_NONE 0
+#define IW_ENCODE_ALG_WEP 1
+#define IW_ENCODE_ALG_TKIP 2
+#define IW_ENCODE_ALG_CCMP 3
+/* struct iw_encode_ext ->ext_flags */
+#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001
+#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002
+#define IW_ENCODE_EXT_GROUP_KEY 0x00000004
+#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008
+
+/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */
+#define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */
+#define IW_MICFAILURE_GROUP 0x00000004
+#define IW_MICFAILURE_PAIRWISE 0x00000008
+#define IW_MICFAILURE_STAKEY 0x00000010
+#define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported)
+ */
+
+/* Bit field values for enc_capa in struct iw_range */
+#define IW_ENC_CAPA_WPA 0x00000001
+#define IW_ENC_CAPA_WPA2 0x00000002
+#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004
+#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008
+
+/* Event capability macros - in (struct iw_range *)->event_capa
+ * Because we have more than 32 possible events, we use an array of
+ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */
+#define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \
+ (cmd - SIOCIWFIRSTPRIV + 0x60) : \
+ (cmd - SIOCSIWCOMMIT))
+#define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5)
+#define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F))
+/* Event capability constants - event autogenerated by the kernel
+ * This list is valid for most 802.11 devices, customise as needed... */
+#define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \
+ IW_EVENT_CAPA_MASK(0x8B06) | \
+ IW_EVENT_CAPA_MASK(0x8B1A))
+#define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A))
+/* "Easy" macro to set events in iw_range (less efficient) */
+#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd))
+#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; }
+
+/* Modulations bitmasks */
+#define IW_MODUL_ALL 0x00000000 /* Everything supported */
+#define IW_MODUL_FH 0x00000001 /* Frequency Hopping */
+#define IW_MODUL_DS 0x00000002 /* Original Direct Sequence */
+#define IW_MODUL_CCK 0x00000004 /* 802.11b : 5.5 + 11 Mb/s */
+#define IW_MODUL_11B (IW_MODUL_DS | IW_MODUL_CCK)
+#define IW_MODUL_PBCC 0x00000008 /* TI : 5.5 + 11 + 22 Mb/s */
+#define IW_MODUL_OFDM_A 0x00000010 /* 802.11a : 54 Mb/s */
+#define IW_MODUL_11A (IW_MODUL_OFDM_A)
+#define IW_MODUL_11AB (IW_MODUL_11B | IW_MODUL_11A)
+#define IW_MODUL_OFDM_G 0x00000020 /* 802.11g : 54 Mb/s */
+#define IW_MODUL_11G (IW_MODUL_11B | IW_MODUL_OFDM_G)
+#define IW_MODUL_11AG (IW_MODUL_11G | IW_MODUL_11A)
+#define IW_MODUL_TURBO 0x00000040 /* ATH : bonding, 108 Mb/s */
+/* In here we should define MIMO stuff. Later... */
+#define IW_MODUL_CUSTOM 0x40000000 /* Driver specific */
+
+/* Bitrate flags available */
+#define IW_BITRATE_TYPE 0x00FF /* Type of value */
+#define IW_BITRATE_UNICAST 0x0001 /* Maximum/Fixed unicast bitrate */
+#define IW_BITRATE_BROADCAST 0x0002 /* Fixed broadcast bitrate */
+
+/****************************** TYPES ******************************/
+
+/* --------------------------- SUBTYPES --------------------------- */
+/*
+ * Generic format for most parameters that fit in an int
+ */
+struct iw_param
+{
+ __s32 value; /* The value of the parameter itself */
+ __u8 fixed; /* Hardware should not use auto select */
+ __u8 disabled; /* Disable the feature */
+ __u16 flags; /* Various specifc flags (if any) */
+};
+
+/*
+ * For all data larger than 16 octets, we need to use a
+ * pointer to memory allocated in user space.
+ */
+struct iw_point
+{
+ void __user *pointer; /* Pointer to the data (in user space) */
+ __u16 length; /* number of fields or size in bytes */
+ __u16 flags; /* Optional params */
+};
+
+/*
+ * A frequency
+ * For numbers lower than 10^9, we encode the number in 'm' and
+ * set 'e' to 0
+ * For number greater than 10^9, we divide it by the lowest power
+ * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')...
+ * The power of 10 is in 'e', the result of the division is in 'm'.
+ */
+struct iw_freq
+{
+ __s32 m; /* Mantissa */
+ __s16 e; /* Exponent */
+ __u8 i; /* List index (when in range struct) */
+ __u8 flags; /* Flags (fixed/auto) */
+};
+
+/*
+ * Quality of the link
+ */
+struct iw_quality
+{
+ __u8 qual; /* link quality (%retries, SNR,
+ %missed beacons or better...) */
+ __u8 level; /* signal level (dBm) */
+ __u8 noise; /* noise level (dBm) */
+ __u8 updated; /* Flags to know if updated */
+};
+
+/*
+ * Packet discarded in the wireless adapter due to
+ * "wireless" specific problems...
+ * Note : the list of counter and statistics in net_device_stats
+ * is already pretty exhaustive, and you should use that first.
+ * This is only additional stats...
+ */
+struct iw_discarded
+{
+ __u32 nwid; /* Rx : Wrong nwid/essid */
+ __u32 code; /* Rx : Unable to code/decode (WEP) */
+ __u32 fragment; /* Rx : Can't perform MAC reassembly */
+ __u32 retries; /* Tx : Max MAC retries num reached */
+ __u32 misc; /* Others cases */
+};
+
+/*
+ * Packet/Time period missed in the wireless adapter due to
+ * "wireless" specific problems...
+ */
+struct iw_missed
+{
+ __u32 beacon; /* Missed beacons/superframe */
+};
+
+/*
+ * Quality range (for spy threshold)
+ */
+struct iw_thrspy
+{
+ struct sockaddr addr; /* Source address (hw/mac) */
+ struct iw_quality qual; /* Quality of the link */
+ struct iw_quality low; /* Low threshold */
+ struct iw_quality high; /* High threshold */
+};
+
+/*
+ * Optional data for scan request
+ *
+ * Note: these optional parameters are controlling parameters for the
+ * scanning behavior, these do not apply to getting scan results
+ * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and
+ * provide a merged results with all BSSes even if the previous scan
+ * request limited scanning to a subset, e.g., by specifying an SSID.
+ * Especially, scan results are required to include an entry for the
+ * current BSS if the driver is in Managed mode and associated with an AP.
+ */
+struct iw_scan_req
+{
+ __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */
+ __u8 essid_len;
+ __u8 num_channels; /* num entries in channel_list;
+ * 0 = scan all allowed channels */
+ __u8 flags; /* reserved as padding; use zero, this may
+ * be used in the future for adding flags
+ * to request different scan behavior */
+ struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or
+ * individual address of a specific BSS */
+
+ /*
+ * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using
+ * the current ESSID. This allows scan requests for specific ESSID
+ * without having to change the current ESSID and potentially breaking
+ * the current association.
+ */
+ __u8 essid[IW_ESSID_MAX_SIZE];
+
+ /*
+ * Optional parameters for changing the default scanning behavior.
+ * These are based on the MLME-SCAN.request from IEEE Std 802.11.
+ * TU is 1.024 ms. If these are set to 0, driver is expected to use
+ * reasonable default values. min_channel_time defines the time that
+ * will be used to wait for the first reply on each channel. If no
+ * replies are received, next channel will be scanned after this. If
+ * replies are received, total time waited on the channel is defined by
+ * max_channel_time.
+ */
+ __u32 min_channel_time; /* in TU */
+ __u32 max_channel_time; /* in TU */
+
+ struct iw_freq channel_list[IW_MAX_FREQUENCIES];
+};
+
+/* ------------------------- WPA SUPPORT ------------------------- */
+
+/*
+ * Extended data structure for get/set encoding (this is used with
+ * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_*
+ * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and
+ * only the data contents changes (key data -> this structure, including
+ * key data).
+ *
+ * If the new key is the first group key, it will be set as the default
+ * TX key. Otherwise, default TX key index is only changed if
+ * IW_ENCODE_EXT_SET_TX_KEY flag is set.
+ *
+ * Key will be changed with SIOCSIWENCODEEXT in all cases except for
+ * special "change TX key index" operation which is indicated by setting
+ * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY.
+ *
+ * tx_seq/rx_seq are only used when respective
+ * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal
+ * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start
+ * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally
+ * used only by an Authenticator (AP or an IBSS station) to get the
+ * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and
+ * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for
+ * debugging/testing.
+ */
+struct iw_encode_ext
+{
+ __u32 ext_flags; /* IW_ENCODE_EXT_* */
+ __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+ __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+ struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast
+ * (group) keys or unicast address for
+ * individual keys */
+ __u16 alg; /* IW_ENCODE_ALG_* */
+ __u16 key_len;
+ __u8 key[0];
+};
+
+/* SIOCSIWMLME data */
+struct iw_mlme
+{
+ __u16 cmd; /* IW_MLME_* */
+ __u16 reason_code;
+ struct sockaddr addr;
+};
+
+/* SIOCSIWPMKSA data */
+#define IW_PMKSA_ADD 1
+#define IW_PMKSA_REMOVE 2
+#define IW_PMKSA_FLUSH 3
+
+#define IW_PMKID_LEN 16
+
+struct iw_pmksa
+{
+ __u32 cmd; /* IW_PMKSA_* */
+ struct sockaddr bssid;
+ __u8 pmkid[IW_PMKID_LEN];
+};
+
+/* IWEVMICHAELMICFAILURE data */
+struct iw_michaelmicfailure
+{
+ __u32 flags;
+ struct sockaddr src_addr;
+ __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */
+};
+
+/* IWEVPMKIDCAND data */
+#define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */
+struct iw_pmkid_cand
+{
+ __u32 flags; /* IW_PMKID_CAND_* */
+ __u32 index; /* the smaller the index, the higher the
+ * priority */
+ struct sockaddr bssid;
+};
+
+/* ------------------------ WIRELESS STATS ------------------------ */
+/*
+ * Wireless statistics (used for /proc/net/wireless)
+ */
+struct iw_statistics
+{
+ __u16 status; /* Status
+ * - device dependent for now */
+
+ struct iw_quality qual; /* Quality of the link
+ * (instant/mean/max) */
+ struct iw_discarded discard; /* Packet discarded counts */
+ struct iw_missed miss; /* Packet missed counts */
+};
+
+/* ------------------------ IOCTL REQUEST ------------------------ */
+/*
+ * This structure defines the payload of an ioctl, and is used
+ * below.
+ *
+ * Note that this structure should fit on the memory footprint
+ * of iwreq (which is the same as ifreq), which mean a max size of
+ * 16 octets = 128 bits. Warning, pointers might be 64 bits wide...
+ * You should check this when increasing the structures defined
+ * above in this file...
+ */
+union iwreq_data
+{
+ /* Config - generic */
+ char name[IFNAMSIZ];
+ /* Name : used to verify the presence of wireless extensions.
+ * Name of the protocol/provider... */
+
+ struct iw_point essid; /* Extended network name */
+ struct iw_param nwid; /* network id (or domain - the cell) */
+ struct iw_freq freq; /* frequency or channel :
+ * 0-1000 = channel
+ * > 1000 = frequency in Hz */
+
+ struct iw_param sens; /* signal level threshold */
+ struct iw_param bitrate; /* default bit rate */
+ struct iw_param txpower; /* default transmit power */
+ struct iw_param rts; /* RTS threshold threshold */
+ struct iw_param frag; /* Fragmentation threshold */
+ __u32 mode; /* Operation mode */
+ struct iw_param retry; /* Retry limits & lifetime */
+
+ struct iw_point encoding; /* Encoding stuff : tokens */
+ struct iw_param power; /* PM duration/timeout */
+ struct iw_quality qual; /* Quality part of statistics */
+
+ struct sockaddr ap_addr; /* Access point address */
+ struct sockaddr addr; /* Destination address (hw/mac) */
+
+ struct iw_param param; /* Other small parameters */
+ struct iw_point data; /* Other large parameters */
+};
+
+/*
+ * The structure to exchange data for ioctl.
+ * This structure is the same as 'struct ifreq', but (re)defined for
+ * convenience...
+ * Do I need to remind you about structure size (32 octets) ?
+ */
+struct iwreq
+{
+ union
+ {
+ char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */
+ } ifr_ifrn;
+
+ /* Data part (defined just above) */
+ union iwreq_data u;
+};
+
+/* -------------------------- IOCTL DATA -------------------------- */
+/*
+ * For those ioctl which want to exchange mode data that what could
+ * fit in the above structure...
+ */
+
+/*
+ * Range of parameters
+ */
+
+struct iw_range
+{
+ /* Informative stuff (to choose between different interface) */
+ __u32 throughput; /* To give an idea... */
+ /* In theory this value should be the maximum benchmarked
+ * TCP/IP throughput, because with most of these devices the
+ * bit rate is meaningless (overhead an co) to estimate how
+ * fast the connection will go and pick the fastest one.
+ * I suggest people to play with Netperf or any benchmark...
+ */
+
+ /* NWID (or domain id) */
+ __u32 min_nwid; /* Minimal NWID we are able to set */
+ __u32 max_nwid; /* Maximal NWID we are able to set */
+
+ /* Old Frequency (backward compat - moved lower ) */
+ __u16 old_num_channels;
+ __u8 old_num_frequency;
+
+ /* Wireless event capability bitmasks */
+ __u32 event_capa[6];
+
+ /* signal level threshold range */
+ __s32 sensitivity;
+
+ /* Quality of link & SNR stuff */
+ /* Quality range (link, level, noise)
+ * If the quality is absolute, it will be in the range [0 ; max_qual],
+ * if the quality is dBm, it will be in the range [max_qual ; 0].
+ * Don't forget that we use 8 bit arithmetics... */
+ struct iw_quality max_qual; /* Quality of the link */
+ /* This should contain the average/typical values of the quality
+ * indicator. This should be the threshold between a "good" and
+ * a "bad" link (example : monitor going from green to orange).
+ * Currently, user space apps like quality monitors don't have any
+ * way to calibrate the measurement. With this, they can split
+ * the range between 0 and max_qual in different quality level
+ * (using a geometric subdivision centered on the average).
+ * I expect that people doing the user space apps will feedback
+ * us on which value we need to put in each driver... */
+ struct iw_quality avg_qual; /* Quality of the link */
+
+ /* Rates */
+ __u8 num_bitrates; /* Number of entries in the list */
+ __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */
+
+ /* RTS threshold */
+ __s32 min_rts; /* Minimal RTS threshold */
+ __s32 max_rts; /* Maximal RTS threshold */
+
+ /* Frag threshold */
+ __s32 min_frag; /* Minimal frag threshold */
+ __s32 max_frag; /* Maximal frag threshold */
+
+ /* Power Management duration & timeout */
+ __s32 min_pmp; /* Minimal PM period */
+ __s32 max_pmp; /* Maximal PM period */
+ __s32 min_pmt; /* Minimal PM timeout */
+ __s32 max_pmt; /* Maximal PM timeout */
+ __u16 pmp_flags; /* How to decode max/min PM period */
+ __u16 pmt_flags; /* How to decode max/min PM timeout */
+ __u16 pm_capa; /* What PM options are supported */
+
+ /* Encoder stuff */
+ __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */
+ __u8 num_encoding_sizes; /* Number of entry in the list */
+ __u8 max_encoding_tokens; /* Max number of tokens */
+ /* For drivers that need a "login/passwd" form */
+ __u8 encoding_login_index; /* token index for login token */
+
+ /* Transmit power */
+ __u16 txpower_capa; /* What options are supported */
+ __u8 num_txpower; /* Number of entries in the list */
+ __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */
+
+ /* Wireless Extension version info */
+ __u8 we_version_compiled; /* Must be WIRELESS_EXT */
+ __u8 we_version_source; /* Last update of source */
+
+ /* Retry limits and lifetime */
+ __u16 retry_capa; /* What retry options are supported */
+ __u16 retry_flags; /* How to decode max/min retry limit */
+ __u16 r_time_flags; /* How to decode max/min retry life */
+ __s32 min_retry; /* Minimal number of retries */
+ __s32 max_retry; /* Maximal number of retries */
+ __s32 min_r_time; /* Minimal retry lifetime */
+ __s32 max_r_time; /* Maximal retry lifetime */
+
+ /* Frequency */
+ __u16 num_channels; /* Number of channels [0; num - 1] */
+ __u8 num_frequency; /* Number of entry in the list */
+ struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */
+ /* Note : this frequency list doesn't need to fit channel numbers,
+ * because each entry contain its channel index */
+
+ __u32 enc_capa; /* IW_ENC_CAPA_* bit field */
+
+ /* More power management stuff */
+ __s32 min_pms; /* Minimal PM saving */
+ __s32 max_pms; /* Maximal PM saving */
+ __u16 pms_flags; /* How to decode max/min PM saving */
+
+ /* All available modulations for driver (hw may support less) */
+ __s32 modul_capa; /* IW_MODUL_* bit field */
+
+ /* More bitrate stuff */
+ __u32 bitrate_capa; /* Types of bitrates supported */
+};
+
+/*
+ * Private ioctl interface information
+ */
+
+struct iw_priv_args
+{
+ __u32 cmd; /* Number of the ioctl to issue */
+ __u16 set_args; /* Type and number of args */
+ __u16 get_args; /* Type and number of args */
+ char name[IFNAMSIZ]; /* Name of the extension */
+};
+
+/* ----------------------- WIRELESS EVENTS ----------------------- */
+/*
+ * Wireless events are carried through the rtnetlink socket to user
+ * space. They are encapsulated in the IFLA_WIRELESS field of
+ * a RTM_NEWLINK message.
+ */
+
+/*
+ * A Wireless Event. Contains basically the same data as the ioctl...
+ */
+struct iw_event
+{
+ __u16 len; /* Real lenght of this stuff */
+ __u16 cmd; /* Wireless IOCTL */
+ union iwreq_data u; /* IOCTL fixed payload */
+};
+
+/* Size of the Event prefix (including padding and alignement junk) */
+#define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data))
+/* Size of the various events */
+#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ)
+#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32))
+#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq))
+#define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param))
+#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr))
+#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality))
+
+/* iw_point events are special. First, the payload (extra data) come at
+ * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second,
+ * we omit the pointer, so start at an offset. */
+#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \
+ (char *) NULL)
+#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \
+ IW_EV_POINT_OFF)
+
+#endif /* _LINUX_WIRELESS_H */
diff --git a/src/Makefile.am b/src/Makefile.am
index fbfbeaee1..b95813220 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -97,6 +97,7 @@ neutrino_LDADD = \
$(top_builddir)/lib/libmd5sum/libtuxbox-md5sum.a \
$(top_builddir)/lib/libtuxtxt/libtuxtxt.a \
$(top_builddir)/lib/libdvbsub/libdvbsub.a \
+ $(top_builddir)/lib/libiw/libiw.a \
@CURL_LIBS@ \
@FREETYPE_LIBS@ \
@PNG_LIBS@ \
diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp
index ca6649176..31f008a17 100644
--- a/src/driver/framebuffer.cpp
+++ b/src/driver/framebuffer.cpp
@@ -459,14 +459,14 @@ unsigned int CFrameBuffer::getScreenHeight(bool real)
unsigned int CFrameBuffer::getScreenWidthRel(bool force_small)
{
- int percent = force_small ? WINDOW_SIZE_MIN : g_settings.window_size;
+ int percent = force_small ? WINDOW_SIZE_MIN_FORCED : g_settings.window_width;
// always reduce a possible detailline
return (g_settings.screen_EndX - g_settings.screen_StartX - 2*ConnectLineBox_Width) * percent / 100;
}
unsigned int CFrameBuffer::getScreenHeightRel(bool force_small)
{
- int percent = force_small ? WINDOW_SIZE_MIN : g_settings.window_size;
+ int percent = force_small ? WINDOW_SIZE_MIN_FORCED : g_settings.window_height;
return (g_settings.screen_EndY - g_settings.screen_StartY) * percent / 100;
}
diff --git a/src/driver/framebuffer.h b/src/driver/framebuffer.h
index 6c4181419..6f8a01e5c 100644
--- a/src/driver/framebuffer.h
+++ b/src/driver/framebuffer.h
@@ -57,7 +57,8 @@ typedef struct fb_var_screeninfo t_fb_var_screeninfo;
#define FADE_RESET 0xFFFF
#define WINDOW_SIZE_MAX 100 // %
-#define WINDOW_SIZE_MIN 80 // %
+#define WINDOW_SIZE_MIN 50 // %
+#define WINDOW_SIZE_MIN_FORCED 80 // %
#define ConnectLineBox_Width 16 // px
/** Ausfuehrung als Singleton */
diff --git a/src/driver/rcinput.cpp b/src/driver/rcinput.cpp
index 9c83a041e..42c82303c 100644
--- a/src/driver/rcinput.cpp
+++ b/src/driver/rcinput.cpp
@@ -136,7 +136,7 @@ CRCInput::CRCInput()
}
- if (listen(fd_event, 15) !=0)
+ if (listen(fd_event, 25) !=0)
{
perror("[neutrino] listen failed...\n");
exit( -1 );
diff --git a/src/driver/volume.cpp b/src/driver/volume.cpp
index 624fd4a78..60d453e65 100644
--- a/src/driver/volume.cpp
+++ b/src/driver/volume.cpp
@@ -126,11 +126,6 @@ void CVolume::setVolume(const neutrino_msg_t key)
hideVolscale();
if (do_vol) {
CAudioMute::getInstance()->AudioMute(false, true);
- if (mode == CNeutrinoApp::mode_audio) {
- CAudioPlayerGui *cap = CMediaPlayerMenu::getInstance()->getPlayerInstance();
- if (cap != NULL)
- cap->refreshMuteIcon();
- }
setVolume(msg);
return;
}
@@ -148,11 +143,6 @@ void CVolume::setVolume(const neutrino_msg_t key)
if (g_settings.show_mute_icon) {
hideVolscale();
CAudioMute::getInstance()->AudioMute(true, true);
- if (mode == CNeutrinoApp::mode_audio) {
- CAudioPlayerGui *cap = CMediaPlayerMenu::getInstance()->getPlayerInstance();
- if (cap != NULL)
- cap->refreshMuteIcon();
- }
setVolume(msg);
return;
}
diff --git a/src/eitd/edvbstring.cpp b/src/eitd/edvbstring.cpp
index a896b8914..fa0fa1459 100644
--- a/src/eitd/edvbstring.cpp
+++ b/src/eitd/edvbstring.cpp
@@ -1599,7 +1599,7 @@ const unsigned short cGB2312UNI[] = {
// Two Char Mapping ( many polish services and UPC Direct/HBO services)
// get from http://mitglied.lycos.de/buran/charsets/videotex-suppl.html
//static inline unsigned int doVideoTexSuppl(int c1, int c2)
-static inline unsigned int doVideoTexSuppl(char c1, char c2)
+static inline unsigned int doVideoTexSuppl(unsigned char c1, unsigned char c2)
{
switch (c1)
{
diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am
index 8bd95f44b..5cbed366e 100644
--- a/src/gui/Makefile.am
+++ b/src/gui/Makefile.am
@@ -95,7 +95,6 @@ libneutrino_gui_a_SOURCES = \
start_wizard.cpp \
streaminfo2.cpp \
subchannel_select.cpp \
- test_menu.cpp \
themes.cpp \
timeosd.cpp \
update.cpp \
@@ -113,6 +112,11 @@ libneutrino_gui_a_SOURCES += \
update_ext.cpp
endif
+if ENABLE_TEST_MENU
+libneutrino_gui_a_SOURCES += \
+ test_menu.cpp
+endif
+
libneutrino_gui_a_SOURCES += \
luainstance.cpp
diff --git a/src/gui/audio_setup.cpp b/src/gui/audio_setup.cpp
index e28384740..10f1dbf59 100644
--- a/src/gui/audio_setup.cpp
+++ b/src/gui/audio_setup.cpp
@@ -157,16 +157,19 @@ int CAudioSetup::showAudioSetup()
CMenuOptionChooser * as_oj_dd_spdif = new CMenuOptionChooser(LOCALE_AUDIOMENU_SPDIF_DD, &g_settings.spdif_dd, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier);
as_oj_dd_spdif->setHint("", LOCALE_MENU_HINT_AUDIO_SPDIF_DD);
- //av synch
- CMenuOptionChooser * as_oj_avsync = new CMenuOptionChooser(LOCALE_AUDIOMENU_AVSYNC, &g_settings.avsync, AUDIOMENU_AVSYNC_OPTIONS, AUDIOMENU_AVSYNC_OPTION_COUNT, true, audioSetupNotifier);
- as_oj_avsync->setHint("", LOCALE_MENU_HINT_AUDIO_AVSYNC);
+ CMenuOptionChooser * as_oj_avsync = NULL;
+ CMenuOptionNumberChooser * as_oj_vsteps = NULL;
+ if (!g_settings.easymenu) {
+ //av synch
+ as_oj_avsync = new CMenuOptionChooser(LOCALE_AUDIOMENU_AVSYNC, &g_settings.avsync, AUDIOMENU_AVSYNC_OPTIONS, AUDIOMENU_AVSYNC_OPTION_COUNT, true, audioSetupNotifier);
+ as_oj_avsync->setHint("", LOCALE_MENU_HINT_AUDIO_AVSYNC);
- //volume steps
- CMenuOptionNumberChooser * as_oj_vsteps = new CMenuOptionNumberChooser(LOCALE_AUDIOMENU_VOLUME_STEP, (int *)&g_settings.current_volume_step, true, 1, 25, NULL);
- as_oj_vsteps->setHint("", LOCALE_MENU_HINT_AUDIO_VOLSTEP);
-
- //clock rec
-// CMenuOptionChooser * as_oj_clockrec new CMenuOptionChooser(LOCALE_AUDIOMENU_CLOCKREC, &g_settings.clockrec, AUDIOMENU_CLOCKREC_OPTIONS, AUDIOMENU_CLOCKREC_OPTION_COUNT, true, audioSetupNotifier);
+ //volume steps
+ as_oj_vsteps = new CMenuOptionNumberChooser(LOCALE_AUDIOMENU_VOLUME_STEP, (int *)&g_settings.current_volume_step, true, 1, 25, NULL);
+ as_oj_vsteps->setHint("", LOCALE_MENU_HINT_AUDIO_VOLSTEP);
+ //clock rec
+ //CMenuOptionChooser * as_oj_clockrec new CMenuOptionChooser(LOCALE_AUDIOMENU_CLOCKREC, &g_settings.clockrec, AUDIOMENU_CLOCKREC_OPTIONS, AUDIOMENU_CLOCKREC_OPTION_COUNT, true, audioSetupNotifier);
+ }
#if HAVE_COOL_HARDWARE
/* only coolstream has SRS stuff, so only compile it there */
@@ -204,11 +207,13 @@ int CAudioSetup::showAudioSetup()
audioSettings->addItem(as_oj_dd_hdmi);
audioSettings->addItem(as_oj_dd_spdif);
audioSettings->addItem(as_oj_ddsubchn);
- audioSettings->addItem(GenericMenuSeparatorLine);
//---------------------------------------------------------
- audioSettings->addItem(as_oj_avsync);
- audioSettings->addItem(as_oj_vsteps);
-// audioSettings->addItem(as_clockrec);
+ if (!g_settings.easymenu) {
+ audioSettings->addItem(GenericMenuSeparatorLine);
+ audioSettings->addItem(as_oj_avsync);
+ audioSettings->addItem(as_oj_vsteps);
+ //audioSettings->addItem(as_clockrec);
+ }
//---------------------------------------------------------
#if HAVE_COOL_HARDWARE
/* only coolstream has SRS stuff, so only compile it there */
diff --git a/src/gui/audiomute.cpp b/src/gui/audiomute.cpp
index 3fb627994..88c0533e8 100644
--- a/src/gui/audiomute.cpp
+++ b/src/gui/audiomute.cpp
@@ -62,7 +62,7 @@ void CAudioMute::AudioMute(int newValue, bool isEvent)
neutrino->setCurrentMuted(newValue);
g_Zapit->muteAudio(newValue);
- if( isEvent && ( neutrino->getMode() != CNeutrinoApp::mode_scart ) && ( neutrino->getMode() != CNeutrinoApp::mode_audio) && ( neutrino->getMode() != CNeutrinoApp::mode_pic))
+ if( isEvent && ( neutrino->getMode() != CNeutrinoApp::mode_scart ) && ( neutrino->getMode() != CNeutrinoApp::mode_pic))
{
CVolumeHelper::getInstance()->getMuteIconDimensions(&x, &y, &width, &height);
if ((y_old != y)) {
@@ -94,12 +94,6 @@ void CAudioMute::AudioMute(int newValue, bool isEvent)
if (doInit)
CVolumeHelper::getInstance()->refresh();
}
- else if (neutrino->getMode() == CNeutrinoApp::mode_audio) {
- if (newValue)
- frameBuffer->setFbArea(CFrameBuffer::FB_PAINTAREA_MUTEICON1, x, y, width, height);
- else
- frameBuffer->setFbArea(CFrameBuffer::FB_PAINTAREA_MUTEICON1);
- }
}
void CAudioMute::enableMuteIcon(bool enable)
diff --git a/src/gui/audiomute.h b/src/gui/audiomute.h
index 2c2310c0e..406483f18 100644
--- a/src/gui/audiomute.h
+++ b/src/gui/audiomute.h
@@ -27,7 +27,7 @@
#ifndef __CAUDIOMUTE__
#define __CAUDIOMUTE__
-#include
+#include
class CAudioMute : public CComponentsPicture
{
diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp
index 568c3a189..3aa6e2a0e 100644
--- a/src/gui/audioplayer.cpp
+++ b/src/gui/audioplayer.cpp
@@ -58,7 +58,7 @@
#include
#endif
-#include
+#include
#include
#include
#include
@@ -282,8 +282,6 @@ int CAudioPlayerGui::exec(CMenuTarget* parent, const std::string &actionKey)
m_fheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight();
int iw, ih;
- m_frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE, &iw, &ih);
- m_theight = std::max(m_theight, ih+2);
m_frameBuffer->getIconSize(NEUTRINO_ICON_MP3, &iw, &ih);
m_theight = std::max(m_theight, ih+4);
@@ -614,7 +612,7 @@ int CAudioPlayerGui::show()
if (m_key_level == 1)
stop();
}
- else if (msg == CRCInput::RC_green)
+ else if ((msg == CRCInput::RC_rewind) || (msg == CRCInput::RC_green))
{
if (m_key_level == 0)
{
@@ -656,7 +654,7 @@ int CAudioPlayerGui::show()
}
}
}
- else if (msg == CRCInput::RC_yellow)
+ else if ((msg == CRCInput::RC_pause) || (msg == CRCInput::RC_yellow))
{
if (m_key_level == 0)
{
@@ -680,7 +678,7 @@ int CAudioPlayerGui::show()
paint();
}
}
- else if (msg == CRCInput::RC_blue)
+ else if ((msg == CRCInput::RC_forward) || (msg == CRCInput::RC_blue))
{
if (m_key_level == 0)
{
@@ -902,8 +900,6 @@ int CAudioPlayerGui::show()
ret = menu_return::RETURN_EXIT_ALL;
loop = false;
}
- // update mute icon
- paintHead();
paintLCD();
}
}
@@ -1646,14 +1642,11 @@ void CAudioPlayerGui::paintHead()
return;
CComponentsHeader header(m_x, m_y + m_title_height, m_width, m_theight, LOCALE_AUDIOPLAYER_HEAD, NEUTRINO_ICON_MP3);
- header.setCorner(RADIUS_MID);
+ header.setCorner(RADIUS_MID, CORNER_TOP);
if (m_inetmode)
header.setCaption(LOCALE_INETRADIO_NAME);
- if (CNeutrinoApp::getInstance()->isMuted())
- header.addButtonIcon(NEUTRINO_ICON_BUTTON_MUTE_SMALL);
-
#ifdef ENABLE_GUI_MOUNT
if (!m_inetmode)
header.addButtonIcon(NEUTRINO_ICON_BUTTON_MENU);
@@ -1666,10 +1659,10 @@ void CAudioPlayerGui::paintHead()
const struct button_label AudioPlayerButtons[][4] =
{
{
- { NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_STOP },
- { NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_REWIND },
- { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_PAUSE },
- { NEUTRINO_ICON_BUTTON_BLUE , LOCALE_AUDIOPLAYER_FASTFORWARD },
+ { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP },
+ { NEUTRINO_ICON_BUTTON_BACKWARD, LOCALE_AUDIOPLAYER_REWIND },
+ { NEUTRINO_ICON_BUTTON_PAUSE , LOCALE_AUDIOPLAYER_PAUSE },
+ { NEUTRINO_ICON_BUTTON_FORWARD , LOCALE_AUDIOPLAYER_FASTFORWARD },
},
{
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_DELETE },
@@ -1694,8 +1687,8 @@ const struct button_label AudioPlayerButtons[][4] =
{ NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_BUTTON_SELECT_TITLE_BY_NAME },
},
{
- { NEUTRINO_ICON_BUTTON_RED , LOCALE_AUDIOPLAYER_STOP },
- { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_AUDIOPLAYER_PAUSE },
+ { NEUTRINO_ICON_BUTTON_STOP , LOCALE_AUDIOPLAYER_STOP },
+ { NEUTRINO_ICON_BUTTON_PAUSE , LOCALE_AUDIOPLAYER_PAUSE },
},
{
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_AUDIOPLAYER_ADD },
diff --git a/src/gui/audioplayer.h b/src/gui/audioplayer.h
index 8ed6eb5f8..74284ed4a 100644
--- a/src/gui/audioplayer.h
+++ b/src/gui/audioplayer.h
@@ -261,7 +261,6 @@ class CAudioPlayerGui : public CMenuTarget
bool playNext(bool allow_rotate = false);
bool playPrev(bool allow_rotate = false);
int getAudioPlayerM_current() {return m_current;}
- void refreshMuteIcon() { paintHead(); }
};
diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp
index 325a9ae9f..28c961667 100644
--- a/src/gui/bedit/bouqueteditor_bouquets.cpp
+++ b/src/gui/bedit/bouqueteditor_bouquets.cpp
@@ -40,7 +40,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp
index 829a14900..12e4b55fe 100644
--- a/src/gui/bedit/bouqueteditor_channels.cpp
+++ b/src/gui/bedit/bouqueteditor_channels.cpp
@@ -44,7 +44,7 @@
#include
#include
#include "bouqueteditor_chanselect.h"
-#include
+#include
#include
#include
diff --git a/src/gui/bedit/bouqueteditor_channels.h b/src/gui/bedit/bouqueteditor_channels.h
index afc74a4b1..90d4d03d4 100644
--- a/src/gui/bedit/bouqueteditor_channels.h
+++ b/src/gui/bedit/bouqueteditor_channels.h
@@ -35,8 +35,7 @@
#include
#include
-#include
-#include
+#include
#include
#include
diff --git a/src/gui/bedit/bouqueteditor_chanselect.h b/src/gui/bedit/bouqueteditor_chanselect.h
index 6ae293c87..729c3d7af 100644
--- a/src/gui/bedit/bouqueteditor_chanselect.h
+++ b/src/gui/bedit/bouqueteditor_chanselect.h
@@ -34,8 +34,7 @@
#include
#include
-#include
-#include
+#include
#include
#include
diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp
index f8affa75e..045c62222 100644
--- a/src/gui/bookmarkmanager.cpp
+++ b/src/gui/bookmarkmanager.cpp
@@ -37,7 +37,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/gui/bouquetlist.cpp b/src/gui/bouquetlist.cpp
index 361b132c3..c8a7af8d6 100644
--- a/src/gui/bouquetlist.cpp
+++ b/src/gui/bouquetlist.cpp
@@ -41,7 +41,7 @@
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp
index a541d628e..45e42b6f0 100644
--- a/src/gui/cam_menu.cpp
+++ b/src/gui/cam_menu.cpp
@@ -107,12 +107,14 @@ int CCAMMenuHandler::doMainMenu()
//cammenu->addItem( GenericMenuSeparatorLine );
cammenu->addIntroItems();
- if(CiSlots) {
- cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_RESET_STANDBY, &g_settings.ci_standby_reset, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
- cammenu->addItem( new CMenuOptionNumberChooser(LOCALE_CI_CLOCK, &g_settings.ci_clock, true, 6, 12, this));
+ if (!g_settings.easymenu) {
+ if(CiSlots) {
+ cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_RESET_STANDBY, &g_settings.ci_standby_reset, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
+ cammenu->addItem( new CMenuOptionNumberChooser(LOCALE_CI_CLOCK, &g_settings.ci_clock, true, 6, 12, this));
+ }
+ cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_IGNORE_MSG, &g_settings.ci_ignore_messages, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
+ cammenu->addItem( GenericMenuSeparatorLine );
}
- cammenu->addItem( new CMenuOptionChooser(LOCALE_CI_IGNORE_MSG, &g_settings.ci_ignore_messages, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true));
- cammenu->addItem( GenericMenuSeparatorLine );
CMenuWidget * tempMenu;
int i = 0;
diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp
index edd9c4369..3e16f1985 100644
--- a/src/gui/channellist.cpp
+++ b/src/gui/channellist.cpp
@@ -57,9 +57,6 @@
#include
#include
#include
-#include
-#include
-#include
#include
#include
@@ -2137,8 +2134,8 @@ void CChannelList::paintHead()
headerClock->setCorner(RADIUS_LARGE, CORNER_TOP_RIGHT);
headerClock->setYPos(y);
headerClock->setHeight(theight);
- headerClock->setTextColor(COL_MENUHEAD_TEXT);
- headerClock->setColorBody(COL_MENUHEAD_PLUS_0);
+ headerClock->setTextColor(header.getTextObject()->getTextColor());
+ headerClock->setColorBody(header.getColorBody());
headerClock->refresh();
headerClockWidth = headerClock->getWidth();
headerClock->setXPos(x + full_width - headerClockWidth - 10);
diff --git a/src/gui/channellist.h b/src/gui/channellist.h
index da8600dfc..c6e3f310c 100644
--- a/src/gui/channellist.h
+++ b/src/gui/channellist.h
@@ -36,8 +36,6 @@
#include
#include
#include
-#include
-#include
#include
#include
diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h
index 6426285fe..9f13752e2 100644
--- a/src/gui/components/cc.h
+++ b/src/gui/components/cc.h
@@ -3,7 +3,7 @@
Copyright (C) 2001 by Steffen Hehn 'McClean'
Classes for generic GUI-related components.
- Copyright (C) 2012, 2013, Thilo Graf 'dbt'
+ Copyright (C) 2013, Thilo Graf 'dbt'
License: GPL
@@ -23,255 +23,30 @@
Boston, MA 02110-1301, USA.
*/
-#ifndef __COMPONENTS__
-#define __COMPONENTS__
-
-#include "cc_types.h"
-#include
-#include
-#include
-#include
-
-//#define DEBUG_CC
-
-/// Basic component class.
+/// Basic CComponent class header.
/*!
Basic attributes and member functions for component sub classes
*/
-class CComponents
-{
- private:
- ///pixel buffer handling, returns pixel buffer depends of given parameters
- fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
-
- protected:
- ///object: framebuffer object, usable in all sub classes
- CFrameBuffer * frameBuffer;
- ///container: for frambuffer properties and pixel buffer
- std::vector v_fbdata;
+#ifndef __N_COMPONENTS__
+#define __N_COMPONENTS__
- ///property: x-position on screen, to alter with setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
- int x;
- ///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
- int y;
- ///property: contains real x-position on screen
- int cc_xr;
- ///property: contains real y-position on screen
- int cc_yr;
- ///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll()
- int height;
- ///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll()
- int width;
- ///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0
- int corner_type;
- ///property: defined radius of corner, without effect, if corner_type=0
- int corner_rad;
-
- ///property: color of body
- fb_pixel_t col_body;
- ///property: color of shadow
- fb_pixel_t col_shadow;
- ///property: color of frame
- fb_pixel_t col_frame;
- ///property: color of frame if component is selected, Note: fr_thickness_sel must be set
- fb_pixel_t col_frame_sel;
+#include "cc_base.h"
+#include "cc_types.h"
- ///property: true=component has shadow
- bool shadow;
- ///property: width of shadow
- int shadow_w;
+#include "cc_item_infobox.h"
+#include "cc_item_picture.h"
+#include "cc_item_progressbar.h"
+#include "cc_item_shapes.h"
+#include "cc_item_tvpic.h"
- ///property: frame thickness
- int fr_thickness;
- ///property: frame thickness of selected component
- int fr_thickness_sel;
+#include "cc_detailsline.h"
- ///status: true=component was painted for 1st time
- bool firstPaint;
- ///status: true=component was rendered
- bool is_painted;
- ///mode: true=activate rendering of basic elements (frame, shadow and body)
- bool paint_bg;
+#include "cc_frm.h"
+#include "cc_frm_button.h"
+#include "cc_frm_clock.h"
+#include "cc_frm_signalbars.h"
- ///initialize of basic attributes, no parameters required
- void initVarBasic();
- ///rendering of framebuffer elements at once,
- ///elements are contained in v_fbdata, presumes added frambuffer elements with paintInit(),
- ///parameter do_save_bg=true, saves background of element to pixel buffer, this can be restore with hide()
- void paintFbItems(bool do_save_bg = true);
- ///clean up old screen buffer saved in v_fbdata
- virtual void clear();
- ///container: contains saved pixel buffer with position and dimensions
- comp_screen_data_t saved_screen;
- ///cleans saved pixel buffer
- void clearSavedScreen();
-
- public:
- ///basic component class constructor.
- CComponents();
- virtual~CComponents();
-
- ///set screen x-position
- inline virtual void setXPos(const int& xpos){x = xpos;};
- ///set screen y-position,
- inline virtual void setYPos(const int& ypos){y = ypos;};
- ///set x and y position
- ///Note: position of bound components (items) means position related within parent form, not for screen!
- ///to set the real screen position, look at setRealPos()
- inline virtual void setPos(const int& xpos, const int& ypos){x = xpos; y = ypos;};
-
- ///sets real x position on screen. Use this, if item is added to a parent form
- virtual void setRealXPos(const int& xr){cc_xr = xr;};
- ///sets real y position on screen. Use this, if item is added to a parent form
- virtual void setRealYPos(const int& yr){cc_yr = yr;};
- ///sets real x and y position on screen at once. Use this, if item is added to a parent form
- virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;};
- ///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form
- virtual int getRealXPos(){return cc_xr;};
- ///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form
- virtual int getRealYPos(){return cc_yr;};
-
- ///set height of component on screen
- inline virtual void setHeight(const int& h){height = h;};
- ///set width of component on screen
- inline virtual void setWidth(const int& w){width = w;};
- ///set all positions and dimensions of component at once
- inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
-
- ///return screen x-position of component
- ///Note: position of bound components (items) means position related within parent form, not for screen!
- ///to get the real screen position, use getRealXPos(), to find in CComponentsItem sub classes
- inline virtual int getXPos(){return x;};
- ///return screen y-position of component
- ///Note: position of bound components (items) means position related within parent form, not for screen!
- ///to get the real screen position, use getRealYPos(), to find in CComponentsItem sub classes
- inline virtual int getYPos(){return y;};
- ///return height of component
- inline virtual int getHeight(){return height;};
- ///return width of component
- inline virtual int getWidth(){return width;};
- ///return of frame thickness
- inline virtual int getFrameThickness(){return fr_thickness;};
-
- ///return/set (pass through) width and height of component
- inline virtual void getSize(int* w, int* h){*w=width; *h=height;};
- ///return/set (pass through) position and dimensions of component at once
- inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;};
-
- ///set frame color
- inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
- ///set body color
- inline virtual void setColorBody(fb_pixel_t color){col_body = color;};
- ///set shadow color
- inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;};
- ///set all basic framebuffer element colors at once
- ///Note: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
- inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
-
- ///get frame color
- inline virtual fb_pixel_t getColorFrame(){return col_frame;};
- ///get body color
- inline virtual fb_pixel_t getColorBody(){return col_body;};
- ///get shadow color
- inline virtual fb_pixel_t getColorShadow(){return col_shadow;};
-
- ///set corner types
- ///Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h)
- ///Note: default values are given from settings
- inline virtual void setCornerType(const int& type){corner_type = type;};
- ///set corner radius and type
- inline virtual void setCorner(const int& radius, const int& type = CORNER_ALL){corner_rad = radius; corner_type = type;};
- ///get corner types
- inline virtual int getCornerType(){return corner_type;};
- ///get corner radius
- inline virtual int getCornerRadius(){return corner_rad;};
-
- ///set frame thickness
- inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
- ///switch shadow on/off
- ///Note: it's recommended to use #defines: CC_SHADOW_ON=true or CC_SHADOW_OFF=false as parameter, see also cc_types.h
- inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
-
- ///hide current screen and restore background
- virtual void hide();
- ///erase current screen without restore of background, it's similar to paintBackgroundBoxRel() from CFrameBuffer
- virtual void kill();
- ///returns paint mode, true=item was painted
- virtual bool isPainted(){return is_painted;}
- ///allows paint of elementary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form
- virtual void doPaintBg(bool do_paint){paint_bg = do_paint;};
-
-};
-
-class CComponentsItem : public CComponents
-{
- protected:
- ///property: define of item type, see cc_types.h for possible types
- int cc_item_type;
- ///property: define of item index, all bound items get an index,
- ///default: CC_NO_INDEX as identifer for not embedded item and default index=0 for form as main parent
- ///see also getIndex(), setIndex()
- int cc_item_index;
- ///property: default enabled
- bool cc_item_enabled;
- ///property: default not selected
- bool cc_item_selected;
-
- ///Pointer to the form object in which this item is embedded.
- ///Is typically the type CComponentsForm or derived classes, default intialized with NULL
- CComponentsItem *cc_parent;
-
- ///hides item, arg: no_restore=true causes no restore of background, but clean up pixel buffer if required
- void hideCCItem(bool no_restore = false);
-
- ///initialze of basic framebuffer elements with shadow, background and frame.
- ///must be called first in all paint() members before paint any item,
- ///If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this!
- ///arg do_save_bg=false avoids using of unnecessary pixel memory, eg. if no hide with restore is provided. This is mostly the case whenever
- ///an item will be hide or overpainted with other methods, or it's embedded (bound) in a parent form.
- void paintInit(bool do_save_bg);
-
- ///initialize all required attributes
- void initVarItem();
-
- public:
- CComponentsItem();
-
- ///sets pointer to the form object in which this item is embedded.
- virtual void setParent(CComponentsItem *parent){cc_parent = parent;};
- ///returns pointer to the form object in which this item is embedded.
- virtual CComponentsItem * getParent(){return cc_parent;};
- ///property: returns true if item is added to a form
- virtual bool isAdded();
-
- ///abstract: paint item, arg: do_save_bg see paintInit() above
- virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
- ///hides item, arg: no_restore see hideCCItem() above
- virtual void hide(bool no_restore = false);
-
- ///get the current item type, see attribute cc_item_type above
- virtual int getItemType();
- ///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
- virtual void syncSysColors();
-
- ///set select mode, see also col_frame_sel
- virtual void setSelected(bool selected){cc_item_selected = selected;};
- ///set enable mode, see also cc_item_enabled
- virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
-
- ///get select mode, see also setSelected() above
- virtual bool isSelected(){return cc_item_selected;};
- ///get enable mode, see also setEnable() above
- virtual bool isEnabled(){return cc_item_enabled;};
-
- ///get current index of item, see also attribut cc_item_index
- virtual int getIndex(){return cc_item_index;};
- ///set an index to item, see also attribut cc_item_index.
- ///To generate an index, use genIndex()
- virtual void setIndex(const int& index){cc_item_index = index;};
-};
-
-#endif
+#endif /*__N_COMPONENTS__*/
diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp
index bbebf1cd6..94693d13e 100644
--- a/src/gui/components/cc_base.cpp
+++ b/src/gui/components/cc_base.cpp
@@ -30,7 +30,7 @@
#include
#include
-#include "cc.h"
+#include "cc_base.h"
using namespace std;
diff --git a/src/gui/components/cc_base.h b/src/gui/components/cc_base.h
new file mode 100644
index 000000000..32605b04d
--- /dev/null
+++ b/src/gui/components/cc_base.h
@@ -0,0 +1,278 @@
+/*
+ Based up Neutrino-GUI - Tuxbox-Project
+ Copyright (C) 2001 by Steffen Hehn 'McClean'
+
+ Classes for generic GUI-related components.
+ Copyright (C) 2012, 2013, Thilo Graf 'dbt'
+
+ License: GPL
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the
+ Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef __COMPONENTS__
+#define __COMPONENTS__
+
+#include "cc_types.h"
+#include
+#include
+#include
+#include
+#include
+
+//#define DEBUG_CC
+
+/// Basic component class.
+/*!
+Basic attributes and member functions for component sub classes
+*/
+
+class CComponents
+{
+ private:
+ ///pixel buffer handling, returns pixel buffer depends of given parameters
+ fb_pixel_t* getScreen(int ax, int ay, int dx, int dy);
+
+ protected:
+ ///object: framebuffer object, usable in all sub classes
+ CFrameBuffer * frameBuffer;
+ ///container: for frambuffer properties and pixel buffer
+ std::vector v_fbdata;
+
+ ///property: x-position on screen, to alter with setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
+ int x;
+ ///property: y-position on screen, to alter setPos() or setDimensionsAll(), see also defines CC_APPEND, CC_CENTERED
+ int y;
+ ///property: contains real x-position on screen
+ int cc_xr;
+ ///property: contains real y-position on screen
+ int cc_yr;
+ ///property: height-dimension on screen, to alter with setHeight() or setDimensionsAll()
+ int height;
+ ///property: width-dimension on screen, to alter with setWidth() or setDimensionsAll()
+ int width;
+ ///property: has corners with definied type, types are defined in /driver/frambuffer.h, without effect, if corner_radius=0
+ int corner_type;
+ ///property: defined radius of corner, without effect, if corner_type=0
+ int corner_rad;
+
+ ///property: color of body
+ fb_pixel_t col_body;
+ ///property: color of shadow
+ fb_pixel_t col_shadow;
+ ///property: color of frame
+ fb_pixel_t col_frame;
+ ///property: color of frame if component is selected, Note: fr_thickness_sel must be set
+ fb_pixel_t col_frame_sel;
+
+ ///property: true=component has shadow
+ bool shadow;
+ ///property: width of shadow
+ int shadow_w;
+
+ ///property: frame thickness
+ int fr_thickness;
+ ///property: frame thickness of selected component
+ int fr_thickness_sel;
+
+ ///status: true=component was painted for 1st time
+ bool firstPaint;
+ ///status: true=component was rendered
+ bool is_painted;
+ ///mode: true=activate rendering of basic elements (frame, shadow and body)
+ bool paint_bg;
+
+ ///initialize of basic attributes, no parameters required
+ void initVarBasic();
+ ///rendering of framebuffer elements at once,
+ ///elements are contained in v_fbdata, presumes added frambuffer elements with paintInit(),
+ ///parameter do_save_bg=true, saves background of element to pixel buffer, this can be restore with hide()
+ void paintFbItems(bool do_save_bg = true);
+
+ ///clean up old screen buffer saved in v_fbdata
+ virtual void clear();
+
+ ///container: contains saved pixel buffer with position and dimensions
+ comp_screen_data_t saved_screen;
+ ///cleans saved pixel buffer
+ void clearSavedScreen();
+
+ public:
+ ///basic component class constructor.
+ CComponents();
+ virtual~CComponents();
+
+ ///set screen x-position
+ inline virtual void setXPos(const int& xpos){x = xpos;};
+ ///set screen y-position,
+ inline virtual void setYPos(const int& ypos){y = ypos;};
+ ///set x and y position
+ ///Note: position of bound components (items) means position related within parent form, not for screen!
+ ///to set the real screen position, look at setRealPos()
+ inline virtual void setPos(const int& xpos, const int& ypos){x = xpos; y = ypos;};
+
+ ///sets real x position on screen. Use this, if item is added to a parent form
+ virtual void setRealXPos(const int& xr){cc_xr = xr;};
+ ///sets real y position on screen. Use this, if item is added to a parent form
+ virtual void setRealYPos(const int& yr){cc_yr = yr;};
+ ///sets real x and y position on screen at once. Use this, if item is added to a parent form
+ virtual void setRealPos(const int& xr, const int& yr){cc_xr = xr; cc_yr = yr;};
+ ///get real x-position on screen. Use this, if item contains own render methods and item is bound to a form
+ virtual int getRealXPos(){return cc_xr;};
+ ///get real y-position on screen. Use this, if item contains own render methods and item is bound to a form
+ virtual int getRealYPos(){return cc_yr;};
+
+ ///set height of component on screen
+ inline virtual void setHeight(const int& h){height = h;};
+ ///set width of component on screen
+ inline virtual void setWidth(const int& w){width = w;};
+ ///set all positions and dimensions of component at once
+ inline virtual void setDimensionsAll(const int& xpos, const int& ypos, const int& w, const int& h){x = xpos; y = ypos; width = w; height = h;};
+
+ ///return screen x-position of component
+ ///Note: position of bound components (items) means position related within parent form, not for screen!
+ ///to get the real screen position, use getRealXPos(), to find in CComponentsItem sub classes
+ inline virtual int getXPos(){return x;};
+ ///return screen y-position of component
+ ///Note: position of bound components (items) means position related within parent form, not for screen!
+ ///to get the real screen position, use getRealYPos(), to find in CComponentsItem sub classes
+ inline virtual int getYPos(){return y;};
+ ///return height of component
+ inline virtual int getHeight(){return height;};
+ ///return width of component
+ inline virtual int getWidth(){return width;};
+ ///return of frame thickness
+ inline virtual int getFrameThickness(){return fr_thickness;};
+
+ ///return/set (pass through) width and height of component
+ inline virtual void getSize(int* w, int* h){*w=width; *h=height;};
+ ///return/set (pass through) position and dimensions of component at once
+ inline virtual void getDimensions(int* xpos, int* ypos, int* w, int* h){*xpos=x; *ypos=y; *w=width; *h=height;};
+
+ ///set frame color
+ inline virtual void setColorFrame(fb_pixel_t color){col_frame = color;};
+ ///set body color
+ inline virtual void setColorBody(fb_pixel_t color){col_body = color;};
+ ///set shadow color
+ inline virtual void setColorShadow(fb_pixel_t color){col_shadow = color;};
+ ///set all basic framebuffer element colors at once
+ ///Note: Possible color values are defined in "gui/color.h" and "gui/customcolor.h"
+ inline virtual void setColorAll(fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow){col_frame = color_frame; col_body = color_body; col_shadow = color_shadow;};
+
+ ///get frame color
+ inline virtual fb_pixel_t getColorFrame(){return col_frame;};
+ ///get body color
+ inline virtual fb_pixel_t getColorBody(){return col_body;};
+ ///get shadow color
+ inline virtual fb_pixel_t getColorShadow(){return col_shadow;};
+
+ ///set corner types
+ ///Possible corner types are defined in CFrameBuffer (see: driver/framebuffer.h)
+ ///Note: default values are given from settings
+ inline virtual void setCornerType(const int& type){corner_type = type;};
+ ///set corner radius and type
+ inline virtual void setCorner(const int& radius, const int& type = CORNER_ALL){corner_rad = radius; corner_type = type;};
+ ///get corner types
+ inline virtual int getCornerType(){return corner_type;};
+ ///get corner radius
+ inline virtual int getCornerRadius(){return corner_rad;};
+
+ ///set frame thickness
+ inline virtual void setFrameThickness(const int& thickness){fr_thickness = thickness;};
+ ///switch shadow on/off
+ ///Note: it's recommended to use #defines: CC_SHADOW_ON=true or CC_SHADOW_OFF=false as parameter, see also cc_types.h
+ inline virtual void setShadowOnOff(bool has_shadow){shadow = has_shadow;};
+
+ ///hide current screen and restore background
+ virtual void hide();
+ ///erase current screen without restore of background, it's similar to paintBackgroundBoxRel() from CFrameBuffer
+ virtual void kill();
+ ///returns paint mode, true=item was painted
+ virtual bool isPainted(){return is_painted;}
+ ///allows paint of elementary item parts (shadow, frame and body), similar as background, set it usually to false, if item used in a form
+ virtual void doPaintBg(bool do_paint){paint_bg = do_paint;};
+
+};
+
+class CComponentsItem : public CComponents
+{
+ protected:
+ ///property: define of item type, see cc_types.h for possible types
+ int cc_item_type;
+ ///property: define of item index, all bound items get an index,
+ ///default: CC_NO_INDEX as identifer for not embedded item and default index=0 for form as main parent
+ ///see also getIndex(), setIndex()
+ int cc_item_index;
+ ///property: default enabled
+ bool cc_item_enabled;
+ ///property: default not selected
+ bool cc_item_selected;
+
+ ///Pointer to the form object in which this item is embedded.
+ ///Is typically the type CComponentsForm or derived classes, default intialized with NULL
+ CComponentsItem *cc_parent;
+
+ ///hides item, arg: no_restore=true causes no restore of background, but clean up pixel buffer if required
+ void hideCCItem(bool no_restore = false);
+
+ ///initialze of basic framebuffer elements with shadow, background and frame.
+ ///must be called first in all paint() members before paint any item,
+ ///If backround is not required, it's possible to override this with variable paint_bg=false, use doPaintBg(true/false) to set this!
+ ///arg do_save_bg=false avoids using of unnecessary pixel memory, eg. if no hide with restore is provided. This is mostly the case whenever
+ ///an item will be hide or overpainted with other methods, or it's embedded (bound) in a parent form.
+ void paintInit(bool do_save_bg);
+
+ ///initialize all required attributes
+ void initVarItem();
+
+ public:
+ CComponentsItem();
+
+ ///sets pointer to the form object in which this item is embedded.
+ virtual void setParent(CComponentsItem *parent){cc_parent = parent;};
+ ///returns pointer to the form object in which this item is embedded.
+ virtual CComponentsItem * getParent(){return cc_parent;};
+ ///property: returns true if item is added to a form
+ virtual bool isAdded();
+
+ ///abstract: paint item, arg: do_save_bg see paintInit() above
+ virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES) = 0;
+ ///hides item, arg: no_restore see hideCCItem() above
+ virtual void hide(bool no_restore = false);
+
+ ///get the current item type, see attribute cc_item_type above
+ virtual int getItemType();
+ ///syncronizes item colors with current color settings if required, NOTE: overwrites internal values!
+ virtual void syncSysColors();
+
+ ///set select mode, see also col_frame_sel
+ virtual void setSelected(bool selected){cc_item_selected = selected;};
+ ///set enable mode, see also cc_item_enabled
+ virtual void setEnable(bool enabled){cc_item_enabled = enabled;};
+
+ ///get select mode, see also setSelected() above
+ virtual bool isSelected(){return cc_item_selected;};
+ ///get enable mode, see also setEnable() above
+ virtual bool isEnabled(){return cc_item_enabled;};
+
+ ///get current index of item, see also attribut cc_item_index
+ virtual int getIndex(){return cc_item_index;};
+ ///set an index to item, see also attribut cc_item_index.
+ ///To generate an index, use genIndex()
+ virtual void setIndex(const int& index){cc_item_index = index;};
+};
+
+#endif
diff --git a/src/gui/components/cc_detailsline.h b/src/gui/components/cc_detailsline.h
index f35cbf745..5276cf75e 100644
--- a/src/gui/components/cc_detailsline.h
+++ b/src/gui/components/cc_detailsline.h
@@ -30,7 +30,7 @@
#include
#endif
-#include "cc.h"
+#include "cc_base.h"
//! Sub class of CComponents. Shows a connectline with given dimensions and color on screen.
/*!
diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h
index 181b4ec78..e00ae07d0 100644
--- a/src/gui/components/cc_frm.h
+++ b/src/gui/components/cc_frm.h
@@ -28,7 +28,7 @@
#include "config.h"
-#include
+#include
#include
#include
#include
@@ -123,6 +123,7 @@ class CComponentsHeader : public CComponentsForm
int cch_items_y, cch_icon_x, cch_icon_w, cch_text_x, cch_buttons, cch_buttons_w, cch_buttons_h, cch_buttons_space, cch_offset;
std::vector v_cch_btn;
int cch_size_mode;
+ int cch_caption_align;
void initIcon();
void initCaption();
@@ -162,8 +163,9 @@ class CComponentsHeader : public CComponentsForm
virtual ~CComponentsHeader();
- virtual void setCaption(const std::string& caption);
- virtual void setCaption(neutrino_locale_t caption_locale);
+ virtual void setCaption(const std::string& caption, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
+ virtual void setCaption(neutrino_locale_t caption_locale, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
+ virtual void setCaptionAlignment(const int& align_mode){cch_caption_align = align_mode;};
virtual void setCaptionFont(Font* font_name);
virtual void setCaptionColor(fb_pixel_t text_color){cch_col_text = text_color;};
virtual void setOffset(const int offset){cch_offset = offset;};
@@ -174,7 +176,7 @@ class CComponentsHeader : public CComponentsForm
virtual void setButtonsSpace(const int buttons_space){cch_buttons_space = buttons_space;};
virtual void initCCItems();
virtual void setSizeMode(const int& size_mode){cch_size_mode = size_mode;};
-
+ virtual CComponentsText* getTextObject(){return cch_text_obj;};
virtual void paint(bool do_save_bg = CC_SAVE_SCREEN_YES);
};
@@ -225,12 +227,16 @@ class CComponentsWindow : public CComponentsForm
CComponentsFooter * ccw_footer;
///property: caption in header, see also getHeaderObject()
std::string ccw_caption;
+ ///property: alignment mode for header caption
+ int ccw_align_mode;
///property: icon name in header, see also getHeaderObject()
const char* ccw_icon_name;
///property: assigned default icon buttons in header, see also getHeaderObject()
int ccw_buttons;
- ///property: value = true, let show footer
+ ///property: value = true, let show footer, see showFooter()
bool ccw_show_footer;
+ ///property: value = true, let show header, see showHeader()
+ bool ccw_show_header;
///initialze header object
void initHeader();
@@ -285,14 +291,18 @@ class CComponentsWindow : public CComponentsForm
///add item to body object, also usable is addCCItem() to add items to the windo object
void addWindowItem(CComponentsItem* cc_Item);
- ///
+ ///allow/disallow paint a footer, default true, see also ccw_show_footer, showHeader()
void showFooter(bool show = true){ccw_show_footer = show;};
+ ///allow/disallow paint a header, default true, see also ccw_show_header, showFooter()
+ void showHeader(bool show = true){ccw_show_header = show;};
///set caption in header with string, see also getHeaderObject()
- void setWindowCaption(const std::string& text){ccw_caption = text;};
+ void setWindowCaption(const std::string& text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK){ccw_caption = text; ccw_align_mode = align_mode;};
///set caption in header from locales, see also getHeaderObject()
- void setWindowCaption(neutrino_locale_t locale_text);
+ void setWindowCaption(neutrino_locale_t locale_text, const int& align_mode = CTextBox::NO_AUTO_LINEBREAK);
+ ///set caption alignment
+ void setWindowCaptionAlignment(const int& align_mode){ccw_align_mode = align_mode;};
///set icon name in header, see also getHeaderObject()
void setWindowIcon(const char* iconname){ccw_icon_name = iconname;};
@@ -305,7 +315,6 @@ class CComponentsWindow : public CComponentsForm
///returns a pointer to the internal body object, use this to get access to body properities
CComponentsForm* getBodyObject(){return ccw_body;};
-
///returns a pointer to the internal footer object, use this to get access to footer properities
CComponentsFooter* getFooterObject(){return ccw_footer;};
diff --git a/src/gui/components/cc_frm_button.h b/src/gui/components/cc_frm_button.h
index 65cc918ee..f435c8e44 100644
--- a/src/gui/components/cc_frm_button.h
+++ b/src/gui/components/cc_frm_button.h
@@ -27,7 +27,7 @@
#define __CC_BUTTONS_H__
#include
-#include "cc.h"
+#include "cc_base.h"
#include "cc_frm.h"
#include
#include
diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h
index 1ca1a8fa5..1af9d2580 100644
--- a/src/gui/components/cc_frm_clock.h
+++ b/src/gui/components/cc_frm_clock.h
@@ -31,7 +31,7 @@
#include
#endif
-#include "cc.h"
+#include "cc_base.h"
#include "cc_frm.h"
diff --git a/src/gui/components/cc_frm_header.cpp b/src/gui/components/cc_frm_header.cpp
index 554601fb9..ea447f548 100644
--- a/src/gui/components/cc_frm_header.cpp
+++ b/src/gui/components/cc_frm_header.cpp
@@ -109,6 +109,7 @@ void CComponentsHeader::initVarHeader()
cch_btn_obj = NULL;
cch_text = "";
cch_col_text = COL_MENUHEAD_TEXT;
+ cch_caption_align = CTextBox::NO_AUTO_LINEBREAK;
cch_items_y = 0;
cch_offset = 8;
cch_icon_x = cch_offset;
@@ -130,14 +131,16 @@ CComponentsHeader::~CComponentsHeader()
cleanCCForm();
}
-void CComponentsHeader::setCaption(const std::string& caption)
+void CComponentsHeader::setCaption(const std::string& caption, const int& align_mode)
{
- cch_text = caption;
+ cch_text = caption;
+ cch_caption_align = align_mode;
}
-void CComponentsHeader::setCaption(neutrino_locale_t caption_locale)
+void CComponentsHeader::setCaption(neutrino_locale_t caption_locale, const int& align_mode)
{
- cch_text = g_Locale->getText(caption_locale);
+ cch_text = g_Locale->getText(caption_locale);
+ cch_caption_align = align_mode;
}
void CComponentsHeader::setCaptionFont(Font* font_name)
@@ -168,10 +171,12 @@ void CComponentsHeader::initIcon()
printf(" [CComponentsHeader]\n [%s - %d] init header icon: %s\n", __FUNCTION__, __LINE__, cch_icon_name);
#endif
cch_icon_obj = new CComponentsPicture(cch_icon_x, cch_items_y, 0, 0, cch_icon_name);
- //add item only one time
- addCCItem(cch_icon_obj); //icon
}
+ //add item only one time
+ if (!cch_icon_obj->isAdded())
+ addCCItem(cch_icon_obj); //icon
+
//get dimensions of header icon
int iw, ih;
frameBuffer->getIconSize(cch_icon_name, &iw, &ih);
@@ -242,6 +247,10 @@ void CComponentsHeader::initButtonFormSize()
{
cch_buttons_w = 0;
cch_buttons_h = 0;
+
+ if (cch_btn_obj == NULL)
+ return;
+
for(size_t i=0; igetIconSize(v_cch_btn[i].c_str(), &bw, &bh);
@@ -254,9 +263,13 @@ void CComponentsHeader::initButtonFormSize()
void CComponentsHeader::initButtons()
{
//exit if no button defined
- if (v_cch_btn.empty())
+ if (v_cch_btn.empty()){
+ if (cch_btn_obj)
+ delete cch_btn_obj;
+ cch_btn_obj = NULL;
return;
-
+ }
+
initButtonFormSize();
if (cch_btn_obj == NULL){
@@ -264,10 +277,12 @@ void CComponentsHeader::initButtons()
#ifdef DEBUG_CC
printf(" [CComponentsHeader]\n [%s - %d] init header buttons...\n", __FUNCTION__, __LINE__);
#endif
- //add button form
- addCCItem(cch_btn_obj); //buttons
}
+ //add button form only one time
+ if (!cch_btn_obj->isAdded())
+ addCCItem(cch_btn_obj); //buttons
+
//set button form properties
if (cch_btn_obj){
cch_btn_obj->setDimensionsAll(width-cch_offset-cch_buttons_w, cch_items_y, cch_buttons_w, cch_buttons_h);
@@ -300,12 +315,13 @@ void CComponentsHeader::initButtons()
void CComponentsHeader::initCaption()
{
//recalc header text position if header icon is defined
+ int cc_text_w = 0;
if (cch_icon_name != NULL){
cch_text_x = cch_icon_x+cch_icon_w+cch_offset;
}
//calc width of text object in header
- int cc_text_w = width-cch_text_x-cch_offset;
+ cc_text_w = width-cch_text_x-cch_offset;
if (cch_buttons_w)
cc_text_w -= cch_buttons_w-cch_offset;
@@ -315,15 +331,20 @@ void CComponentsHeader::initCaption()
printf(" [CComponentsHeader]\n [%s - %d] init header text: %s [ x %d w %d ]\n", __FUNCTION__, __LINE__, cch_text.c_str(), cch_text_x, cc_text_w);
#endif
cch_text_obj = new CComponentsText();
- //add text item
- addCCItem(cch_text_obj); //text
}
+ //add text item
+ if (!cch_text_obj->isAdded())
+ addCCItem(cch_text_obj); //text
+
//set header text properties
if (cch_text_obj){
+ //set alignment of text item in dependency from text alignment
+ if (cch_caption_align == CTextBox::CENTER)
+ cch_text_x = CC_CENTERED;
cch_text_obj->setDimensionsAll(cch_text_x, cch_items_y, cc_text_w, height);
cch_text_obj->doPaintBg(false);
- cch_text_obj->setText(cch_text, CTextBox::TOP | CTextBox::NO_AUTO_LINEBREAK, cch_font);
+ cch_text_obj->setText(cch_text, cch_caption_align, cch_font);
cch_text_obj->forceTextPaint(); //here required
cch_text_obj->setTextColor(cch_col_text);
cch_text_obj->setColorBody(col_body);
diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h
index 0e8268b6c..460270f12 100644
--- a/src/gui/components/cc_frm_signalbars.h
+++ b/src/gui/components/cc_frm_signalbars.h
@@ -31,8 +31,8 @@
#include
#endif
-#include
-#include
+// #include
+// #include
#include
#include
#include
diff --git a/src/gui/components/cc_frm_window.cpp b/src/gui/components/cc_frm_window.cpp
index 69997d755..6b66f5827 100644
--- a/src/gui/components/cc_frm_window.cpp
+++ b/src/gui/components/cc_frm_window.cpp
@@ -141,13 +141,16 @@ void CComponentsWindow::initVarWindow()
ccw_icon_name = NULL;
ccw_buttons = 0; //no header buttons
ccw_show_footer = true;
-
+ ccw_show_header = true;
+ ccw_align_mode = CTextBox::NO_AUTO_LINEBREAK;
+
setShadowOnOff(true);
}
-void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text)
+void CComponentsWindow::setWindowCaption(neutrino_locale_t locale_text, const int& align_mode)
{
ccw_caption = g_Locale->getText(locale_text);
+ ccw_align_mode = align_mode;
}
void CComponentsWindow::initHeader()
@@ -158,12 +161,12 @@ void CComponentsWindow::initHeader()
//add of header item happens initCCWItems()
}
- //set header properties
+ //set header properties //TODO: assigned properties with internal header objekt have no effect!
if (ccw_head){
- ccw_head->setPos(0, 0);
ccw_head->setWidth(width-2*fr_thickness);
+// ccw_head->setPos(0, 0);
ccw_head->setIcon(ccw_icon_name);
- ccw_head->setCaption(ccw_caption);
+ ccw_head->setCaption(ccw_caption, ccw_align_mode);
ccw_head->initCCItems();
ccw_head->setDefaultButtons(ccw_buttons);
}
@@ -181,9 +184,11 @@ void CComponentsWindow::initBody()
if (ccw_body){
ccw_body->setCornerType(0);
int fh = 0;
+ int hh = 0;
if (ccw_footer)
fh = ccw_footer->getHeight();
- int hh = ccw_head->getHeight();
+ if (ccw_head)
+ hh = ccw_head->getHeight();
int h_body = height - hh - fh - 2*fr_thickness;
ccw_body->setDimensionsAll(0, CC_APPEND, width-2*fr_thickness, h_body);
ccw_body->doPaintBg(false);
@@ -193,7 +198,6 @@ void CComponentsWindow::initBody()
void CComponentsWindow::initFooter()
{
if (ccw_footer== NULL){
-
ccw_footer= new CComponentsFooter();
initFooter();
//add of footer item happens initCCWItems()
@@ -218,22 +222,31 @@ void CComponentsWindow::initCCWItems()
#ifdef DEBUG_CC
printf("[CComponentsWindow] [%s - %d] init items...\n", __FUNCTION__, __LINE__);
#endif
- initHeader();
-
+ //add header if required
+ if (ccw_show_header){
+ initHeader();
+ }else{
+ if (ccw_head){
+ removeCCItem(ccw_head);
+ ccw_head = NULL;
+ }
+ }
+
//add footer if required
if (ccw_show_footer){
initFooter();
}else{
- if (ccw_footer != NULL){
+ if (ccw_footer){
removeCCItem(ccw_footer);
ccw_footer = NULL;
}
}
initBody();
-
+
//add header, body and footer items only one time
- if (!ccw_head->isAdded())
- addCCItem(ccw_head);
+ if (ccw_head)
+ if (!ccw_head->isAdded())
+ addCCItem(ccw_head);
if (!ccw_body->isAdded())
addCCItem(ccw_body);
if (ccw_footer)
diff --git a/src/gui/components/cc_item.cpp b/src/gui/components/cc_item.cpp
index d8d4fbbf0..07d621e96 100644
--- a/src/gui/components/cc_item.cpp
+++ b/src/gui/components/cc_item.cpp
@@ -30,7 +30,7 @@
#include
#include
-#include "cc.h"
+#include "cc_base.h"
using namespace std;
diff --git a/src/gui/components/cc_item_picture.h b/src/gui/components/cc_item_picture.h
index 2b74c1709..dd45ec449 100644
--- a/src/gui/components/cc_item_picture.h
+++ b/src/gui/components/cc_item_picture.h
@@ -31,7 +31,7 @@
#include
#endif
-#include "cc.h"
+#include "cc_base.h"
#include
#include
diff --git a/src/gui/components/cc_item_progressbar.h b/src/gui/components/cc_item_progressbar.h
index eb22f8bf7..90fb2a7a0 100644
--- a/src/gui/components/cc_item_progressbar.h
+++ b/src/gui/components/cc_item_progressbar.h
@@ -50,7 +50,7 @@
#define __CC_PROGRESSBAR_H__
#include "config.h"
-#include
+#include
#include
class CProgressBar : public CComponentsItem
diff --git a/src/gui/components/cc_item_shapes.h b/src/gui/components/cc_item_shapes.h
index b6900c820..e9e879033 100644
--- a/src/gui/components/cc_item_shapes.h
+++ b/src/gui/components/cc_item_shapes.h
@@ -30,7 +30,7 @@
#include
#endif
-#include "cc.h"
+#include "cc_base.h"
//! Sub class of CComponentsItem. Shows a shape with given dimensions and color on screen.
/*!
diff --git a/src/gui/components/cc_item_text.cpp b/src/gui/components/cc_item_text.cpp
index 1b5aba9a1..dbd94b4c2 100644
--- a/src/gui/components/cc_item_text.cpp
+++ b/src/gui/components/cc_item_text.cpp
@@ -273,3 +273,18 @@ string CComponentsText::iToString(int int_val)
string i_string(i_str.str());
return i_string;
}
+
+//helper, get lines per textbox page
+int CComponentsText::getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode)
+{
+ CComponentsText box;
+ box.iX = 0;
+ box.iY = 0;
+ box.iWidth = textWidth;
+ box.iHeight = textMaxHeight;
+
+ CTextBox tb(ct_text.c_str(), ct_font, mode, &box);
+ int ret = tb.getLinesPerPage();
+
+ return ret;
+}
diff --git a/src/gui/components/cc_item_text.h b/src/gui/components/cc_item_text.h
index e6bf1365e..2661641eb 100644
--- a/src/gui/components/cc_item_text.h
+++ b/src/gui/components/cc_item_text.h
@@ -26,7 +26,7 @@
#ifndef __CC_ITEM_TEXT_H__
#define __CC_ITEM_TEXT_H__
-#include "cc.h"
+#include "cc_base.h"
#include
#include
@@ -100,6 +100,8 @@ class CComponentsText : public CComponentsItem, public CBox
virtual inline void setTextFont(Font* font_text){ct_font = font_text;};
///set text color
virtual inline void setTextColor(fb_pixel_t color_text){ ct_col_text = color_text;};
+ ///get text color
+ virtual inline fb_pixel_t getTextColor(){return ct_col_text;};
///set text alignment, also see textbox.h for possible alignment modes
virtual inline void setTextMode(const int mode){ct_text_mode = mode;};
///set text border width
@@ -131,6 +133,9 @@ class CComponentsText : public CComponentsItem, public CBox
///gets the embedded CTextBox object, so it's possible to get access directly to its methods and properties
virtual CTextBox* getCTextBoxObject() { return ct_textbox; };
+
+ ///returns count of lines from a text box page
+ virtual int getTextLinesAutoHeight(const int& textMaxHeight, const int& textWidth, const int& mode);
};
diff --git a/src/gui/components/cc_item_tvpic.h b/src/gui/components/cc_item_tvpic.h
index 6634b15b2..fef5a23b8 100644
--- a/src/gui/components/cc_item_tvpic.h
+++ b/src/gui/components/cc_item_tvpic.h
@@ -30,7 +30,7 @@
#include
#endif
-#include "cc.h"
+#include "cc_base.h"
#include
//! Sub class of CComponentsItem. Shows a mini tv box, similar to a PIP-Feature with current tv-channel.
diff --git a/src/gui/components/unmaintained/cc_misc.h b/src/gui/components/unmaintained/cc_misc.h
index cda11f389..2c050859c 100644
--- a/src/gui/components/unmaintained/cc_misc.h
+++ b/src/gui/components/unmaintained/cc_misc.h
@@ -28,7 +28,7 @@
#define __CC_MISC__
#include "config.h"
-#include
+#include
#include
#include
diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp
index 27901e561..61ff13176 100644
--- a/src/gui/dboxinfo.cpp
+++ b/src/gui/dboxinfo.cpp
@@ -40,7 +40,7 @@
#include
#include
-#include
+#include
#include
#include
diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp
index 9c4b4b71f..939a9e85a 100644
--- a/src/gui/epgview.cpp
+++ b/src/gui/epgview.cpp
@@ -34,7 +34,7 @@
#include
#include
#include
-#include
+#include
#include
#include
diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h
index 621581fbc..8eff085db 100644
--- a/src/gui/eventlist.h
+++ b/src/gui/eventlist.h
@@ -34,7 +34,7 @@
#include
#include
#include
-#include
+#include
#include "color.h"
#include "infoviewer.h"
diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp
index f6258816a..26165a01b 100644
--- a/src/gui/filebrowser.cpp
+++ b/src/gui/filebrowser.cpp
@@ -28,7 +28,7 @@
/* include before to enable 64 bit file offsets */
#include
-#include
+#include
#include
#include
#include
diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp
index 165a05f9c..83d01fe7d 100644
--- a/src/gui/hdd_menu.cpp
+++ b/src/gui/hdd_menu.cpp
@@ -168,6 +168,7 @@ int CHDDMenuHandler::doMenu ()
std::string tmp_str[n];
CMenuWidget * tempMenu[n];
for(int i = 0; i < n;i++) {
+ tempMenu[i] = NULL;
char str[256];
char sstr[256];
char vendor[128], model[128];
diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp
index 3a75b43c2..7254860ca 100644
--- a/src/gui/imageinfo.cpp
+++ b/src/gui/imageinfo.cpp
@@ -38,7 +38,6 @@
#include
#include
#include
-#include
#include "version.h"
#define LICENSEDIR DATADIR "/neutrino/license/"
diff --git a/src/gui/imageinfo.h b/src/gui/imageinfo.h
index 367d7ee91..2a5b671da 100644
--- a/src/gui/imageinfo.h
+++ b/src/gui/imageinfo.h
@@ -32,8 +32,7 @@
#endif
#include
-#include
-#include
+#include
#include
typedef struct image_info_t
diff --git a/src/gui/info_menue.cpp b/src/gui/info_menue.cpp
index c90c17b7d..6df35961f 100644
--- a/src/gui/info_menue.cpp
+++ b/src/gui/info_menue.cpp
@@ -40,6 +40,9 @@
#include
#include
+#include "gui/cam_menu.h"
+
+extern CCAMMenuHandler * g_CamHandler;
CInfoMenu::CInfoMenu()
{
@@ -83,6 +86,12 @@ int CInfoMenu::showMenu()
mf->setHint(NEUTRINO_ICON_HINT_STREAMINFO, LOCALE_MENU_HINT_STREAMINFO);
info->addItem(mf);
+ if (g_settings.easymenu) {
+ mf = new CMenuForwarder(LOCALE_CI_SETTINGS, true, NULL, g_CamHandler, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE);
+ mf->setHint(NEUTRINO_ICON_HINT_CI, LOCALE_MENU_HINT_CI);
+ info->addItem(mf);
+ }
+
int res = info->exec(NULL, "");
delete info;
return res;
diff --git a/src/gui/infoviewer_bb.h b/src/gui/infoviewer_bb.h
index 620a3aa73..1b2398f74 100644
--- a/src/gui/infoviewer_bb.h
+++ b/src/gui/infoviewer_bb.h
@@ -41,7 +41,7 @@
#include
#include
#include "widget/menue.h"
-#include
+#include
#include
class CInfoViewerBB
diff --git a/src/gui/mediaplayer.cpp b/src/gui/mediaplayer.cpp
index 6ff2edbd7..f3ce226ce 100644
--- a/src/gui/mediaplayer.cpp
+++ b/src/gui/mediaplayer.cpp
@@ -91,20 +91,16 @@ int CMediaPlayerMenu::exec(CMenuTarget* parent, const std::string &actionKey)
CAudioMute *audiomute = CAudioMute::getInstance();
if (actionKey == "audioplayer")
{
- audiomute->enableMuteIcon(false);
if (audioPlayer == NULL)
audioPlayer = new CAudioPlayerGui();
int res = audioPlayer->exec(NULL, "init");
- audiomute->enableMuteIcon(true);
return res /*menu_return::RETURN_REPAINT*/;
}
else if (actionKey == "inetplayer")
{
- audiomute->enableMuteIcon(false);
if (inetPlayer == NULL)
inetPlayer = new CAudioPlayerGui(true);
int res = inetPlayer->exec(NULL, "init");
- audiomute->enableMuteIcon(true);
return res; //menu_return::RETURN_REPAINT;
}
else if (actionKey == "movieplayer")
@@ -157,14 +153,14 @@ int CMediaPlayerMenu::initMenuMedia(CMenuWidget *m, CPersonalizeGui *p)
if (usage_mode != MODE_VIDEO)
{
//audio player
- neutrino_msg_t audio_rc = usage_mode == MODE_AUDIO ? CRCInput::RC_audio:CRCInput::RC_red;
- const char* audio_btn = usage_mode == MODE_AUDIO ? "" : NEUTRINO_ICON_BUTTON_RED;
+ neutrino_msg_t audio_rc = usage_mode == MODE_AUDIO ? CRCInput::RC_audio : g_settings.easymenu ? CRCInput::RC_green : CRCInput::RC_red;
+ const char* audio_btn = usage_mode == MODE_AUDIO ? "" : g_settings.easymenu ? NEUTRINO_ICON_BUTTON_GREEN: NEUTRINO_ICON_BUTTON_RED;
fw_audio = new CMenuForwarder(LOCALE_MAINMENU_AUDIOPLAYER, true, NULL, this, "audioplayer", audio_rc, audio_btn);
fw_audio->setHint(NEUTRINO_ICON_HINT_APLAY, LOCALE_MENU_HINT_APLAY);
-
+
//internet player
- neutrino_msg_t inet_rc = usage_mode == MODE_AUDIO ? CRCInput::RC_www : CRCInput::RC_green;
- const char* inet_btn = usage_mode == MODE_AUDIO ? "" : NEUTRINO_ICON_BUTTON_GREEN;
+ neutrino_msg_t inet_rc = usage_mode == MODE_AUDIO ? CRCInput::RC_www : g_settings.easymenu ? CRCInput::RC_blue : CRCInput::RC_green;
+ const char* inet_btn = usage_mode == MODE_AUDIO ? "" : g_settings.easymenu ? NEUTRINO_ICON_BUTTON_BLUE : NEUTRINO_ICON_BUTTON_GREEN;
fw_inet = new CMenuForwarder(LOCALE_INETRADIO_NAME, true, NULL, this, "inetplayer", inet_rc, inet_btn);
fw_inet->setHint(NEUTRINO_ICON_HINT_INET_RADIO, LOCALE_MENU_HINT_INET_RADIO);
}
@@ -175,19 +171,27 @@ int CMediaPlayerMenu::initMenuMedia(CMenuWidget *m, CPersonalizeGui *p)
if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) {
moviePlayer = new CMenuWidget(LOCALE_MAINMENU_MOVIEPLAYER, NEUTRINO_ICON_MULTIMEDIA, width, MN_WIDGET_ID_MEDIA_MOVIEPLAYER);
personalize->addWidget(moviePlayer);
- fw_mp = new CMenuForwarder(LOCALE_MAINMENU_MOVIEPLAYER, true, NULL, moviePlayer, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
+ if (g_settings.easymenu)
+ fw_mp = new CMenuForwarder(LOCALE_MAINMENU_MOVIEPLAYER, true, NULL, moviePlayer, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);
+ else
+ fw_mp = new CMenuForwarder(LOCALE_MAINMENU_MOVIEPLAYER, true, NULL, moviePlayer, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
fw_mp->setHint(NEUTRINO_ICON_HINT_MOVIE, LOCALE_MENU_HINT_MOVIE);
}
//pictureviewer
pictureviewergui = new CPictureViewerGui();
- fw_pviewer = new CMenuForwarder(LOCALE_MAINMENU_PICTUREVIEWER, true, NULL, pictureviewergui, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE);
+ if (g_settings.easymenu)
+ fw_pviewer = new CMenuForwarder(LOCALE_MAINMENU_PICTUREVIEWER, true, NULL, pictureviewergui, NULL, CRCInput::RC_1, NEUTRINO_ICON_BUTTON_1);
+ else
+ fw_pviewer = new CMenuForwarder(LOCALE_MAINMENU_PICTUREVIEWER, true, NULL, pictureviewergui, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE);
fw_pviewer->setHint(NEUTRINO_ICON_HINT_PICVIEW, LOCALE_MENU_HINT_PICVIEW);
#if ENABLE_UPNP
//upnp browser
- if (!upnpbrowsergui)
- upnpbrowsergui = new CUpnpBrowserGui();
- fw_upnp = new CMenuForwarder(LOCALE_UPNPBROWSER_HEAD, true, NULL, upnpbrowsergui, NULL, CRCInput::RC_0, NEUTRINO_ICON_BUTTON_0);
+ if (!g_settings.easymenu) {
+ if (!upnpbrowsergui)
+ upnpbrowsergui = new CUpnpBrowserGui();
+ fw_upnp = new CMenuForwarder(LOCALE_UPNPBROWSER_HEAD, true, NULL, upnpbrowsergui, NULL, CRCInput::RC_0, NEUTRINO_ICON_BUTTON_0);
+ }
#endif
// media->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, usage_mode == MODE_AUDIO ? CMenuWidget::BTN_TYPE_CANCEL : CMenuWidget::BTN_TYPE_BACK);
}
@@ -206,24 +210,43 @@ int CMediaPlayerMenu::initMenuMedia(CMenuWidget *m, CPersonalizeGui *p)
}
else
{
- //audio player
- personalize->addItem(media, fw_audio, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_AUDIO]);
-
- //internet player
- personalize->addItem(media, fw_inet, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_INETPLAY]);
-
- //movieplayer
- if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) {
- showMoviePlayer(moviePlayer, personalize);
- personalize->addItem(media, fw_mp, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_MPLAYER], false, CPersonalizeGui::PERSONALIZE_SHOW_AS_ACCESS_OPTION);
- }
-
- //picture viewer
- personalize->addItem(media, fw_pviewer, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_PVIEWER]);
+ if (g_settings.easymenu) {
+ //movieplayer
+ if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) {
+ showMoviePlayer(moviePlayer, personalize);
+ personalize->addItem(media, fw_mp, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_MPLAYER]);
+ }
+ //audio player
+ personalize->addItem(media, fw_audio, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_AUDIO]);
+ if (g_settings.easymenu) {
+ CMenuForwarder *fw_yt = new CMenuForwarder(LOCALE_MOVIEPLAYER_YTPLAYBACK, true, NULL, &CMoviePlayerGui::getInstance(), "ytplayback", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
+ fw_yt->setHint(NEUTRINO_ICON_HINT_YTPLAY, LOCALE_MENU_HINT_YTPLAY);
+ personalize->addItem(media, fw_yt, &g_settings.personalize[SNeutrinoSettings::P_MPLAYER_YTPLAY]);
+ }
+ //internet player
+ personalize->addItem(media, fw_inet, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_INETPLAY]);
+ //picture viewer
+ personalize->addItem(media, fw_pviewer, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_PVIEWER]);
+ } else {
+ //audio player
+ personalize->addItem(media, fw_audio, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_AUDIO]);
+
+ //internet player
+ personalize->addItem(media, fw_inet, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_INETPLAY]);
+
+ //movieplayer
+ if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) {
+ showMoviePlayer(moviePlayer, personalize);
+ personalize->addItem(media, fw_mp, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_MPLAYER], false, CPersonalizeGui::PERSONALIZE_SHOW_AS_ACCESS_OPTION);
+ }
+
+ //picture viewer
+ personalize->addItem(media, fw_pviewer, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_PVIEWER]);
#if ENABLE_UPNP
- //upnp browser
- personalize->addItem(media, fw_upnp, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_UPNP]);
+ //upnp browser
+ personalize->addItem(media, fw_upnp, &g_settings.personalize[SNeutrinoSettings::P_MEDIA_UPNP]);
#endif
+ }
}
int res = menu_return::RETURN_NONE;
@@ -253,8 +276,6 @@ void CMediaPlayerMenu::showMoviePlayer(CMenuWidget *moviePlayer, CPersonalizeGui
fw_mbrowser->setHint(NEUTRINO_ICON_HINT_MB, LOCALE_MENU_HINT_MB);
CMenuForwarder *fw_file = new CMenuForwarder(LOCALE_MOVIEPLAYER_FILEPLAYBACK, true, NULL, &CMoviePlayerGui::getInstance(), "fileplayback", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN);
fw_file->setHint(NEUTRINO_ICON_HINT_FILEPLAY, LOCALE_MENU_HINT_FILEPLAY);
- CMenuForwarder *fw_yt = new CMenuForwarder(LOCALE_MOVIEPLAYER_YTPLAYBACK, true, NULL, &CMoviePlayerGui::getInstance(), "ytplayback", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
- fw_yt->setHint(NEUTRINO_ICON_HINT_YTPLAY, LOCALE_MENU_HINT_YTPLAY);
p->addIntroItems(moviePlayer);
@@ -264,7 +285,11 @@ void CMediaPlayerMenu::showMoviePlayer(CMenuWidget *moviePlayer, CPersonalizeGui
//fileplayback
p->addItem(moviePlayer, fw_file, &g_settings.personalize[SNeutrinoSettings::P_MPLAYER_FILEPLAY]);
//ytplayback
- p->addItem(moviePlayer, fw_yt, &g_settings.personalize[SNeutrinoSettings::P_MPLAYER_YTPLAY]);
+ if (!g_settings.easymenu) {
+ CMenuForwarder *fw_yt = new CMenuForwarder(LOCALE_MOVIEPLAYER_YTPLAYBACK, true, NULL, &CMoviePlayerGui::getInstance(), "ytplayback", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
+ fw_yt->setHint(NEUTRINO_ICON_HINT_YTPLAY, LOCALE_MENU_HINT_YTPLAY);
+ p->addItem(moviePlayer, fw_yt, &g_settings.personalize[SNeutrinoSettings::P_MPLAYER_YTPLAY]);
+ }
// #if 0
// //moviePlayer->addItem(new CMenuForwarder(LOCALE_MOVIEPLAYER_PESPLAYBACK, true, NULL, moviePlayerGui, "pesplayback"));
diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp
index a987aa4ee..312cb2725 100644
--- a/src/gui/miscsettings_menu.cpp
+++ b/src/gui/miscsettings_menu.cpp
@@ -53,9 +53,12 @@
#include
#include
+#include
+
//#define ONE_KEY_PLUGIN
extern CPlugins * g_PluginList;
+extern cVideo *videoDecoder;
CMiscMenue::CMiscMenue()
{
@@ -123,6 +126,14 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey)
ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack);
return menu_return::RETURN_REPAINT;
}
+ else if(actionKey == "energy")
+ {
+ return showMiscSettingsMenuEnergy();
+ }
+ else if(actionKey == "channellist")
+ {
+ return showMiscSettingsMenuChanlist();
+ }
return showMiscSettingsMenu();
}
@@ -194,7 +205,6 @@ const CMenuOptionChooser::keyval_ext SLEEPTIMER_MIN_OPTIONS[SLEEPTIMER_MIN_OPTIO
int CMiscMenue::showMiscSettingsMenu()
{
//misc settings
- miscNotifier = NULL; /* for check at exit */
fanNotifier = new CFanControlNotifier();
sectionsdConfigNotifier = new CSectionsdConfigNotifier();
CMenuWidget misc_menue(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP);
@@ -211,9 +221,7 @@ int CMiscMenue::showMiscSettingsMenu()
//energy, shutdown
if (g_info.hw_caps->can_shutdown)
{
- CMenuWidget *misc_menue_energy = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_ENERGY);
- showMiscSettingsMenuEnergy(misc_menue_energy);
- mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_ENERGY, true, NULL, misc_menue_energy, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN);
+ mf = new CMenuForwarder(LOCALE_MISCSETTINGS_ENERGY, true, NULL, this, "energy", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN);
mf->setHint("", LOCALE_MENU_HINT_MISC_ENERGY);
misc_menue.addItem(mf);
}
@@ -249,9 +257,7 @@ int CMiscMenue::showMiscSettingsMenu()
misc_menue.addItem(mf);
}
//channellist
- CMenuWidget misc_menue_chanlist(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_CHANNELLIST);
- showMiscSettingsMenuChanlist(&misc_menue_chanlist);
- mf = new CMenuForwarder(LOCALE_MISCSETTINGS_CHANNELLIST, true, NULL, &misc_menue_chanlist, NULL, CRCInput::RC_2);
+ mf = new CMenuForwarder(LOCALE_MISCSETTINGS_CHANNELLIST, true, NULL, this, "channellist", CRCInput::RC_2);
mf->setHint("", LOCALE_MENU_HINT_MISC_CHANNELLIST);
misc_menue.addItem(mf);
@@ -271,8 +277,10 @@ int CMiscMenue::showMiscSettingsMenu()
int res = misc_menue.exec(NULL, "");
delete fanNotifier;
delete sectionsdConfigNotifier;
+#if 0
if (miscNotifier)
delete miscNotifier;
+#endif
delete miscEpgNotifier;
return res;
}
@@ -315,9 +323,17 @@ void CMiscMenue::showMiscSettingsMenuGeneral(CMenuWidget *ms_general)
#endif /*ONE_KEY_PLUGIN*/
}
-//energy and shutdown settings
-void CMiscMenue::showMiscSettingsMenuEnergy(CMenuWidget *ms_energy)
+#define VIDEOMENU_HDMI_CEC_MODE_OPTION_COUNT 2
+const CMenuOptionChooser::keyval VIDEOMENU_HDMI_CEC_MODE_OPTIONS[VIDEOMENU_HDMI_CEC_MODE_OPTION_COUNT] =
{
+ { VIDEO_HDMI_CEC_MODE_OFF , LOCALE_OPTIONS_OFF },
+ { VIDEO_HDMI_CEC_MODE_TUNER , LOCALE_OPTIONS_ON }
+};
+
+//energy and shutdown settings
+int CMiscMenue::showMiscSettingsMenuEnergy()
+{
+ CMenuWidget *ms_energy = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_ENERGY);
ms_energy->addIntroItems(LOCALE_MISCSETTINGS_ENERGY);
CMenuOptionChooser *m1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL_RCDELAY, &g_settings.shutdown_real_rcdelay, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, !g_settings.shutdown_real);
@@ -326,8 +342,8 @@ void CMiscMenue::showMiscSettingsMenuEnergy(CMenuWidget *ms_energy)
CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, g_settings.shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 ");
CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_shutdown_count);
m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT);
-
- miscNotifier = new COnOffNotifier(1);
+
+ COnOffNotifier * miscNotifier = new COnOffNotifier(1);
miscNotifier->addItem(m1);
miscNotifier->addItem(m2);
@@ -345,6 +361,17 @@ void CMiscMenue::showMiscSettingsMenuEnergy(CMenuWidget *ms_energy)
CMenuOptionChooser * m4 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SLEEPTIMER_MIN, &g_settings.sleeptimer_min, SLEEPTIMER_MIN_OPTIONS, SLEEPTIMER_MIN_OPTION_COUNT, true);
m4->setHint("", LOCALE_MENU_HINT_SLEEPTIMER_MIN);
ms_energy->addItem(m4);
+
+ if (g_settings.easymenu) {
+ CMenuOptionChooser *cec_ch = new CMenuOptionChooser(LOCALE_VIDEOMENU_HDMI_CEC, &g_settings.hdmi_cec_mode, VIDEOMENU_HDMI_CEC_MODE_OPTIONS, VIDEOMENU_HDMI_CEC_MODE_OPTION_COUNT, true, this);
+ cec_ch->setHint("", LOCALE_MENU_HINT_CEC_MODE);
+ ms_energy->addItem(cec_ch);
+ }
+
+ int res = ms_energy->exec(NULL, "");
+ delete ms_energy;
+ delete miscNotifier;
+ return res;
}
//EPG settings
@@ -419,8 +446,9 @@ void CMiscMenue::showMiscSettingsMenuFBrowser(CMenuWidget *ms_fbrowser)
}
//channellist
-void CMiscMenue::showMiscSettingsMenuChanlist(CMenuWidget *ms_chanlist)
+int CMiscMenue::showMiscSettingsMenuChanlist()
{
+ CMenuWidget * ms_chanlist = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_CHANNELLIST);
ms_chanlist->addIntroItems(LOCALE_MISCSETTINGS_CHANNELLIST);
CMenuOptionChooser * mc;
@@ -451,6 +479,9 @@ void CMiscMenue::showMiscSettingsMenuChanlist(CMenuWidget *ms_chanlist)
mc = new CMenuOptionChooser(LOCALE_CHANNELLIST_NUMERIC_ADJUST, &g_settings.channellist_numeric_adjust, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true);
mc->setHint("", LOCALE_MENU_HINT_NUMERIC_ADJUST);
ms_chanlist->addItem(mc);
+ int res = ms_chanlist->exec(NULL, "");
+ delete ms_chanlist;
+ return res;
}
#ifdef CPU_FREQ
@@ -464,3 +495,23 @@ void CMiscMenue::showMiscSettingsMenuCPUFreq(CMenuWidget *ms_cpu)
ms_cpu->addItem(new CMenuOptionChooser(LOCALE_CPU_FREQ_STANDBY, &g_settings.standby_cpufreq, CPU_FREQ_OPTIONS, CPU_FREQ_OPTION_COUNT, true));
}
#endif /*CPU_FREQ*/
+
+bool CMiscMenue::changeNotify(const neutrino_locale_t OptionName, void * /*data*/)
+{
+ if (ARE_LOCALES_EQUAL(OptionName, LOCALE_VIDEOMENU_HDMI_CEC))
+ {
+ printf("[neutrino CEC Settings] %s set CEC settings...\n", __FUNCTION__);
+ g_settings.hdmi_cec_standby = 0;
+ g_settings.hdmi_cec_view_on = 0;
+ if (g_settings.hdmi_cec_mode != VIDEO_HDMI_CEC_MODE_OFF) {
+ g_settings.hdmi_cec_standby = 1;
+ g_settings.hdmi_cec_view_on = 1;
+ g_settings.hdmi_cec_mode = VIDEO_HDMI_CEC_MODE_TUNER;
+ }
+ videoDecoder->SetCECAutoStandby(g_settings.hdmi_cec_standby == 1);
+ videoDecoder->SetCECAutoView(g_settings.hdmi_cec_view_on == 1);
+ videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)g_settings.hdmi_cec_mode);
+ }
+
+ return false;
+}
diff --git a/src/gui/miscsettings_menu.h b/src/gui/miscsettings_menu.h
index d9c0269fb..66afe0796 100644
--- a/src/gui/miscsettings_menu.h
+++ b/src/gui/miscsettings_menu.h
@@ -35,21 +35,21 @@
//#define CPU_FREQ
-class CMiscMenue : public CMenuTarget
+class CMiscMenue : public CMenuTarget, CChangeObserver
{
private:
CFanControlNotifier *fanNotifier;
CSectionsdConfigNotifier* sectionsdConfigNotifier;
- COnOffNotifier* miscNotifier;
+ //COnOffNotifier* miscNotifier;
COnOffNotifier* miscEpgNotifier;
int width;
int showMiscSettingsMenu();
void showMiscSettingsMenuGeneral(CMenuWidget *ms_general);
- void showMiscSettingsMenuEnergy(CMenuWidget *ms_energy);
void showMiscSettingsMenuEpg(CMenuWidget *ms_epg);
void showMiscSettingsMenuFBrowser(CMenuWidget *ms_fbrowser);
- void showMiscSettingsMenuChanlist(CMenuWidget *ms_chanlist);
+ int showMiscSettingsMenuEnergy();
+ int showMiscSettingsMenuChanlist();
#ifdef CPU_FREQ
void showMiscSettingsMenuCPUFreq(CMenuWidget *ms_cpu);
#endif /*CPU_FREQ*/
@@ -57,8 +57,7 @@ class CMiscMenue : public CMenuTarget
CMiscMenue();
~CMiscMenue();
int exec(CMenuTarget* parent, const std::string & actionKey);
-
+ bool changeNotify(const neutrino_locale_t OptionName, void * /*data*/);
};
-
#endif
diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp
index 43ff2038d..68ae0add9 100644
--- a/src/gui/motorcontrol.cpp
+++ b/src/gui/motorcontrol.cpp
@@ -38,7 +38,6 @@
#include
#include
#include
-#include
#include
#include
#include
diff --git a/src/gui/motorcontrol.h b/src/gui/motorcontrol.h
index fb4b74dc4..c595308ee 100644
--- a/src/gui/motorcontrol.h
+++ b/src/gui/motorcontrol.h
@@ -34,7 +34,7 @@
#define __motorcontrol__
#include
-#include
+#include
#include
#include
#include
diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp
index 8b409a68c..da738d1f0 100644
--- a/src/gui/moviebrowser.cpp
+++ b/src/gui/moviebrowser.cpp
@@ -48,7 +48,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -1243,12 +1243,14 @@ std::string CMovieBrowser::getScreenshotName(std::string movie)
void CMovieBrowser::refreshMovieInfo(void)
{
//TRACE("[mb]->refreshMovieInfo m_vMovieInfo.size %d\n", m_vMovieInfo.size());
+ //reset text before new init, m_pcInfo must be clean
std::string emptytext = " ";
- if(m_vMovieInfo.empty()) {
- if(m_pcInfo != NULL)
- m_pcInfo->setText(&emptytext);
+ if(m_pcInfo)
+ m_pcInfo->setText(&emptytext);
+
+ if(m_vMovieInfo.empty())
return;
- }
+
if (m_movieSelectionHandler == NULL) {
// There is no selected element, clear LCD
m_pcInfo->setText(&emptytext);
@@ -1285,7 +1287,9 @@ printf("CMovieBrowser::refreshMovieInfo\n");
//printf("refreshMovieInfo: EpgId %llx id %llx y %d\n", m_movieSelectionHandler->epgEpgId, m_movieSelectionHandler->epgId, m_cBoxFrameTitleRel.iY);
int lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-logo_w-10;
int ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-logo_h)/2;
- const short pb_hdd_offset = 104;
+ short pb_hdd_offset = 104;
+ if (show_mode == MB_SHOW_YT)
+ pb_hdd_offset = 0;
m_pcWindow->paintBoxRel(lx - pb_hdd_offset , ly, logo_w, logo_h, TITLE_BACKGROUND_COLOR);
std::string lname;
if(g_PicViewer->GetLogoName(m_movieSelectionHandler->epgEpgId >>16, m_movieSelectionHandler->epgChannel, lname, &logo_w, &logo_h)){
@@ -1309,6 +1313,9 @@ printf("CMovieBrowser::refreshMovieInfo\n");
void CMovieBrowser::info_hdd_level(bool paint_hdd)
{
+ if (show_mode == MB_SHOW_YT)
+ return;
+
struct statfs s;
long blocks_percent_used =0;
static long tmp_blocks_percent_used = 0;
@@ -1613,7 +1620,6 @@ void CMovieBrowser::refreshBookmarkList(void) // P3
void CMovieBrowser::refreshTitle(void)
{
- //Paint Text Background
std::string title = m_textTitle.c_str();
if (show_mode == MB_SHOW_YT) {
title = g_Locale->getText(LOCALE_MOVIEPLAYER_YTPLAYBACK);
@@ -1623,17 +1629,14 @@ void CMovieBrowser::refreshTitle(void)
TRACE("[mb]->refreshTitle : %s\r\n", title.c_str());
- const short text_border_width = 8;
- int start_y = m_cBoxFrame.iY+ m_cBoxFrameTitleRel.iY;
+ int x = m_cBoxFrameTitleRel.iX + m_cBoxFrame.iX;
+ int y = m_cBoxFrameTitleRel.iY + m_cBoxFrame.iY;
+ int w = m_cBoxFrameTitleRel.iWidth;
+ int h = m_cBoxFrameTitleRel.iHeight;
- m_pcWindow->paintBoxRel(m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX, start_y,
- m_cBoxFrameTitleRel.iWidth, m_cBoxFrameTitleRel.iHeight, TITLE_BACKGROUND_COLOR, RADIUS_LARGE, CORNER_TOP);
-
- int iconw = 0, iconh = 0;
- CFrameBuffer::getInstance()->getIconSize(NEUTRINO_ICON_MOVIEPLAYER, &iconw, &iconh);
- m_pcWindow->paintIcon(NEUTRINO_ICON_MOVIEPLAYER, m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+6, start_y+ m_cBoxFrameTitleRel.iHeight/2 - iconh/2);
+ CComponentsHeader header(x, y, w, h, title.c_str(), NEUTRINO_ICON_MOVIEPLAYER);
+ header.paint(CC_SAVE_SCREEN_NO);
- m_pcFontTitle->RenderString(m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX + iconw + text_border_width, start_y + m_cBoxFrameTitleRel.iHeight, m_cBoxFrameTitleRel.iWidth - (text_border_width << 1), title.c_str(), TITLE_FONT_COLOR, 0, true); // UTF-8
info_hdd_level(true);
}
diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp
index 13d81ea53..75fa1da60 100644
--- a/src/gui/network_setup.cpp
+++ b/src/gui/network_setup.cpp
@@ -56,6 +56,7 @@
#include
#include
+#include
extern "C" int pinghost( const char *hostname );
@@ -120,6 +121,10 @@ int CNetworkSetup::exec(CMenuTarget* parent, const std::string &actionKey)
showCurrentNetworkSettings();
return res;
}
+ else if(actionKey=="scanssid")
+ {
+ return showWlanList();
+ }
else if(actionKey=="restore")
{
int result = ShowMsgUTF(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMessageBox::mbrNo,
@@ -306,57 +311,68 @@ int CNetworkSetup::showNetworkSetup()
//------------------------------------------------
networkSettings->addItem( m4); //gateway
networkSettings->addItem( m5); //nameserver
- networkSettings->addItem(GenericMenuSeparatorLine);
//------------------------------------------------
if(ifcount > 1) // if there is only one, its probably wired
{
+ networkSettings->addItem(GenericMenuSeparatorLine);
//ssid
CStringInputSMS * networkSettings_ssid = new CStringInputSMS(LOCALE_NETWORKMENU_SSID, &network_ssid, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789 -_/()<>=+.,:!?\\'");
//key
CStringInputSMS * networkSettings_key = new CStringInputSMS(LOCALE_NETWORKMENU_PASSWORD, &network_key, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.! ");
CMenuForwarder *m9 = new CMenuDForwarder(LOCALE_NETWORKMENU_SSID , networkConfig->wireless, network_ssid , networkSettings_ssid );
CMenuForwarder *m10 = new CMenuDForwarder(LOCALE_NETWORKMENU_PASSWORD , networkConfig->wireless, network_key , networkSettings_key );
+ CMenuForwarder *m11 = new CMenuForwarder(LOCALE_NETWORKMENU_SSID_SCAN , networkConfig->wireless, NULL, this, "scanssid");
m9->setHint("", LOCALE_MENU_HINT_NET_SSID);
m10->setHint("", LOCALE_MENU_HINT_NET_PASS);
+ m11->setHint("", LOCALE_MENU_HINT_NET_SSID_SCAN);
wlanEnable[0] = m9;
wlanEnable[1] = m10;
+ wlanEnable[2] = m11;
+ networkSettings->addItem( m11); //ssid scan
networkSettings->addItem( m9); //ssid
networkSettings->addItem( m10); //key
- networkSettings->addItem(GenericMenuSeparatorLine);
+ if (!g_settings.easymenu)
+ networkSettings->addItem(GenericMenuSeparatorLine);
}
//------------------------------------------------
- //ntp submenu
- sectionsdConfigNotifier = new CSectionsdConfigNotifier;
+ sectionsdConfigNotifier = NULL;
CMenuWidget ntp(LOCALE_MAINSETTINGS_NETWORK, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_NETWORKSETUP_NTP);
- mf = new CMenuForwarder(LOCALE_NETWORKMENU_NTPTITLE, true, NULL, &ntp, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
- mf->setHint("", LOCALE_MENU_HINT_NET_NTP);
- networkSettings->addItem(mf);
+#ifdef ENABLE_GUI_MOUNT
+ CMenuWidget networkmounts(LOCALE_MAINSETTINGS_NETWORK, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_NETWORKSETUP_MOUNTS);
+#endif
+ CProxySetup proxy(LOCALE_MAINSETTINGS_NETWORK);
+ CNetworkServiceSetup services;
- showNetworkNTPSetup(&ntp);
+ if (!g_settings.easymenu) {
+ //ntp submenu
+ sectionsdConfigNotifier = new CSectionsdConfigNotifier;
+ mf = new CMenuForwarder(LOCALE_NETWORKMENU_NTPTITLE, true, NULL, &ntp, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
+ mf->setHint("", LOCALE_MENU_HINT_NET_NTP);
+ networkSettings->addItem(mf);
+
+ showNetworkNTPSetup(&ntp);
#ifdef ENABLE_GUI_MOUNT
- //nfs mount submenu
- CMenuWidget networkmounts(LOCALE_MAINSETTINGS_NETWORK, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_NETWORKSETUP_MOUNTS);
- mf = new CMenuForwarder(LOCALE_NETWORKMENU_MOUNT, true, NULL, &networkmounts, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE);
- mf->setHint("", LOCALE_MENU_HINT_NET_MOUNT);
- networkSettings->addItem(mf);
- showNetworkNFSMounts(&networkmounts);
+ //nfs mount submenu
+ mf = new CMenuForwarder(LOCALE_NETWORKMENU_MOUNT, true, NULL, &networkmounts, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE);
+ mf->setHint("", LOCALE_MENU_HINT_NET_MOUNT);
+ networkSettings->addItem(mf);
+ showNetworkNFSMounts(&networkmounts);
#endif
- //proxyserver submenu
- CProxySetup proxy(LOCALE_MAINSETTINGS_NETWORK);
- mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYSERVER_SEP, true, NULL, &proxy, NULL, CRCInput::RC_0, NEUTRINO_ICON_BUTTON_0);
- mf->setHint("", LOCALE_MENU_HINT_NET_PROXY);
- networkSettings->addItem(mf);
+ //proxyserver submenu
+ mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYSERVER_SEP, true, NULL, &proxy, NULL, CRCInput::RC_0, NEUTRINO_ICON_BUTTON_0);
+ mf->setHint("", LOCALE_MENU_HINT_NET_PROXY);
+ networkSettings->addItem(mf);
- //services
- CNetworkServiceSetup services;
- mf = new CMenuForwarder(LOCALE_NETWORKMENU_SERVICES, true, NULL, &services, NULL, CRCInput::RC_1, NEUTRINO_ICON_BUTTON_1);
- mf->setHint("", LOCALE_MENU_HINT_NET_SERVICES);
- networkSettings->addItem(mf);
+ //services
+ mf = new CMenuForwarder(LOCALE_NETWORKMENU_SERVICES, true, NULL, &services, NULL, CRCInput::RC_1, NEUTRINO_ICON_BUTTON_1);
+ mf->setHint("", LOCALE_MENU_HINT_NET_SERVICES);
+ networkSettings->addItem(mf);
+ }
int ret = 0;
while(true) {
@@ -642,7 +658,6 @@ bool CNetworkSetup::changeNotify(const neutrino_locale_t locale, void * Data)
int ecnt = sizeof(wlanEnable) / sizeof(CMenuForwarder*);
for(int i = 0; i < ecnt; i++)
wlanEnable[i]->setActive(CNetworkConfig::getInstance()->wireless);
-
} else if(locale == LOCALE_NETWORKMENU_DHCP) {
CNetworkConfig::getInstance()->inet_static = (network_dhcp == NETWORK_DHCP_OFF);
int ecnt = sizeof(dhcpDisable) / sizeof(CMenuForwarder*);
@@ -791,3 +806,50 @@ void CNetworkSetup::testNetworkSettings()
ShowMsgUTF(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8
}
+
+int CNetworkSetup::showWlanList()
+{
+ int res = menu_return::RETURN_REPAINT;
+
+ CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_WAIT));
+ hintBox.paint();
+
+ std::vector networks;
+ bool found = get_wlan_list(g_settings.ifname, networks);
+ hintBox.hide();
+ if (!found) {
+ ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_ERROR), CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8
+ return res;
+ }
+
+ CMenuWidget wlist(LOCALE_MAINSETTINGS_NETWORK, NEUTRINO_ICON_SETTINGS, width);
+ wlist.addIntroItems(LOCALE_NETWORKMENU_SSID_SCAN); //intros
+
+ char cnt[5];
+ int select = -1;
+ CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select);
+
+ std::string option[networks.size()];
+ for (unsigned i = 0; i < networks.size(); ++i) {
+ sprintf(cnt, "%d", i);
+
+ option[i] = networks[i].qual;
+ option[i] += ", ";
+ option[i] += networks[i].channel;
+
+ const char * icon = NULL;
+ if (networks[i].encrypted)
+ icon = NEUTRINO_ICON_LOCK;
+ CMenuForwarderNonLocalized * net = new CMenuForwarderNonLocalized(networks[i].ssid.c_str(), true, option[i], selector, cnt, CRCInput::RC_nokey, NULL, icon);
+ net->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
+ wlist.addItem(net, networks[i].ssid == network_ssid);
+ }
+ res = wlist.exec(NULL, "");
+ delete selector;
+
+ printf("CNetworkSetup::showWlanList: selected: %d\n", select);
+ if (select >= 0) {
+ network_ssid = networks[select].ssid;
+ }
+ return res;
+}
diff --git a/src/gui/network_setup.h b/src/gui/network_setup.h
index 2464f573c..f2c015c24 100644
--- a/src/gui/network_setup.h
+++ b/src/gui/network_setup.h
@@ -75,7 +75,7 @@ class CNetworkSetup : public CMenuTarget, CChangeObserver
CMenuForwarder* dhcpDisable[5];
- CMenuForwarder* wlanEnable[2];
+ CMenuForwarder* wlanEnable[3];
CSectionsdConfigNotifier* sectionsdConfigNotifier;
@@ -89,7 +89,8 @@ class CNetworkSetup : public CMenuTarget, CChangeObserver
int saveChangesDialog();
void applyNetworkSettings();
void saveNetworkSettings();
-
+ int showWlanList();
+
bool checkIntSettings();
bool checkStringSettings();
bool checkForIP();
diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp
index f59e21fc6..9776ffbb5 100644
--- a/src/gui/osd_setup.cpp
+++ b/src/gui/osd_setup.cpp
@@ -10,7 +10,7 @@
Copyright (C) 2010 T. Graf 'dbt'
Homepage: http://www.dbox2-tuning.net/
- Copyright (C) 2010, 2012-2103 Stefan Seyfried
+ Copyright (C) 2010, 2012-2013 Stefan Seyfried
License: GPL
@@ -270,27 +270,11 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey)
return res;
}
else if(actionKey=="window_size") {
- if (win_demo == NULL) {
- win_demo = new CComponentsShapeSquare(0, 0, 0, 0);
- win_demo->setFrameThickness(8);
- win_demo->setShadowOnOff(CC_SHADOW_OFF);
- win_demo->setColorBody(COL_BACKGROUND);
- win_demo->setColorFrame(COL_RED);
- win_demo->doPaintBg(true);
- }
- else {
- if (win_demo->isPainted())
- win_demo->kill();
- }
+ int old_window_width = g_settings.window_width;
+ int old_window_height = g_settings.window_height;
- win_demo->setWidth(frameBuffer->getScreenWidthRel());
- win_demo->setHeight(frameBuffer->getScreenHeightRel());
- win_demo->setXPos(getScreenStartX(win_demo->getWidth()));
- win_demo->setYPos(getScreenStartY(win_demo->getHeight()));
+ paintWindowSize(old_window_width, old_window_height);
- win_demo->paint(CC_SAVE_SCREEN_NO);
-
- int old_window_size = g_settings.window_size;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]);
bool loop=true;
@@ -303,30 +287,34 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey)
if ( msg == CRCInput::RC_ok ) {
loop = false;
memset(window_size_value, 0, sizeof(window_size_value));
- snprintf(window_size_value, sizeof(window_size_value)-1, "%d", g_settings.window_size);
+ snprintf(window_size_value, sizeof(window_size_value), "%d / %d", g_settings.window_width, g_settings.window_height);
mfWindowSize->setOption(window_size_value);
break;
} else if ((msg == CRCInput::RC_home) || (msg == CRCInput::RC_timeout)) {
- g_settings.window_size = old_window_size;
+ g_settings.window_width = old_window_width;
+ g_settings.window_height = old_window_height;
loop = false;
- } else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)) {
- if ((msg == CRCInput::RC_up) && (g_settings.window_size < WINDOW_SIZE_MAX)) {
- g_settings.window_size += 1;
- }
- if ((msg == CRCInput::RC_down) && (g_settings.window_size > WINDOW_SIZE_MIN)) {
- g_settings.window_size -= 1;
- }
+ } else if ((msg == CRCInput::RC_page_up) || (msg == CRCInput::RC_page_down) ||
+ (msg == CRCInput::RC_left) || (msg == CRCInput::RC_right) ||
+ (msg == CRCInput::RC_up) || (msg == CRCInput::RC_down)) {
- if (win_demo->isPainted())
- win_demo->kill();
+ int dir = 1;
+ if ((msg == CRCInput::RC_page_down) || (msg == CRCInput::RC_left) || (msg == CRCInput::RC_down))
+ dir = -1;
- win_demo->setWidth(frameBuffer->getScreenWidthRel());
- win_demo->setHeight(frameBuffer->getScreenHeightRel());
- win_demo->setXPos(getScreenStartX(win_demo->getWidth()));
- win_demo->setYPos(getScreenStartY(win_demo->getHeight()));
+ int mask = 3;
+ if ((msg == CRCInput::RC_left) || (msg == CRCInput::RC_right))
+ mask = 1;
+ else if ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))
+ mask = 2;
+ if (mask & 1)
+ g_settings.window_width += dir;
+ if (mask & 2)
+ g_settings.window_height += dir;
- win_demo->paint(CC_SAVE_SCREEN_NO);
+ paintWindowSize(g_settings.window_width, g_settings.window_height);
+ } else if ((msg == CRCInput::RC_left) || (msg == CRCInput::RC_right)) {
} else if (msg > CRCInput::RC_MaxRC) {
if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) {
loop = false;
@@ -602,7 +590,7 @@ int COsdSetup::showOsdSetup()
// window size
memset(window_size_value, 0, sizeof(window_size_value));
- snprintf(window_size_value, sizeof(window_size_value)-1, "%d", g_settings.window_size);
+ snprintf(window_size_value, sizeof(window_size_value), "%d / %d", g_settings.window_width, g_settings.window_height);
mfWindowSize = new CMenuForwarder(LOCALE_WINDOW_SIZE, true, window_size_value, this, "window_size", CRCInput::convertDigitToKey(shortcut++));
mfWindowSize->setHint("", LOCALE_MENU_HINT_WINDOW_SIZE);
osd_menu->addItem(mfWindowSize);
@@ -1206,3 +1194,37 @@ void COsdSetup::showOsdScreenShotSetup(CMenuWidget *menu_screenshot)
menu_screenshot->addItem(mc);
}
#endif
+
+void COsdSetup::paintWindowSize(int w, int h)
+{
+ if (win_demo == NULL) {
+ win_demo = new CComponentsShapeSquare(0, 0, 0, 0);
+ win_demo->setFrameThickness(8);
+ win_demo->setShadowOnOff(CC_SHADOW_OFF);
+ win_demo->setColorBody(COL_BACKGROUND);
+ win_demo->setColorFrame(COL_RED);
+ win_demo->doPaintBg(true);
+ }
+ else {
+ if (win_demo->isPainted())
+ win_demo->kill();
+ }
+
+ g_settings.window_width = w;
+ g_settings.window_height = h;
+ if (g_settings.window_width > WINDOW_SIZE_MAX)
+ g_settings.window_width = WINDOW_SIZE_MAX;
+ if (g_settings.window_width < WINDOW_SIZE_MIN)
+ g_settings.window_width = WINDOW_SIZE_MIN;
+ if (g_settings.window_height > WINDOW_SIZE_MAX)
+ g_settings.window_height = WINDOW_SIZE_MAX;
+ if (g_settings.window_height < WINDOW_SIZE_MIN)
+ g_settings.window_height = WINDOW_SIZE_MIN;
+
+ win_demo->setWidth(frameBuffer->getScreenWidthRel());
+ win_demo->setHeight(frameBuffer->getScreenHeightRel());
+ win_demo->setXPos(getScreenStartX(win_demo->getWidth()));
+ win_demo->setYPos(getScreenStartY(win_demo->getHeight()));
+
+ win_demo->paint(CC_SAVE_SCREEN_NO);
+}
diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h
index d392d4cd7..68ab6ad17 100644
--- a/src/gui/osd_setup.h
+++ b/src/gui/osd_setup.h
@@ -31,7 +31,7 @@
#ifndef __osd_setup__
#define __osd_setup__
-#include
+#include
#include
#include
@@ -50,7 +50,7 @@ class COsdSetup : public CMenuTarget, public CChangeObserver
CMenuWidget *osd_menu;
CMenuWidget *submenu_menus;
CMenuForwarder *mfFontFile, *mfTtxFontFile, *mfWindowSize;
- char window_size_value[6];
+ char window_size_value[10];
std::string osdFontFile, osdTtxFontFile;
CComponentsShapeSquare *win_demo;
@@ -69,6 +69,7 @@ class COsdSetup : public CMenuTarget, public CChangeObserver
void showOsdEventlistSetup(CMenuWidget *menu_eventlist);
void showOsdVolumeSetup(CMenuWidget *menu_volume);
void showOsdScreenShotSetup(CMenuWidget *menu_screenshot);
+ void paintWindowSize(int w, int h);
void AddFontSettingItem(CMenuWidget &font_Settings, const SNeutrinoSettings::FONT_TYPES number_of_fontsize_entry);
diff --git a/src/gui/parentallock_setup.cpp b/src/gui/parentallock_setup.cpp
index 5260fbd97..fba9290d0 100644
--- a/src/gui/parentallock_setup.cpp
+++ b/src/gui/parentallock_setup.cpp
@@ -59,7 +59,7 @@ int CParentalSetup::exec(CMenuTarget* parent, const std::string &/*actionKey*/)
parent->hide();
if (check())
- showParentalSetup();
+ res = showParentalSetup();
return res;
}
@@ -97,7 +97,7 @@ const CMenuOptionChooser::keyval PARENTALLOCK_DEFAULTLOCKED_OPTIONS[PARENTALLOCK
};
extern bool parentallocked;
-void CParentalSetup::showParentalSetup()
+int CParentalSetup::showParentalSetup()
{
//menue init
CMenuWidget* plock = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_LOCK, width, MN_WIDGET_ID_PLOCKSETUP);
@@ -108,22 +108,38 @@ void CParentalSetup::showParentalSetup()
// intros
plock->addIntroItems();
+ CPersonalizeGui &p = CNeutrinoApp::getInstance()->getPersonalizeGui();
+ CMenuForwarder * mf = new CMenuForwarder(LOCALE_PARENTALLOCK_MENU, true, NULL, &p, NULL, CRCInput::RC_red , NEUTRINO_ICON_BUTTON_RED);
+ mf->setHint("", LOCALE_MENU_HINT_PARENTALLOCK_MENU);
+ plock->addItem(mf);
+
CMenuOptionChooser * mc;
- mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_PROMPT , &g_settings.parentallock_prompt , PARENTALLOCK_PROMPT_OPTIONS, PARENTALLOCK_PROMPT_OPTION_COUNT , !parentallocked);
+ if (g_settings.easymenu)
+ mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_PROMPT , &g_settings.parentallock_prompt , PARENTALLOCK_PROMPT_OPTIONS, PARENTALLOCK_PROMPT_OPTION_COUNT , !parentallocked, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN);
+ else
+ mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_PROMPT , &g_settings.parentallock_prompt , PARENTALLOCK_PROMPT_OPTIONS, PARENTALLOCK_PROMPT_OPTION_COUNT , !parentallocked);
mc->setHint("", LOCALE_MENU_HINT_PARENTALLOCK_PROMPT);
plock->addItem(mc);
- mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_LOCKAGE, &g_settings.parentallock_lockage, PARENTALLOCK_LOCKAGE_OPTIONS, PARENTALLOCK_LOCKAGE_OPTION_COUNT, !parentallocked);
+ if (g_settings.easymenu)
+ mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_LOCKAGE, &g_settings.parentallock_lockage, PARENTALLOCK_LOCKAGE_OPTIONS, PARENTALLOCK_LOCKAGE_OPTION_COUNT, !parentallocked, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW);
+ else
+ mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_LOCKAGE, &g_settings.parentallock_lockage, PARENTALLOCK_LOCKAGE_OPTIONS, PARENTALLOCK_LOCKAGE_OPTION_COUNT, !parentallocked);
mc->setHint("", LOCALE_MENU_HINT_PARENTALLOCK_LOCKAGE);
plock->addItem(mc);
- plock->addItem(new CMenuOptionChooser(LOCALE_PARENTALLOCK_BOUQUETMODE, &g_settings.parentallock_defaultlocked, PARENTALLOCK_DEFAULTLOCKED_OPTIONS, PARENTALLOCK_DEFAULTLOCKED_OPTION_COUNT, !parentallocked));
+ if (g_settings.easymenu)
+ mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_BOUQUETMODE, &g_settings.parentallock_defaultlocked, PARENTALLOCK_DEFAULTLOCKED_OPTIONS, PARENTALLOCK_DEFAULTLOCKED_OPTION_COUNT, !parentallocked, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE);
+ else
+ mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_BOUQUETMODE, &g_settings.parentallock_defaultlocked, PARENTALLOCK_DEFAULTLOCKED_OPTIONS, PARENTALLOCK_DEFAULTLOCKED_OPTION_COUNT, !parentallocked);
+ plock->addItem(mc);
CPINChangeWidget pinChangeWidget(LOCALE_PARENTALLOCK_CHANGEPIN, g_settings.parentallock_pincode, 4, LOCALE_PARENTALLOCK_CHANGEPIN_HINT1);
- CMenuForwarder * mf = new CMenuForwarder(LOCALE_PARENTALLOCK_CHANGEPIN, true, g_settings.parentallock_pincode, &pinChangeWidget);
+ mf = new CMenuForwarder(LOCALE_PARENTALLOCK_CHANGEPIN, true, g_settings.parentallock_pincode, &pinChangeWidget);
mf->setHint("", LOCALE_MENU_HINT_PARENTALLOCK_CHANGEPIN);
plock->addItem(mf);
- plock->exec(NULL, "");
+ int res = plock->exec(NULL, "");
delete plock;
+ return res;
}
diff --git a/src/gui/parentallock_setup.h b/src/gui/parentallock_setup.h
index fde2310ed..d2e102782 100644
--- a/src/gui/parentallock_setup.h
+++ b/src/gui/parentallock_setup.h
@@ -44,7 +44,7 @@ class CParentalSetup : public CMenuTarget, public CPINProtection
{
private:
int width;
- void showParentalSetup();
+ int showParentalSetup();
protected:
virtual CMenuTarget* getParent() { return( NULL);};
@@ -58,6 +58,7 @@ class CParentalSetup : public CMenuTarget, public CPINProtection
};
~CParentalSetup();
int exec(CMenuTarget* parent, const std::string & actionKey);
+ bool checkPin() { return check(); }
};
diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp
index 4cebbb484..d9637f11a 100644
--- a/src/gui/personalize.cpp
+++ b/src/gui/personalize.cpp
@@ -256,8 +256,9 @@ int CPersonalizeGui::exec(CMenuTarget* parent, const string & actionKey)
//pin protected access to personalize menu also if found any pin protected items
bool is_pin_protected = g_settings.personalize[SNeutrinoSettings::P_MAIN_PINSTATUS];
- if ( is_pin_protected || hasPinItems()){
+ if (!g_settings.easymenu && (is_pin_protected || hasPinItems())) {
setHint(LOCALE_PERSONALIZE_PINHINT); //from CPINProtection
+ is_pin_protected = true;
if (check())
is_pin_protected = false;
}
@@ -283,14 +284,45 @@ int CPersonalizeGui::ShowPersonalizationMenu()
{
width = w_max (40, 10);
- CMenuWidget* pMenu = new CMenuWidget(LOCALE_PERSONALIZE_HEAD, NEUTRINO_ICON_PERSONALIZE, width, MN_WIDGET_ID_PERSONALIZE);
+ CMenuWidget* pMenu = new CMenuWidget(g_settings.easymenu ? LOCALE_PARENTALLOCK_MENU : LOCALE_PERSONALIZE_HEAD, NEUTRINO_ICON_PERSONALIZE, width, MN_WIDGET_ID_PERSONALIZE);
pMenu->addIntroItems(NONEXISTANT_LOCALE, LOCALE_PERSONALIZE_ACCESS);
//pin
CPINChangeWidget *pinChangeWidget = NULL;
- if (show_pin_setup)
+ if (!g_settings.easymenu && show_pin_setup)
ShowPinSetup(pMenu, pinChangeWidget);
+ int res;
+ if (g_settings.easymenu) {
+ int count = 0;
+ for (uint j = 0; jgetName().c_str());
+ //pin protected items only
+ if (v_item[j].item_mode == PERSONALIZE_SHOW_AS_ACCESS_OPTION)
+ {
+ const char* icon = (count == 0) ? NEUTRINO_ICON_BUTTON_RED :
+ (count == 1) ? NEUTRINO_ICON_BUTTON_GREEN :
+ (count == 2) ? NEUTRINO_ICON_BUTTON_YELLOW :
+ (count == 3) ? NEUTRINO_ICON_BUTTON_BLUE : NULL;
+ const neutrino_msg_t key = (count == 0) ? CRCInput::RC_red :
+ (count == 1) ? CRCInput::RC_green :
+ (count == 2) ? CRCInput::RC_yellow :
+ (count == 3) ? CRCInput::RC_blue : CRCInput::RC_nokey;
+ count++;
+ string itm_name = g_Locale->getText(v_item[j].locale_name);
+ itm_name += " ";
+ itm_name += g_Locale->getText(LOCALE_PERSONALIZE_PINSTATUS);
+
+ if (v_item[j].personalize_mode != NULL)
+ pMenu->addItem(new CMenuOptionChooser(itm_name.c_str(), v_item[j].personalize_mode, PERSONALIZE_PROTECT_MODE_OPTIONS, PERSONALIZE_PROTECT_MODE_MAX, v_item[j].menuItem->active, NULL, key, icon));
+ }
+ }
+ res = pMenu->exec(NULL, "");
+ delete pMenu;
+ delete pinChangeWidget;
+ return res;
+ }
+
//personalized menues
CMenuForwarderNonLocalized *p_mn[widget_count];
for (int i = 0; i<(widget_count); i++)
@@ -322,7 +354,7 @@ int CPersonalizeGui::ShowPersonalizationMenu()
pMenu->addItem(GenericMenuSeparatorLine);
pMenu->addItem(new CMenuForwarder(LOCALE_PERSONALIZE_HELP, true, NULL, this, "personalize_help", CRCInput::RC_help, NEUTRINO_ICON_BUTTON_HELP));
- int res = pMenu->exec(NULL, "");
+ res = pMenu->exec(NULL, "");
delete pMenu;
delete uMenu;
delete pinChangeWidget;
@@ -338,7 +370,7 @@ int CPersonalizeGui::ShowPersonalizationMenu()
}
//init pin setup dialog
-void CPersonalizeGui::ShowPinSetup(CMenuWidget* p_widget, CPINChangeWidget *pin_widget)
+void CPersonalizeGui::ShowPinSetup(CMenuWidget* p_widget, CPINChangeWidget * &pin_widget)
{
pin_widget = new CPINChangeWidget(LOCALE_PERSONALIZE_PINCODE, g_settings.personalize_pincode, 4, LOCALE_PERSONALIZE_PINHINT);
@@ -346,7 +378,7 @@ void CPersonalizeGui::ShowPinSetup(CMenuWidget* p_widget, CPINChangeWidget *pin_
pin_setup_notifier = new CPinSetupNotifier(fw_pin_setup);
p_widget->addItem(new CMenuOptionChooser(LOCALE_PERSONALIZE_PIN_IN_USE, &g_settings.personalize[SNeutrinoSettings::P_MAIN_PINSTATUS], OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, pin_setup_notifier));
- fw_pin_setup->setActive(pin_setup_notifier->changeNotify());
+ pin_setup_notifier->changeNotify();
p_widget->addItem(fw_pin_setup);
p_widget->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_PERSONALIZE_MENUCONFIGURATION));
@@ -446,7 +478,7 @@ void CPersonalizeGui::ShowPluginMenu(CMenuWidget* p_widget)
int CPersonalizeGui::ShowMenuOptions(const int& widget)
{
string mn_name = v_widget[widget]->getName();
- printf("[neutrino-personalize] exec %s...\n", __FUNCTION__);
+ printf("[neutrino-personalize] exec %s for [%s]...\n", __FUNCTION__, mn_name.c_str());
mn_widget_id_t w_index = widget+MN_WIDGET_ID_PERSONALIZE_MAIN;
CMenuWidget* pm = new CMenuWidget(LOCALE_PERSONALIZE_HEAD, NEUTRINO_ICON_PERSONALIZE, width, w_index);
@@ -597,24 +629,31 @@ void CPersonalizeGui::ShowHelpPersonalize()
helpbox.show(LOCALE_PERSONALIZE_HELP);
}
+void CPersonalizeGui::ApplySettings()
+{
+ // replace old settings with new settings
+ for (uint i = 0; i < v_int_settings.size(); i++)
+ v_int_settings[i].old_val = *v_int_settings[i].p_val;
+ for (int i = 0; i<(widget_count); i++)
+ v_widget[i]->resetWidget();
+
+ addPersonalizedItems();
+}
+
void CPersonalizeGui::SaveAndExit()
{
// Save the settings and left menu, if user wants to!
if (haveChangedSettings())
{
+ if (g_settings.easymenu) {
+ ApplySettings();
+ return;
+ }
if (ShowMsgUTF(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_PERSONALIZE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes)
{
CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MAINSETTINGS_SAVESETTINGSNOW_HINT)); // UTF-8
hintBox.paint();
- // replace old settings with new settings
- for (uint i = 0; i < v_int_settings.size(); i++)
- v_int_settings[i].old_val = *v_int_settings[i].p_val;
- //CNeutrinoApp::getInstance()->saveSetup();
-
- for (int i = 0; i<(widget_count); i++)
- v_widget[i]->resetWidget();
-
- addPersonalizedItems();
+ ApplySettings();
hintBox.hide();
}
else
@@ -803,7 +842,7 @@ void CPersonalizeGui::addPersonalizedItems()
use_pin = true;
//set pinmode for personalize menu or for settings manager menu and if any item is pin protected
- if (in_pinmode && !use_pin)
+ if (!g_settings.easymenu && (in_pinmode && !use_pin))
if (v_item[i].personalize_mode == &g_settings.personalize[SNeutrinoSettings::P_MAIN_PINSTATUS] || v_item[i].personalize_mode == &g_settings.personalize[SNeutrinoSettings::P_MSET_SETTINGS_MANAGER])
{
use_pin = true;
@@ -811,7 +850,9 @@ void CPersonalizeGui::addPersonalizedItems()
}
//convert item to locked forwarder and use generated pin mode for usage as ask parameter
- v_item[i].menuItem = new CLockedMenuForwarder(fw->getTextLocale(), g_settings.personalize_pincode, use_pin, fw->active, NULL, fw->getTarget(), fw->getActionKey().c_str(), d_key, fw->iconName.c_str(), lock_icon);
+ v_item[i].menuItem = new CLockedMenuForwarder(fw->getTextLocale(),
+ g_settings.easymenu ? g_settings.parentallock_pincode : g_settings.personalize_pincode,
+ use_pin, fw->active, NULL, fw->getTarget(), fw->getActionKey().c_str(), d_key, fw->iconName.c_str(), lock_icon);
v_item[i].menuItem->hintIcon = fw->hintIcon;
v_item[i].menuItem->hint = fw->hint;
//add item if it's set to visible or pin protected and allow to add an forwarder as next
@@ -934,5 +975,6 @@ bool CPinSetupNotifier::changeNotify(const neutrino_locale_t, void *)
{
toDisable->setActive(g_settings.personalize[SNeutrinoSettings::P_MAIN_PINSTATUS]);
- return g_settings.personalize[SNeutrinoSettings::P_MAIN_PINSTATUS];
+// return g_settings.personalize[SNeutrinoSettings::P_MAIN_PINSTATUS];
+ return false;
}
diff --git a/src/gui/personalize.h b/src/gui/personalize.h
index 9b6a452c4..cb537d4b4 100644
--- a/src/gui/personalize.h
+++ b/src/gui/personalize.h
@@ -164,11 +164,12 @@ class CPersonalizeGui : public CMenuTarget, public CChangeObserver, public CPINP
int ShowPersonalizationMenu();
int ShowMenuOptions(const int& menu);
void ShowHelpPersonalize();
- void ShowPinSetup(CMenuWidget* p_widget, CPINChangeWidget *pin_widget);
+ void ShowPinSetup(CMenuWidget* p_widget, CPINChangeWidget * &pin_widget);
void ShowUserMenu(CMenuWidget* p_widget, std::vector &v_umenu);
void ShowPluginMenu(CMenuWidget* p_widget);
void ShowPreverredKeySetup(CMenuWidget* p_widget);
void SaveAndExit();
+ void ApplySettings();
bool hasPinItems();
@@ -193,7 +194,7 @@ class CPersonalizeGui : public CMenuTarget, public CChangeObserver, public CPINP
PERSONALIZE_PROTECT_MODE_NOT_PROTECTED = 0,
PERSONALIZE_PROTECT_MODE_PIN_PROTECTED = 2,
- PERSONALIZE_PROTECT_MODE_MAX
+ PERSONALIZE_PROTECT_MODE_MAX = 2
};
//options for show_epg_feat options
diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp
index e53b18e05..1e691cc98 100644
--- a/src/gui/pictureviewer.cpp
+++ b/src/gui/pictureviewer.cpp
@@ -50,7 +50,7 @@
#include
#endif
-#include
+#include
#include