diff --git a/SettingsGUI/tags/0.8/docs/icon/2spaners-001-128.png b/SettingsGUI/tags/0.8/docs/icon/2spaners-001-128.png new file mode 100644 index 0000000..774f9b0 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/icon/2spaners-001-128.png differ diff --git a/SettingsGUI/tags/0.8/docs/icon/2spaners-001-48.png b/SettingsGUI/tags/0.8/docs/icon/2spaners-001-48.png new file mode 100644 index 0000000..97854d4 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/icon/2spaners-001-48.png differ diff --git a/SettingsGUI/tags/0.8/docs/icon/2spaners-001.blend b/SettingsGUI/tags/0.8/docs/icon/2spaners-001.blend new file mode 100644 index 0000000..d68278f Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/icon/2spaners-001.blend differ diff --git a/SettingsGUI/tags/0.8/docs/icon/2spaners-001.jpeg.jpg b/SettingsGUI/tags/0.8/docs/icon/2spaners-001.jpeg.jpg new file mode 100644 index 0000000..ba612ce Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/icon/2spaners-001.jpeg.jpg differ diff --git a/SettingsGUI/tags/0.8/docs/icon/SettingsGUI-48.png b/SettingsGUI/tags/0.8/docs/icon/SettingsGUI-48.png new file mode 100644 index 0000000..97854d4 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/icon/SettingsGUI-48.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.3.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.3.png new file mode 100644 index 0000000..ed2d3db Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.3.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-audio.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-audio.png new file mode 100644 index 0000000..43bb1fb Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-audio.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-gprs.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-gprs.png new file mode 100644 index 0000000..a45c904 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-gprs.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-gsm.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-gsm.png new file mode 100644 index 0000000..9fb772a Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-gsm.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-scaled.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-scaled.png new file mode 100644 index 0000000..3d62ec4 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-scaled.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-screen_.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-screen_.png new file mode 100644 index 0000000..dbf80ba Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6-screen_.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6.png new file mode 100644 index 0000000..6c6673e Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.6.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-audio.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-audio.png new file mode 100644 index 0000000..90cc158 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-audio.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-close_gprs.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-close_gprs.png new file mode 100644 index 0000000..54512c9 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-close_gprs.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-gprs.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-gprs.png new file mode 100644 index 0000000..756f7bb Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-gprs.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-gsm.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-gsm.png new file mode 100644 index 0000000..9845091 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-gsm.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-screen.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-screen.png new file mode 100644 index 0000000..4cca4a6 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-screen.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-terminate-gsmd.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-terminate-gsmd.png new file mode 100644 index 0000000..24cc818 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.7-terminate-gsmd.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-audio.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-audio.png new file mode 100644 index 0000000..71aefad Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-audio.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-bluetooth.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-bluetooth.png new file mode 100644 index 0000000..985b338 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-bluetooth.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-gprs.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-gprs.png new file mode 100644 index 0000000..c2ac804 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-gprs.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-gsm.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-gsm.png new file mode 100644 index 0000000..a54e5e8 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-gsm.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-screen.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-screen.png new file mode 100644 index 0000000..6d99243 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-0.8-screen.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-Backlight-in_action.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-Backlight-in_action.png new file mode 100644 index 0000000..d2219f3 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-Backlight-in_action.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-Backlight.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-Backlight.png new file mode 100644 index 0000000..1d138ae Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-Backlight.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-GSM-0_5.png.png b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-GSM-0_5.png.png new file mode 100644 index 0000000..2443ab3 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-GSM-0_5.png.png differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-GSM-in_action.jpeg b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-GSM-in_action.jpeg new file mode 100644 index 0000000..33a455b Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/SettingsGUI-GSM-in_action.jpeg differ diff --git a/SettingsGUI/tags/0.8/docs/screenshots/audio-0_4.png b/SettingsGUI/tags/0.8/docs/screenshots/audio-0_4.png new file mode 100644 index 0000000..a78e0c4 Binary files /dev/null and b/SettingsGUI/tags/0.8/docs/screenshots/audio-0_4.png differ diff --git a/SettingsGUI/tags/0.8/docs/settingsgui.desktop b/SettingsGUI/tags/0.8/docs/settingsgui.desktop new file mode 100644 index 0000000..45cbe1c --- /dev/null +++ b/SettingsGUI/tags/0.8/docs/settingsgui.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Version=0.7 +Type=Application +Name=SettingsGUI +Comment=Settings Utility +Categories=Utility +Exec=settingsgui +Icon=SettingsGUI-48.png +Terminal=false +SingleInstance=true + diff --git a/SettingsGUI/tags/0.8/src/COPYING b/SettingsGUI/tags/0.8/src/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/SettingsGUI/tags/0.8/src/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + 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 Library 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 +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 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 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. + + 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. + + 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. + + 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. + + 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. + + 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 +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. + +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. + +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. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 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 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. + + 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. + + NO 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. + + 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 + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +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 +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 + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + 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, 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 your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + 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 Library General +Public License instead of this License. diff --git a/SettingsGUI/tags/0.8/src/copy_to_neo.sh b/SettingsGUI/tags/0.8/src/copy_to_neo.sh new file mode 100755 index 0000000..721642e --- /dev/null +++ b/SettingsGUI/tags/0.8/src/copy_to_neo.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +# scp -r *.py moko:/media/card/SettingsGUI-0.8 +scp -r settingsgui/*.py moko:/media/card/SettingsGUI-0.8/settingsgui diff --git a/SettingsGUI/tags/0.8/src/settings b/SettingsGUI/tags/0.8/src/settings new file mode 100755 index 0000000..f678465 --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settings @@ -0,0 +1,41 @@ +#!/usr/bin/python +""" + * settings-gui.py - script to start the application + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import gtk +from settingsgui.SettingsGUI import * + +def main(): + gobject.timeout_add(500, SettingGUI.create_UI) # every 1/2 second + try: + if gtk.gtk_version[0] == 2: + gtk.gdk.threads_init() + except: + pass + gtk.gdk.threads_enter() + gtk.main() + gtk.gdk.threads_leave() + +if (__name__ == '__main__'): + gtk.gdk.threads_init() + gtk.gdk.threads_enter() + + SettingGUI = SettingsGUI() + main() diff --git a/SettingsGUI/tags/0.8/src/settingsgui/AudioPanel.py b/SettingsGUI/tags/0.8/src/settingsgui/AudioPanel.py new file mode 100644 index 0000000..3e85efa --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/AudioPanel.py @@ -0,0 +1,160 @@ +""" + * AudioPanel.py - SettingsGUI - Audio Settings + * + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import sys +import os +import gtk +import SysFSAccess +#from settingsgui.GlobalConfiguration import * +from GlobalConfiguration import * + + +class AudioPanel(gtk.VBox): + def __init__(self): + gtk.VBox.__init__(self, False, 0) + self.muted = 0 + self.volume_scales = {} + self.create_notebook_page() + + def profile_changed_callback(self, box): + os.system("/usr/sbin/alsactl -f %s%s restore" % ( + ALSA_STATES_DIR, ALSA_ENTRYS[box.get_active_text()])) + print "called [%s]" % "/usr/sbin/alsactl -f %s%s restore" % ( + ALSA_STATES_DIR, ALSA_ENTRYS[box.get_active_text()]) + + ## update scales + for entry in self.volume_scales: + self.volume_scales[entry].value = self.get_volume(entry) + + ## callback save from button + def save_profile(self, widget): + os.system("/usr/sbin/alsactl -f %s%s store" % ( + ALSA_STATES_DIR, ALSA_ENTRYS[self.profile_combo.get_active_text()])) + print "called [%s]" % "/usr/sbin/alsactl -f %s%s store" % ( + ALSA_STATES_DIR, ALSA_ENTRYS[self.profile_combo.get_active_text()]) + + + ## called when a scaled was touched + def volume_changed_callback(self, scale, channel): + self.set_volume(channel, scale.value) + + ## callback from mute button + def mute_audio(self, widget): + if self.muted != 1: + self.set_volume(ALSA_CHANNEL_RIGHT, 0) + self.set_volume(ALSA_CHANNEL_LEFT, 0) + self.set_volume(ALSA_CHANNEL_MONO, 0) + self.mute_tbn.set_label("Unmute") + self.muted = 1 + else: + for scale in self.volume_scales: + self.set_volume(scale, self.volume_scales[scale].value) + self.mute_tbn.set_label("Mute") + self.muted = 0 + + ## will use amixer for now - so we dont depend on python-alsa which is not + ## in OpenEmbedded now... + def set_volume(self, chan_id, value): + amix_ostream = os.popen("%s cset numid=%d %d" %(ALSA_AMIXER, chan_id, value)) + return True; + + def read_alsa_mixer(self): + amix_ostream = os.popen("%s" %ALSA_AMIXER) + mixer = {} ## dict of mixer controls + mixer_entry = {} + for line in amix_ostream.read().split('\n'): + if not line.startswith(" "): + if len(line.split("'")) >= 2: + mixer["%s" % line.split("'")[1]] = {} + mixer_entry = mixer["%s" % line.split("'")[1]] + + + ## will use amixer for now - so we dont depend on python-alsa which is not + ## in OpenEmbedded now... + def get_volume(self, chan_id): + amix_ostream = os.popen("%s cget numid=%d" %(ALSA_AMIXER, chan_id)) + # ToDo - parse everything! + amix_out = amix_ostream.readline() + amix_out = amix_ostream.readline() + amix_out = amix_ostream.readline() + if amix_out.find("value") >= 0: + return int(amix_out.split('=')[1]) + return 0; + + def get_max_volume(self, chan_id): + amix_ostream = os.popen("%s cget numid=%d" %(ALSA_AMIXER, chan_id)) + # ToDo - parse everything! + amix_out = amix_ostream.readline() + amix_out = amix_ostream.readline() + for value_entry in amix_out.split(','): + if value_entry.find("max") >= 0: + return int(value_entry.split('=')[1]) + return 100; + + def create_notebook_page(self): + audio_channels = [ + ["Right Speaker", ALSA_CHANNEL_RIGHT], + ["Left Speaker", ALSA_CHANNEL_LEFT], + ["Mono Output", ALSA_CHANNEL_MONO], + ] + self.set_border_width(0) + + # profile selector dropdown box + upper_box = gtk.HBox() + self.profile_combo = gtk.combo_box_new_text() + for entry in ALSA_ENTRYS.keys(): + self.profile_combo.append_text(entry) + self.profile_combo.connect('changed', self.profile_changed_callback) + upper_box.add(self.profile_combo) + + self.mute_btn = gtk.Button("Mute") + self.mute_btn.connect("clicked", self.mute_audio) + upper_box.pack_start(self.mute_btn, False, False, 0) + + self.add_profile_btn = gtk.Button() + image = gtk.Image() + image.set_from_icon_name("gtk-save", gtk.ICON_SIZE_MENU) + self.add_profile_btn.add(image) + self.add_profile_btn.connect('clicked', self.save_profile) + upper_box.pack_start(self.add_profile_btn, False, False, 0) + + self.pack_start(upper_box, False, False, 0) + + # volume control + for channel in audio_channels: + init_volume = self.get_volume(channel[1]) + + frame = gtk.Frame(channel[0]) + self.pack_start(frame, False, True, 0) + + max_value = self.get_max_volume(channel[1]) + scale_adj = gtk.Adjustment(init_volume, 0.0, max_value, 1.0, 1.0, 0.0) + scale_adj.connect("value_changed", self.volume_changed_callback, channel[1]) + self.volume_scales.update({channel[1]: scale_adj}) + volume_scale = gtk.HScale(scale_adj) + volume_scale.set_digits(0) + frame.add(volume_scale) +# self.pack_start(volume_scale, False, False, 0) + + self.show_all() + + ### ToDo. + diff --git a/SettingsGUI/tags/0.8/src/settingsgui/BluetoothPanel.py b/SettingsGUI/tags/0.8/src/settingsgui/BluetoothPanel.py new file mode 100644 index 0000000..b8a3e9a --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/BluetoothPanel.py @@ -0,0 +1,445 @@ +""" + * BluetoothPanel.py - SettingsGUI - Bluetooth Settings + * + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import sys +import os +import time +import gtk +import gobject +import SysFSAccess +from GlobalConfiguration import * +from SysFSAccess import * +from ProcessInterface import * + + +class BluetoothScanner(threading.Thread): + def __init__(self, update_callback): + threading.Thread.__init__(self) + self.keep_running = True + self.scan_active = False + self.update_callback = update_callback + self.start() + + + def run(self): + while (self.keep_running): + if self.scan_active: + self.update_callback(self.update_list()) + time.sleep(BLUETOOTH_UPDATE_INTERVAL) # scan every x seconds + else: + time.sleep(2) # check again if we are active in a second + + + def set_active(self, active): + self.scan_active = active + + + def update_list(self): + ## exec hcitool scan + hcitool = ProcessInterface("%s scan hci0" % HCITOOL_CMD) + while not hcitool.process_finished(): + time.sleep(0.1) ## wait for command to compute + hcitool_output = hcitool.read_from_process() + + ## exec pand list + pand = ProcessInterface("pand -l") + while not pand.process_finished(): + time.sleep(0.1) ## wait for command to compute + pand_output = pand.read_from_process() + + ## filter output for visible peers + visible_peers = [] + for line in hcitool_output.split("\n"): + if line.find(":") >= 1: + visible_peers.append((line.strip().split("\t")[1],\ + line.strip().split("\t")[0])) + ## filter output for connected peers + connected_peers = [] + for line in pand_output.split("\n"): + if len(line.split(" ")) > 1: + connected_peers.append(line.split(" ")[1]) + + return (visible_peers, connected_peers) + + + + +class BluetoothPanel(gtk.VBox): + """ + Settings for the Bluetooth Module of GTA01 + """ + def __init__(self): + gtk.VBox.__init__(self, False, 0) + self.address = "" + + self.create_notebook_page() + + # asyncronous stuff + self.update_ui_condition = threading.Condition() + self.scan_for_bt_peers = True # to be handled in critical section! + self.async_updated = False # to be handled in critical section! + self.visible_peers_backup = [] + self.connected_peers_backup = [] + + # creating backgroundscanner - not active by default + self.bluetooth_scanner = BluetoothScanner(self.update_from_scanner) + + # start our update timer + gobject.timeout_add(500, self.update_ui) # every 1/2 second + + # settings powerstate as last operation to ensure existence of all + # widgets + if self.get_power_state(): + self.power_state_cbtn.set_active(True) + self.visible_state_cbtn.set_active(True) + self.update_btn.set_active(True) + self.list_store1.append(("Scanning for ", "Peers", False)) + self.pand_state_cbtn.set_active(self.get_pand_state()) + self.update_infos() + else: + self.power_state_cbtn.set_active(False) + self.visible_state_cbtn.set_active(False) + + + + def create_notebook_page(self): + self.set_border_width(0) + + ## Power State of Bluetooth Module + cell_frame = gtk.Frame("Bluetooth State") + upper_box = gtk.HBox() + upper_box.set_border_width(10) + + # power + self.power_state_cbtn = gtk.CheckButton("Powered") + self.power_state_cbtn.set_sensitive(1) + self.power_state_cbtn.connect('pressed', \ + lambda *w: self.power_state_cbtn.set_inconsistent(1)) + self.power_state_cbtn.connect('released', self.toggle_power) + upper_box.pack_start(self.power_state_cbtn, True, True, 0) + + # discoverability + self.visible_state_cbtn = gtk.CheckButton("Visible") + self.visible_state_cbtn.set_sensitive(1) + #self.visible_state_cbtn.connect('pressed', \ + # lambda *w: self.visible_state_cbtn.set_inconsistent(1)) + self.visible_state_cbtn.connect('released', \ + lambda *w: self.visible_state_cbtn.set_active(1)) + upper_box.pack_start(self.visible_state_cbtn, True, True, 0) + + # pand + self.pand_state_cbtn = gtk.CheckButton("Allow PAN") + self.pand_state_cbtn.set_sensitive(1) + self.pand_state_cbtn.connect('pressed', \ + lambda *w: self.pand_state_cbtn.set_inconsistent(1)) + self.pand_state_cbtn.connect('released', self.toggle_listen_pand) + upper_box.pack_start(self.pand_state_cbtn, True, True, 0) + + cell_frame.add(upper_box) + self.pack_start(cell_frame, False, False, 0) + + ## Info on BT state + info_frame = gtk.Frame("Bluetooth Informations") + info_box = gtk.VBox() + info_box.set_border_width(10) + + self.name_label = gtk.Label("Visible Name: %s" % self.get_name()) + self.address_label = gtk.Label("Address: %s" % self.get_address()) + self.ip_address_label = gtk.Label("IP: %s" % self.get_ip_address()) + info_box.add(self.name_label) + info_box.add(self.address_label) + info_box.add(self.ip_address_label) + info_frame.add(info_box) + self.pack_start(info_frame, False, True, 1) + + + scan_frame = gtk.Frame("Devices in range") + scan_frame_box = gtk.VBox() + scan_frame_box.set_border_width(10) + (scroll_win, self.tree_view1, self.list_store1) = \ + self.make_list_view(3, \ + ["Name", "Address", "Link"], \ + ["text", "text", "toggle"]) + scan_frame_box.pack_start(scroll_win, True, True, 0) + + scan_btn_box = gtk.HBox() + self.update_btn = gtk.ToggleButton("Scan for\nPeers") + self.update_btn.connect('toggled', self.scan_for_peers_toggled) + scan_btn_box.add(self.update_btn) + connect_btn = gtk.Button("Connect\n(PAN)") + connect_btn.connect('clicked', self.connect_to_peer) + scan_btn_box.add(connect_btn) + scan_frame_box.pack_start(scan_btn_box, False, True, 0) + scan_frame.add(scan_frame_box) + + self.pack_start(scan_frame, True, True, 0) + + ## finish notebook page creation + self.show_all() + +################################################################################ +######################### build GUI helper ##################################### +################################################################################ + ## we allow one toggle -for fixed (text, text, toggle) + def make_list_view(self, number, names, type = ["text", "text", "text"]): + scroll_win = gtk.ScrolledWindow() + scroll_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + + #try: + if type.index("toggle") >= 0: + list_store = gtk.ListStore(str, str, 'gboolean')#gobject.TYPE_BOOLEAN) + #except: + # list_store = gtk.ListStore(*(str,) * number) + + tree_view = gtk.TreeView(list_store) + cell = gtk.CellRendererText() + cell.set_property('editable', False) + cell_toggle = gtk.CellRendererToggle() + cell_toggle.set_property('activatable', True) + + tvcolumn = [] + for i in range(number): + if type[i] == "text": + tvcolumn.append(gtk.TreeViewColumn(names[i], cell, markup=i)) + if type[i] == "toggle": + toggle_column = gtk.TreeViewColumn(names[i], cell_toggle) + tvcolumn.append(toggle_column) + toggle_column.add_attribute(cell_toggle, attribute = "active", \ + column = 2) + tree_view.append_column(tvcolumn[i]) + tvcolumn[i].set_sort_column_id(i) + tvcolumn[i].set_resizable(True) + + scroll_win.add(tree_view) + return (scroll_win, tree_view, list_store) + +################################################################################ +######### update GUI from asynchronous changes (from threads) ################## +################################################################################ + def update_ui(self): + self.update_ui_condition.acquire() # <- critical section + if not self.async_updated: # to be handled in critical section! + self.update_ui_condition.release() # -> critical section + return True # Do nothing, keep going + else: + self.async_updated = False + + self.list_store1.clear() + # access the peer_list (which is written to by the scan thread) + for entry in self.peer_list: + self.list_store1.append(entry) + + if len(self.peer_list) <= 0: + self.list_store1.append(("Scanning for ", "Peers...", False)) + + self.update_ui_condition.release() # -> critical section + return True # keep going for ever + + ## gets calles from thread context - has no access to GUI! + def update_from_scanner(self, data): + (visible_peers, connected_peers) = data + + ## this does not need synchronisation yet - only one thread calling + ## find out if anything has changed since last update + if self.visible_peers_backup == visible_peers and \ + self.connected_peers_backup == connected_peers: + return ## nothing to be done + + self.visible_peers_backup = visible_peers + self.connected_peers_backup = connected_peers + + + self.update_ui_condition.acquire() # <- critical section + self.peer_list = [] # to be handled in critical section! + + for entry in visible_peers: + ## see if entry can be found in conneced list + found = False + for connected in connected_peers: + print "." + if entry[1] == connected: + found = True + ## add to list als (Name, Address, Found) + self.peer_list.append((entry[0], entry[1], found)) + + self.async_updated = True # to be handled in critical section! + self.update_ui_condition.release() # -> critical section + +################################################################################ +####################### Callbacks from GUI ##################################### +################################################################################ + def scan_for_peers_toggled(self, event): + ''' + activate/deactivate background scanner + ''' + self.bluetooth_scanner.set_active(self.update_btn.get_active()) + + + def toggle_power(self, event): + print "Toggleing Power state!" + if not self.get_power_state(): + set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 1) + self.list_store1.clear() + self.list_store1.append(("Scanning for ", "Peers...", False)) + self.update_btn.set_active(True) + else: + set_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER, 0) + + self.power_state_cbtn.set_active(self.get_power_state()) + + ## have to wait for async init :-( - TODO - make updates async. + time.sleep(2) + self.update_infos() + + ## for now we are alyways visible when power is on + self.visible_state_cbtn.set_active(self.get_power_state()) + + self.power_state_cbtn.set_inconsistent(0) + + def toggle_listen_pand(self, event): + if self.pand_state_cbtn.get_active(): + +# IP_address = "%s.%s" % (BLUETOOTH_IP_MASK, \ +# int(self.address.split(":")[-1], 16)) +# print "setting IP address to [%s]" % IP_address + + + + print "Starting pand [pand -s]" + os.system("pand -s") + else: + print "pand already listening for connections" + self.pand_state_cbtn.set_active(1) + self.pand_state_cbtn.set_inconsistent(0) + + + def get_power_state(self): + power_value = get_sysfs_value(SYSFS_ENTRY_BLUETOOTH_POWER) + + ## value will be empty if sysfs entry does not exist + if len(power_value) > 0: + state = power_value[0] + else: + state = "0" + + if state.isdigit(): + if int(state) > 0: + return True + return False + + + def get_pand_state(self): + if process_running("pand\0-s") or process_running("pand\0--listen"): + return True + else: + return False + + + def connect_to_peer(self, event): + + def call_cmd(string): + print("calling command [%s]" % string) + os.system(string) + + ## get selected entry + if len(self.address) <= 0: + return + (model, model_iter) = self.tree_view1.get_selection().get_selected() + if model_iter >= 1: + name = model.get_value(model_iter, 0) # column is first (name) + addr = model.get_value(model_iter, 1) # column is second (adr) + call_cmd("pand -c %s" % addr) + time.sleep(1) ## time needed to create bnap device + ## convert last number of addr to decimal and user as last ip number + call_cmd("ifconfig bnep0 %s%s" % (BLUETOOTH_IP_MASK, \ + int(self.address.split(":")[-1], 16))) + time.sleep(1) ## time needed to set ip + self.update_infos() + + +################################################################################ +#################### subprocess callbacks (outputs) ############################ +################################################################################ + + def add_scan_list_entry(self, string): + if string.find(":") >= 0: + print ("new") + try: + self.connected_peers.index(string.strip().split("\t")[0]) + found = True ## we've had no exception + except: + found = False + + self.list_store1.append((string.strip().split("\t")[1], \ + string.strip().split("\t")[0], found)) + + +################################################################################ +####################### Interface to bluez tools ############################### +################################################################################ + def update_infos(self): + self.name_label.set_text("Visible Name: %s" % self.get_name()) + self.address_label.set_text("Address: %s" % self.get_address()) + self.ip_address_label.set_text("IP: %s" % self.get_ip_address()) + + def get_name(self): + hciconfig = ProcessInterface("hciconfig hci0 name") + while not hciconfig.process_finished(): + time.sleep(0.1) ## wait for command to compute + output = hciconfig.read_from_process() + if output.find("Name:") >= 0: + return output.split("Name:")[1].split("'")[1] + return "down" + + + def get_address(self): + hciconfig = ProcessInterface("%s %s" % (HCICONFIG_CMD, BLUETOOTH_DEVICE)) + while not hciconfig.process_finished(): + time.sleep(0.1) ## wait for command to compute + output = hciconfig.read_from_process() + + # print "output of get_address: [%s]" % output + # hciconfig.close_process() ## has no effect anyway :-( TODO - fix + if output.find("BD Address: "): + if len(output.split("BD Address: ")) > 1 and \ + len(output.split("BD Address: ")[1].split(" ")) > 1: + self.address = output.split("BD Address: ")[1].split(" ")[0] + return output.split("BD Address: ")[1].split(" ")[0] + else: + return "offline" + return "unknown" + + + def get_ip_address(self): + if len(self.address) <= 0: + return "none" + else: ## todo mind more than one device + ifconfig = ProcessInterface("ifconfig bnep0") + while not ifconfig.process_finished(): + time.sleep(0.1) ## wait for command to compute + output = ifconfig.read_from_process() + # print "output of get_ip_address: [%s]" % output + if len(output.split("inet addr:")) > 1: + return output.split("inet addr:")[1].split(" ")[0].strip() + + def get_features(self): + """using the hciconfig tool to get the list of supported features""" + diff --git a/SettingsGUI/tags/0.8/src/settingsgui/GPRSPanel.py b/SettingsGUI/tags/0.8/src/settingsgui/GPRSPanel.py new file mode 100644 index 0000000..f632289 --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/GPRSPanel.py @@ -0,0 +1,471 @@ +""" + * GPRSPanel.py - SettingsGUI - GPRS Settings + * + * GPRS Connection Settings - using pppd until the LDISC interface is + * finished + * + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import sys +import os +import shutil # to create a backup of pppd config files +import threading +import time +import gtk +import gobject + +from ProcessInterface import * +from SysFSAccess import * +from GSMPanel import * +from GlobalConfiguration import * +from pppdConfigParser import * + +#from settingsgui.ProcessInterface import * +#from settingsgui.SysFSAccess import * +#from settingsgui.GSMPanel import * +#from settingsgui.GlobalConfiguration import * +#from settingsgui.pppdConfigParser import * + +## ToDo +## from GSMPanel import GSMPanel ## to reach the operator name +## (name peer like operator) + + +################################################################################ +# lots of methods - will devide them into block with big comments between them # +################################################################################ +class GPRSPanel(gtk.VBox): + def __init__(self, GSM_Panel): + self.GSM_Panel = GSM_Panel + gtk.VBox.__init__(self, False, 0) + self.peer_entries = {} + self.entry_dict = {} + self.local_ip = "" + self.remote_ip = "" + self.nameserver_ip = "" + + self.peer_entries.update(self.find_peers()) + self.create_notebook_page() + self.peer_changed_callback(self.peer_combo) + self.set_state("disconnected") + +################################################################################ +############ search system for ppp peers (pppd config files) ################### +################################################################################ + def find_peers(self): + new_dict = {} + + if not os.path.exists(os.path.expanduser(PPP_PATH_TO_USER_PEERS)): + os.makedirs(os.path.expanduser(PPP_PATH_TO_USER_PEERS)) + print "created %s" % os.path.expanduser(PPP_PATH_TO_USER_PEERS) + else: + try: + for key in os.listdir( + os.path.expanduser(PPP_PATH_TO_USER_PEERS)): + + if (key[-1] != '~') \ + and (key.find("-chat") < 0) \ + and (key.find("latest_") < 0): + path_to_file = os.path.join( + os.path.expanduser(PPP_PATH_TO_USER_PEERS), key) + new_dict[key] = pppdConfigParser(path_to_file) +# print "Added and parsed <%s> (global)" % path_to_file + except: ## maybe we have no permissions for os.listdir + None # nothing we can do about it - + # ToDo: maybe throw a message box + + ## read in system wide peers + if os.path.exists(PPP_PATH_TO_GLOBAL_PEERS): + try: + for key in os.listdir(PPP_PATH_TO_GLOBAL_PEERS): + if ((key[-1] != '~') \ + and (key.find("-chat") < 0) \ + and (key.find("latest_") < 0) \ + and (key.find(PPP_PATH_TO_USER_PEERS) < 0)): + + path_to_file = os.path.join( + PPP_PATH_TO_GLOBAL_PEERS, key) + + new_dict[key] = pppdConfigParser(path_to_file) + except: ## maybe we have no permissions for os.listdir + print "could no access %s" % PPP_PATH_TO_GLOBAL_PEERS + + print "found %d peers" % len(new_dict) + + + ## no peer found, creating default peer + if len(new_dict) <= 0: + ## ToDo use users directory + print "Will create a default peer in /etc/ppp/peers" + if not os.path.exists(PPP_PATH_TO_GLOBAL_PEERS): + try: + os.makedirs(PPP_PATH_TO_GLOBAL_PEERS) + except: + print "Could not make %s dir" % PPP_PATH_TO_GLOBAL_PEERS + try: + filename = os.path.join(PPP_PATH_TO_GLOBAL_PEERS, + PPP_DEFAULT_CONFIG_NAME) + peer_fd = open(filename, 'w') + print "Creating default peer in %s " % filename + for line in PPP_DEFAULT_CONFIG.split('\n'): + peer_fd.write("%s\n" %line) + peer_fd.close() + + ## connect chat script + filename = os.path.join(PPP_PATH_TO_GLOBAL_PEERS, + "%s-connect-chat" % PPP_DEFAULT_CONFIG_NAME) + print "Creating default chat file in %s " % filename + peer_fd = open(filename, 'w') + for line in PPP_DEFAULT_CONNECT_SCRIPT.split('\n'): + peer_fd.write("%s\n" %line) + peer_fd.close() + + ## disconnect chat script + filename = os.path.join(PPP_PATH_TO_GLOBAL_PEERS, + "%s-disconnect-chat" % PPP_DEFAULT_CONFIG_NAME) + print "Creating default chat file in %s " % filename + peer_fd = open(filename, 'w') + for line in PPP_DEFAULT_DISCONNECT_SCRIPT.split('\n'): + peer_fd.write("%s\n" %line) + peer_fd.close() + + filename = os.path.join(PPP_PATH_TO_GLOBAL_PEERS, + PPP_DEFAULT_CONFIG_NAME) + new_dict[PPP_DEFAULT_CONFIG_NAME] = pppdConfigParser(filename) + except: + print "Could not create peer <%s>" % os.path.join( + PPP_PATH_TO_GLOBAL_PEERS, PPP_DEFAULT_CONFIG_NAME) + return new_dict + +################################################################################ +############# interfacing the pppd subprocess, regestering callbacks ########### +################################################################################ + + ## starting subprocess + ## ToDo: use -b and parse a logfile + ## to keep it running when SettingsGUI is quit + ## => find out if pppd is running on start up + def start_pppd(self, config_file): + parameters = "debug call %s" % config_file + pppd = ProcessInterface( + "start-stop-daemon --start -x %s -- %s" % (PPP_INIT, parameters)) + pppd.register_event_handler("ERROR", self.connection_error) + pppd.register_event_handler("", self.update_output) + pppd.register_event_handler("local IP address", self.update_local_ip) + pppd.register_event_handler("remote IP address", self.update_remote_ip) + + ## ToDo see start_pppd + def stop_pppd(self): + pppd = ProcessInterface("start-stop-daemon --stop -x %s" % (PPP_INIT)) + pppd.register_event_handler("", self.update_output) + self.set_state("disconnected") + + + +################################################################################ +############## Callbacks from pppd subprocess output - as callbacks ############ +################################################################################ + ## called from pppd parser subprocess + def update_local_ip(self, string): + if len(string.split()) >= 3: + self.local_ip = string.split()[3] + else: + self.local_ip = "" + self.IP_text_buffer.set_text("Local IP: %s\nRemote IP: %s\nNameserver: %s" %( + self.local_ip, self.remote_ip, self.nameserver_ip)) + + + ## called from pppd parser subprocess + def update_remote_ip(self, string): + if len(string.split()) >= 3: + self.remote_ip = string.split()[3] + self.set_state("connected") + else: + self.remote_ip = "" + self.IP_text_buffer.set_text("Local IP: %s\nRemote IP: %s\nNameserver: %s" %( + self.local_ip, self.remote_ip, self.nameserver_ip)) + + + ## called from pppd parser subprocess + def connection_error(self, dummy): + self.set_state("disconnected") + + + ## called indirectly from pppd parser subprocess (from set state) + def update_nameserver(self): + self.nameserver_ip = "" + if self.state_string == "connected" and os.path.exists("/etc/resolv.conf"): + fd = open("/etc/resolv.conf", 'r') + for line in fd.readlines(): + if line.find("nameserver") >= 0: + self.nameserver_ip = line.split()[1] + break + fd.close() + + if not os.path.exists("/etc"): + try: + os.makedirs("/etc") + except: + print "could not make /etc directory" + + if len(self.nameserver_ip) <= 0: + try: + fd = open("/etc/resolv.conf", 'w') + fd.write("nameserver %s\n" % DEFAULT_NAMESERVER) + except: + print "could not edit /etc/resolv.conf to add a default Nameserver" + + self.IP_text_buffer.set_text("Local IP: %s\nRemote IP: %s\nNameserver: %s" %( + self.local_ip, self.remote_ip, self.nameserver_ip)) + + + ## called on init and from pppd parser subprocess + def set_state(self, state_string): + self.state_string = state_string + + if state_string == "connected": + self.disconnect_btn.set_sensitive(1) + self.connect_btn.set_sensitive(0) + self.update_nameserver() + + if state_string == "disconnected": + self.connect_btn.set_sensitive(1) + self.disconnect_btn.set_sensitive(0) + self.update_local_ip("") + self.update_remote_ip("") + self.update_nameserver() + + def update_output(self, string): + ## remove tailing and starting \n and \r - just in case + string = string.rstrip('\n').lstrip('\n').rstrip('\r').lstrip('\r') + print "pppd: <%s>" % string + self.update_state(string) + + + +################################################################################ +############################## Callbacks from UI ############################### +################################################################################ + + ## called when drop down box selection changed + def peer_changed_callback(self, widget): + print "peers changed, filling in entries..." + entry = widget.get_active_text() + if not self.peer_entries.has_key(entry): + self.update_state("Could not open a peer file") + return False + + self.current_peer_entry = self.peer_entries[entry] + if self.peer_entries.has_key(entry): + self.entry_dict["APN"].set_text(self.current_peer_entry.get_APN()) + self.entry_dict["User"].set_text(self.current_peer_entry.get_user()) + self.entry_dict["Password"].set_text(self.current_peer_entry.get_password()) + self.entry_dict["Number"].set_text(self.current_peer_entry.get_number()) + self.current_peer_entry.config_name = entry + return True + ## user edited the settings + def settings_changed(self, widget): + self.entry_dict[widget.get_name()].set_text(widget.get_text()) + self.add_peer_btn.set_sensitive(1) + + ## ToDo + def save_peer(self, widget): + file_path = os.path.join(os.path.expanduser(PPP_PATH_TO_USER_PEERS), \ + self.current_peer_entry.config_name) + if not os.path.exists("%s-backup" % file_path): + print "will backup peer %s - %s" % (file_path, self.current_peer_entry.config_name) + try: + shutil.copyfile(file_path, "%s-backup" % file_path) + + if os.path.exists("%s-connect-chat" % file_path) and \ + not os.path.exists("%s-connect-chat-backup" % file_path): + shutil.copyfile("%s-connect-chat" % file_path, \ + "%s-connect-chat-backup" % file_path) + + if os.path.exists("%s-disconnect-chat" % file_path) and \ + not os.path.exists("%s-disconnect-chat-backup" % file_path): + shutil.copyfile("%s-disconnect-chat" % file_path, \ + "%s-disconnect-chat-backup" % file_path) + except: + self.update_state("Backup of old entry failed - aborting!") + return False + + + if self.current_peer_entry.generate_configuration( + os.path.expanduser(PPP_PATH_TO_USER_PEERS), \ + self.current_peer_entry.config_name, \ + self.entry_dict["APN"].get_text(), \ + self.entry_dict["User"].get_text(), \ + self.entry_dict["Password"].get_text(), \ + self.entry_dict["Number"].get_text()): + self.update_state("%s saved to %s" % (\ + self.current_peer_entry.config_name, \ + os.path.expanduser(PPP_PATH_TO_USER_PEERS))) + + return True + + def connect_clicked(self, widget): + if self.GSM_Panel.stop_gsmd_btn.get_property("sensitive"): + mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, + gtk.BUTTONS_YES_NO, "Do you want to terminate gsmd first?") + response = mbox.run() + mbox.hide() + mbox.destroy() + if response == gtk.RESPONSE_YES: + print "will terminate gsmd" + self.GSM_Panel.stop_gsmd(None) + + if self.current_peer_entry.generate_configuration( + os.path.expanduser(PPP_PATH_TO_USER_PEERS), PPP_GENCONFIG_NAME, \ + self.entry_dict["APN"].get_text(), \ + self.entry_dict["User"].get_text(), \ + self.entry_dict["Password"].get_text(), \ + self.entry_dict["Number"].get_text()): + self.start_pppd(PPP_GENCONFIG_NAME) + + def disconnect_clicked(self, widget): + self.stop_pppd() + + + + +################################################################################ +############################## UI Helper fkts ################################## +################################################################################ + + ## change output on "state bar" + def update_state(self, string): + self.state_entry.set_text(string) + + + ## creating a label + entry box + def add_entry_with_name(self, name, default_text, password_mode, callback): + entry_box = gtk.HBox() + + label = gtk.Label(name) + label.set_width_chars(8) + entry_box.set_spacing(15) + entry_box.pack_start(label, False, False, 0) + + entry = gtk.Entry() + entry.set_text(default_text) + entry.set_visibility(password_mode) + entry.connect("changed", callback) + entry.set_name(name) + entry_box.add(entry) + + self.entry_dict[name] = entry ## to access the text entry + + entry_box.show() + return entry_box + +################################################################################ +################################# create UI #################################### +################################################################################ + def create_notebook_page(self): +# start_time = time.time() + self.set_border_width(0) + + peer_box = gtk.HBox() +# self.peer_combo = gtk.combo_box_new_text() + self.peer_combo = gtk.combo_box_entry_new_text() + if len(self.peer_entries) <= 0: + self.peer_combo.append_text("ERROR /etc/ppp/ access?") ## <- there was no peer and access to /etc/ppp was not possible + for entry in self.peer_entries: + self.peer_combo.append_text(entry) + + self.peer_combo.set_focus_on_click(False) +# self.peer_combo.set_property("allow_empty", 0) + self.peer_combo.set_active(0) + +# self.peer_combo.set_sensitive(0) + self.peer_combo.connect('changed', self.peer_changed_callback) + + self.add_peer_btn = gtk.Button() + image = gtk.Image() + image.set_from_icon_name("gtk-save", gtk.ICON_SIZE_MENU) + self.add_peer_btn.add(image) + self.add_peer_btn.connect('clicked', self.save_peer) + peer_box.pack_start(self.add_peer_btn, False, False, 0) + peer_box.add (self.peer_combo) + if len(self.peer_entries) <= 0: + self.add_peer_btn.set_sensitive(1) + else: + self.add_peer_btn.set_sensitive(0) + + self.pack_start(peer_box, False, False, 0) + + + # GPRS Settings + gprs_frame = gtk.Frame("GPRS Login Settings") + gprs_box = gtk.VBox() + gprs_box.set_border_width(10) + + gprs_box.add(self.add_entry_with_name("APN", "internet.eplus.de", True, self.settings_changed)) + gprs_box.add(self.add_entry_with_name("User", "gprs", True, self.settings_changed)) + gprs_box.add(self.add_entry_with_name("Password", "gprs", False, self.settings_changed)) + gprs_box.add(self.add_entry_with_name("Number", "*99***1#", True, self.settings_changed)) + gprs_frame.add(gprs_box) + self.pack_start(gprs_frame, False, False, 0) + + # buttons + btn_box = gtk.HBox() + + self.connect_btn = gtk.Button("Connect\nto GPRS") + self.connect_btn.connect("clicked", self.connect_clicked) + btn_box.add(self.connect_btn) + ## to prevent keyboard from beeing activated on startup + self.set_focus_child(self.connect_btn) + + self.disconnect_btn = gtk.Button("Disconnect\nfrom GPRS") + self.disconnect_btn.connect("clicked", self.disconnect_clicked) + self.disconnect_btn.set_sensitive(0) + btn_box.add(self.disconnect_btn) + + self.pack_start(btn_box, False, False, 0) + + state_frame = gtk.Frame("GPRS State") + + # IP infos + state_box = gtk.VBox() + + self.IP_box = gtk.VBox() + self.IP_box.set_border_width(10) + self.IP_text_view = gtk.TextView() + self.IP_text_buffer = self.IP_text_view.get_buffer() + self.IP_text_buffer.set_text("Local IP: %s\nRemote IP: %s\nNameserver: %s" %( + self.local_ip, self.remote_ip, self.nameserver_ip)) + self.IP_text_view.set_editable(0) + self.IP_box.add(self.IP_text_view) + state_box.add(self.IP_box) + + self.state_entry = gtk.Entry() + self.state_entry.set_text("") + self.state_entry.set_sensitive(0) + state_box.add(self.state_entry) + state_frame.add(state_box) + self.pack_start(state_frame, False, False, 0) + + ## override the focus chain as OM will fire the keyboard + ## if a textentry is active + focusable_widgets = [self.connect_btn, + gprs_box] + [self.entry_dict[x] for x in self.entry_dict] + [self.peer_combo] + + self.show_all() +# print "time needed to init GPRS Panel = %s" % (time.time() - start_time) diff --git a/SettingsGUI/tags/0.8/src/settingsgui/GSMPanel.py b/SettingsGUI/tags/0.8/src/settingsgui/GSMPanel.py new file mode 100644 index 0000000..d6a6ada --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/GSMPanel.py @@ -0,0 +1,442 @@ +""" + * GSMPanel.py - SettingsGUI - GSM Settings + * + * Using libgsm_tool until there is a python bindung available + * + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import sys +import os +import threading +import time +import gtk +# import gobject + +from ProcessInterface import * +from SysFSAccess import * +from GlobalConfiguration import * +#from settingsgui.ProcessInterface import * +#from settingsgui.SysFSAccess import * +#from settingsgui.GlobalConfiguration import * + + +MAX_SIGNAL = 30.0 +LIBGSM_TOOL = "/usr/bin/libgsmd-tool" +PATH_TO_LIBGSM_TOOL = "/usr/bin/" +GSMD_INIT = "/etc/init.d/gsmd" +SYSFS_ENTRY_GSM_POWER = "/sys/bus/platform/devices/gta01-pm-gsm.0/power_on" + +class GSMPanel(gtk.VBox): + def __init__(self): + gtk.VBox.__init__(self, False, 0) + self.create_notebook_page() + gtk.gdk.threads_init() + self.gsm_state = 0 + self.start_gsm_tool() + + + def __del__(self): + try: + self.gsm_tool_at.write_to_process("\d") ## EOF! + except: + print "GSMPanel: Warning: gsmtool seems to be closed already" + time.sleep(0.3) + + + def start_gsm_tool(self): + if os.path.exists(LIBGSM_TOOL): + self.gsm_tool_at = ProcessInterface( + "%s -m atcmd" % LIBGSM_TOOL) + time.sleep(0.2) + error_out = self.gsm_tool_at.read_error_from_process() + if len(error_out) > 0: + error_out = error_out.rstrip('\n').lstrip('\n').rstrip( + '\r').lstrip('\r') + self.update_state("error libgsm-tool: %s" % error_out) + print "error libgsm-tool: %s" % error_out + self.state_changed("Off") + return False + + self.gsm_tool_at.register_event_handler("RSTR=",\ + self.at_state_changed) + time.sleep(0.3) + + ## request regestration state + self.gsm_tool_at.write_to_process("AT+CREG?") + + self.gsm_tool_at.register_event_handler("EVENT: Signal Quality",\ + self.link_quality_changed) + self.gsm_tool_at.register_event_handler("EVENT: Netreg registered",\ + self.network_registration_changed) + self.gsm_tool_at.register_event_handler("EVENT: Signal Quality",\ + self.link_quality_changed) + self.gsm_tool_at.register_event_handler("# Power-On",\ + self.state_changed) + self.gsm_tool_at.register_event_handler("# Register",\ + self.state_changed) + self.gsm_tool_at.register_event_handler("", self.update_output) + self.gsm_tool_at.register_event_handler("Our current operator is",\ + self.operator_changed) + self.gsm_tool_at.register_event_handler("ERROR reading from gsm_fd",\ + self.gsm_fs_changed) + self.state_changed("Init") + + return True + else: + self.update_state("%s not found, most functions in the GSM panel disabled" % LIBGSM_TOOL) + self.gsm_tool_at = False + return False + + + +################################################################################ +######### Callbacks from libgsmd-tool subprocess output - as callbacks ######### +################################################################################ + + def update_gsmd_state(self): + None + + def update_output(self, string): + ## remove tailing and starting \n and \r - just in case + string = string.rstrip('\n').lstrip('\n').rstrip('\r').lstrip('\r') + print "libgsmd-tool: <%s>" % string + self.update_state(string) + self.update_gsmd_state() + + def gsm_fs_changed(self, string): + self.state_changed("Off") + + ## called from gsmd at answer + def at_state_changed(self, string): + if string.find("RSTR=") < 0 or string.find(":") < 0\ + or string.find("`") < 0: + if string.find("OK") >= 0: + if self.gsm_state == 1: + self.state_changed("Power-On") + time.sleep(1) + self.gsm_tool_at.write_to_process("AT+COPS?") ## request oper. name + time.sleep(1) + self.gsm_tool_at.write_to_process("AT+CSQ") ## request sign. qual. + else: + return False + return True + + response = string.split("`")[1].rstrip("'") + cmd = response.split(":")[0] + resp = response.split(":")[1].split(",") + resp = [x.rstrip("\n").rstrip("'").rstrip("\"").lstrip("\"") for x in resp] + + print "got a response from modem: CMD: %s Response: %s" %(cmd, resp) + + ## set location area code and cellid + if string.find("+CREG") >= 0: + if len(resp) == 3: + location_area = resp[1] + cell_id = resp[2] + if len(resp) >= 4: + location_area = resp[2] + cell_id = resp[3] + if len(resp) >= 3: + self.reg_state_cbtn.set_active(1) + self.connected_state_cbtn.set_active(1) + self.state_changed("Connected") + else: + location_area = "" + cell_id = "" + self.state_changed("Init") + + print "Got a location: %s/%s" % (location_area, cell_id) + self.area_code_lbl.set_text("Location Area Code: %s" % location_area) + self.cell_id_lbl.set_text("Cell ID: %s" % cell_id) + if len(resp) >= 2: # it should always be + if resp[0] == 0: + self.reg_state_cbtn.set_active(0) + self.connected_state_cbtn.set_active(0) + if resp[1] == 0 or resp[1] == 2 or resp[1] == 3: + self.connected_state_cbtn.set_active(0) + if resp[1] == 5 or resp[1] == 1: + self.reg_state_cbtn.set_active(1) + self.connected_state_cbtn.set_active(1) + + + if string.find("+COPS") >= 0: + if len(resp) >= 3: + self.operator_lbl.set_text("Operator: %s" % resp[2]) + """ + else: + if len(resp) == 1: + time.sleep(3) + ## request oper. name + self.gsm_tool_at.write_to_process("AT+COPS?") + time.sleep(1) + ## request sign. qual. + self.gsm_tool_at.write_to_process("AT+CSQ") + """ + + + if string.find("+CSQ") >= 0: + if len(resp) >= 2: + self.link_quality_changed("%s %s %s %s" % \ + (resp[0], resp[0], resp[0], resp[0], )) + + + ## set opername - ToDo + + ## called from gsmd event + def link_quality_changed(self, line): + ## ToDo - strange - maybe filter the '#'??? + try: + quality = int(line.split(" ")[4]) + except: + quality = int(line.split(" ")[3]) + if quality != 99: + self.scale_adj.value = int((quality / MAX_SIGNAL) * 100) + self.sig_stength_scale.set_text("%3.4s %%" % ((quality / MAX_SIGNAL) * 100)) + + ## called from gsmd event + ## ToDo - remove strange string-list-join-thing + def operator_changed(self, line): + line_list = line.split(" ") + operator = " ".join([line_list[x+4] for x in range(len(line_list)-4)]) + self.operator_lbl.set_text("Operator: %s" % operator.rstrip('\n')) + + ## called from gsmd event + ## requesting name of operator + def network_registration_changed(self, line): + if len(line.split()) >= 11: + location_area = line.split()[7] + cell_id = line.split()[10] + else: + location_area = "" + cell_id = "" + + self.area_code_lbl.set_text("Location Area Code: %s"%location_area) + self.cell_id_lbl.set_text("Cell ID: %s" % cell_id) + if cell_id != "?": + print "setting connected - cell_id=%s" % cell_id + self.state_changed("Connected") + self.operator_lbl.set_text("Operator: ") + + + ## called from gsmd event + def state_changed(self, line): + self.gsm_state = 0 + if line.find("Init") >= 0: + self.gsm_state = 1 + if line.find("Power-On") >= 0: + self.gsm_state = 2 + if line.find("Register") >= 0: + self.gsm_state = 3 + if line.find("Connected") >= 0: + self.gsm_tool_at.write_to_process("AT+COPS?") ## request oper. name + time.sleep(1) + self.gsm_tool_at.write_to_process("AT+CSQ") ## request sign. qual. + self.gsm_state = 4 + + ## may flicker + self.lib_state_cbtn.set_active(0) + + self.power_state_cbtn.set_active(0) + self.power_state_cbtn.set_sensitive(0) + self.power_state_cbtn.set_inconsistent(0) + + self.reg_state_cbtn.set_active(0) + self.reg_state_cbtn.set_sensitive(0) + self.reg_state_cbtn.set_inconsistent(0) + + self.connected_state_cbtn.set_active(0) + + self.sig_stength_scale.set_text("Invalid") + + ## nothing + if self.gsm_state == 0: + self.start_gsmd_btn.set_sensitive(1) + self.start_gsmd_btn.set_sensitive(1) + self.stop_gsmd_btn.set_sensitive(0) + + ## init lib + if self.gsm_state > 0: + self.lib_state_cbtn.set_active(1) + self.power_state_cbtn.set_sensitive(1) + self.start_gsmd_btn.set_sensitive(0) + self.stop_gsmd_btn.set_sensitive(1) + + ## power + if self.gsm_state > 1: + self.power_state_cbtn.set_active(1) + self.reg_state_cbtn.set_sensitive(1) + + ## register + if self.gsm_state > 2: + self.reg_state_cbtn.set_active(1) + + ## connected + if self.gsm_state > 3: + self.connected_state_cbtn.set_active(1) + + + +################################################################################ +############################## Callbacks from UI ############################### +################################################################################ + + def power_cb_changed(self, widget): + widget.set_inconsistent(1) + if widget.get_active(): + ## power on modem + print "sending power-on request to modem" + self.gsm_tool_at.write_to_process("AT+CFUN=1") + + def register_cb_changed(self, widget): + widget.set_inconsistent(1) + if widget.get_active(): + print "sending register request to modem" + self.gsm_tool_at.write_to_process("AT+COPS=0") + + def stop_gsmd(self, widget): + os.popen("start-stop-daemon --stop -x /usr/sbin/gsmd") + time.sleep(2) ## libgsmd-tool will flush some outdated data + self.start_gsmd_btn.set_sensitive(1) + self.stop_gsmd_btn.set_sensitive(0) + self.state_changed("Off") + + + def start_gsmd(self, widget): + # restart not working yet - using stop and start + if process_running("pppd"): + mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_YES_NO, + "There seems to be a GPRS connection runnung.\nDo you want to close it?") + response = mbox.run() + mbox.hide() + mbox.destroy() + if response == gtk.RESPONSE_YES: + print "will terminate pppd" + os.system("start-stop-daemon --stop -x %s" % (PPP_INIT)) + + os.system("%s stop" %(GSMD_INIT)) + print "executing: %s start" %(GSMD_INIT) + os.system("%s start" %(GSMD_INIT)) + time.sleep(0.5) + self.link_quality_changed("0 0 0 0 0") + self.network_registration_changed("? ? ? ? ? ? ? ? ? ? ?") + self.start_gsmd_btn.set_sensitive(0) + self.stop_gsmd_btn.set_sensitive(1) + time.sleep(1) ## give the gsmd some time to init... :-/ + self.reinit_libgsmd_tool(None) + + def reinit_libgsmd_tool(self, widget): + if not self.start_gsm_tool(): + print "error starting gsm-tool - abort reinit" + return + self.link_quality_changed("0 0 0 0 0") + self.network_registration_changed("? ? ? ? ? ? ? ? ? ? ?") + self.state_changed("Init") + self.operator_changed("? ? ? ? ?") + + def get_cur_sig_strength(self): + # ToDo - parse everything! + return 0 #ToDo + + + ## change output on "state bar" + def update_state(self, string): + self.state_entry.set_text(string) + + + def create_notebook_page(self): + self.set_border_width(0) + + top_btn_box = gtk.HBox(False, 0) + self.start_gsmd_btn = gtk.Button("Start\ngsmd") + self.start_gsmd_btn.connect("clicked", self.start_gsmd) + top_btn_box.add(self.start_gsmd_btn) + + self.stop_gsmd_btn = gtk.Button("Stop\ngsmd") + self.stop_gsmd_btn.connect("clicked", self.stop_gsmd) + top_btn_box.add(self.stop_gsmd_btn) + + self.pack_start(top_btn_box, False, False, 0) + + # signal Quality + frame = gtk.Frame("Signal Stength") + box = gtk.VBox() + box.set_border_width(15) + + self.scale_adj = gtk.Adjustment(self.get_cur_sig_strength(), 0.0, + 100, 1.0, 1.0, 0.0) + self.sig_stength_scale = gtk.ProgressBar(self.scale_adj) + self.sig_stength_scale.set_text("0.0 %") + box.add(self.sig_stength_scale) + frame.add(box) + self.pack_start(frame, False, False, 1) + + # cell info + cell_frame = gtk.Frame("Cell Information") + cell_box = gtk.VBox() + cell_box.set_border_width(15) + + self.area_code_lbl = gtk.Label("Location Area Code: ?") + cell_box.add(self.area_code_lbl) + + self.cell_id_lbl = gtk.Label("Cell ID: ?") + cell_box.add(self.cell_id_lbl) + + self.operator_lbl = gtk.Label("Operator: ?") + cell_box.add(self.operator_lbl) + + cell_frame.add(cell_box) + self.pack_start(cell_frame, False, False, 0) + + # state + state_frame = gtk.Frame("GSM State") + state_box = gtk.HBox() + state_box1 = gtk.VBox() + state_box2 = gtk.VBox() + state_box.set_border_width(15) + + self.lib_state_cbtn = gtk.CheckButton("Init") + self.lib_state_cbtn.set_sensitive(1) + self.lib_state_cbtn.connect("released", self.reinit_libgsmd_tool) + state_box1.add(self.lib_state_cbtn) + self.power_state_cbtn = gtk.CheckButton("Power") + self.power_state_cbtn.set_sensitive(1) + self.power_state_cbtn.connect("released", self.power_cb_changed) + state_box1.add(self.power_state_cbtn) + self.reg_state_cbtn = gtk.CheckButton("Register") + self.reg_state_cbtn.set_sensitive(1) + self.reg_state_cbtn.connect("released", self.register_cb_changed) + state_box2.add(self.reg_state_cbtn) + self.connected_state_cbtn = gtk.CheckButton("Connected") + self.connected_state_cbtn.set_sensitive(0) + state_box2.add(self.connected_state_cbtn) + + state_box.add(state_box1) + state_box.add(state_box2) + state_frame.add(state_box) + self.pack_start(state_frame, False, False, 0) + + + state_bar_box = gtk.VBox() + self.state_entry = gtk.Entry() + self.state_entry.set_text("") + self.state_entry.set_sensitive(0) + state_bar_box.add(self.state_entry) + self.pack_start(state_bar_box, False, False, 0) + + self.show_all() diff --git a/SettingsGUI/tags/0.8/src/settingsgui/GlobalConfiguration.py b/SettingsGUI/tags/0.8/src/settingsgui/GlobalConfiguration.py new file mode 100644 index 0000000..a0c0328 --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/GlobalConfiguration.py @@ -0,0 +1,144 @@ +""" + * GlobalConfiguration.py - SettingsGUI - + * Settings and default config files + * + * (C) 2007, 2008 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + + +################################################################################ +#################################### GUI ####################################### +################################################################################ +NOTEBK_PADDING = 6 +GSM_Panel_Instance = None + +################################################################################ +############################# used in Screen Panel ############################# +################################################################################ +SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS = "/sys/class/backlight/gta01-bl/brightness" +SYSFS_ENTRY_BACKLIGHT_POWER = "/sys/class/backlight/gta01-bl/power" # reverse + + +################################################################################ +############################ used in Bluetooth Panel ########################### +################################################################################ +SYSFS_ENTRY_BLUETOOTH_POWER = "/sys/bus/platform/devices/gta01-pm-bt.0/power_on" +HCICONFIG_CMD = "hciconfig" ## using $PATH +#HCICONFIG_CMD = "/sbin/hciconfig" ## openembedded +#HCICONFIG_CMD = "/usr/sbin/hciconfig" ## ubuntu +HCITOOL_CMD = "hcitool" ## using $PATH +BLUETOOTH_DEVICE = "hci0" +BLUETOOTH_UPDATE_INTERVAL = 10 ## scan for Bluetooth Peers every 3 secs +BLUETOOTH_IP_MASK = "10.0.0." ## last number will be added from BT-MAC + + +################################################################################ +############################# used in Audio Panel ############################## +################################################################################ +ALSA_STATES_DIR = "/etc/" + +ALSA_ENTRYS = { + "GSM Handset" : "gsmhandset.state", + "GSM Headset" : "gsmheadset.state", + "Capture Handset" : "capturehandset.state", + "Capture Headset" : "captureheadset.state", + "GSM Bluetooth" : "gsmbluetooth.state", + "Stereoout" : "stereoout.state" +} + +ALSA_AMIXER = "/usr/bin/amixer" +## amixer cset numid=87 30 + +ALSA_CHANNEL_LEFT = 86 +ALSA_CHANNEL_RIGHT = 87 +ALSA_CHANNEL_MONO = 88 + + +################################################################################ +######################### PPP Settings and config files ######################## +################################################################################ + +DEFAULT_NAMESERVER = "208.67.222.222" # from the OpenDNS project (2007-09-05) + +PPP_PATH_TO_PPP = "/etc/ppp/" +PPP_PATH_TO_GLOBAL_PEERS = "/etc/ppp/peers/" +## ToDo move to ~/.settings-gui/ppp/ +## => ToDo find out how to tell pppd... +PPP_PATH_TO_USER_PEERS = "/etc/ppp/peers/" +PPP_GENCONFIG_NAME = "latest_gprs" +PPP_DEFAULT_CONFIG_NAME = "gprs" +PPP_INIT = "/usr/sbin/pppd" + +PPP_SECRETS_FILES = ["/etc/ppp/pap-secrets", "/etc/ppp/chap-secrets"] + +## from http://wiki.openmoko.org/wiki/Manually_using_GPRS +## thanks Pavel! +PPP_DEFAULT_CONNECT_SCRIPT = """exec chat + TIMEOUT 22 + ECHO ON + ABORT '\\nBUSY\\r' + ABORT '\\nERROR\\r' + ABORT '\\nNO ANSWER\\r' + ABORT '\\nNO CARRIER\\r' + ABORT '\\nNO DIALTONE\\r' + ABORT '\\nRINGING\\r\\n\\r\\nRINGING\\r' + SAY "\\nDefining Packet Data Protocol context...\\n" + "" "\\d" + "" "atz" + OK "ate1" + OK 'at+cgdcont=1,"ip","internet.eplus.de","0.0.0.0",0,0' + TIMEOUT 22 + OK ATD*99# + TIMEOUT 33 + SAY "\\nWaiting for connect...\\n" + CONNECT "" + SAY "\\nConnected." """ + + +PPP_DEFAULT_DISCONNECT_SCRIPT = """exec /usr/sbin/chat -V -s -S + ABORT "BUSY" + ABORT "ERROR" + ABORT "NO DIALTONE" + SAY "\nSending break to the modem\n" + "" "\K" + "" "\K" + "" "\K" + "" "+++ATH" + "" "+++ATH" + "" "+++ATH" + "NO CARRIER" "" + SAY "\nPDP context detached\n" """ + +## deafult ppp peer - will be written to /etc/ppp/peers +## if no other peer is found +PPP_DEFAULT_CONFIG = """/dev/ttySAC0 +novjccomp +crtscts +nodetach +defaultroute +noipdefault +disconnect /etc/ppp/peers/gprs-disconnect-chat +novj +holdoff 5 +ipcp-accept-local +user eplus +password gprs +replacedefaultroute +lcp-echo-failure 40000 +connect /etc/ppp/peers/gprs-connect-chat +""" diff --git a/SettingsGUI/tags/0.8/src/settingsgui/ProcessInterface.py b/SettingsGUI/tags/0.8/src/settingsgui/ProcessInterface.py new file mode 100644 index 0000000..91c2460 --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/ProcessInterface.py @@ -0,0 +1,356 @@ +""" + * ProcessInterface.py - SettingsGUI - + * Interface to interactive userspace processes + * + * Based on code from Jens Diemer + * + * Using libgsm_tool until there is a python bindung available + * + * (C) 2008 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import os +import subprocess +import threading +import signal +import time + +class error_poller(threading.Thread): + def __init__(self, error_stream): + self.error_stream = error_stream + threading.Thread.__init__(self) + ## init + self.out_data = [] + self.keep_going = True + self.start() + + def run(self): + while self.keep_going: + self.error_stream.flush() + line = self.error_stream.readline() + if line == "": + break + self.out_data.append(line) + + def stop(self): + """ + kills process if still running + """ + if self.process.poll() != None: + print " already killed" + return + + self.killed = True + os.kill(self.process.pid, signal.SIGQUIT) + ## gice it a second + time.sleep(1) + ## have to kill - as readline is blocking. + os.kill( self.process.pid, signal.SIGKILL ) + + + +class async_process(threading.Thread): + """ + asynchronous subprocess handler + + used to read the output - access through out_data + + not working with Windows - as there is no os.kill() available + command - the command to be started + cwd - directory for execution + timeout - timeout for stop - + 0 to execution until self.keep_going is set to False + """ + def __init__(self, command, options, cwd, timeout): + self.command = command + self.options = options + self.cwd = cwd + self.timeout = timeout + self.process_created_error = False + self.process_created = False ## find out when subprocess() finished + self.keep_going = True + + self.killed = False + self.closed = False + self.out_data = [] # output buffer <- ToDo use a list - for now '\n's + self.events = [] + + threading.Thread.__init__(self) + self.start() + + def run(self): + print "Executes subprocess [%s]" % " ".join([self.command] + self.options) + try: + self.process = subprocess.Popen( + [self.command] + self.options, + cwd = self.cwd, + bufsize = 1, # line buffer + shell = False, + # shell = True, # resulting in broken pipe on stdout + universal_newlines = True, # changes any nl/cr-combination to one nl + stdout = subprocess.PIPE, + stderr = subprocess.PIPE, + stdin = subprocess.PIPE + ) + except: + print "Error: subprocess %s could not be started" % self.command + self.process = 0 + self.process_created_error = True + + + self.process_created = True + # save output + line = "" + while self.keep_going: + char = "" + while char == "": + if not isinstance(self.process, int): + char = self.process.stdout.read(1) + if char == "": + # print "[2]: %s" % self.closed + self.closed = True + #print "process [%s] finished" % \ + # " ".join([self.command] + self.options) + return + else: + # print "[1]: %s" % self.closed + self.closed = True + #print "process [%s] finished" % \ + # " ".join([self.command] + self.options) + return + + line = line + char + if line[-1] == "\n": + self.out_data.append(line) + for event in self.events: + if line.find(event[0]) >= 0: + event[1](line) + line = "" + + print "Subprocess terminated" + + ## event_name <- string to search for (e.g. EVENT: blah changed...) + ## function <- function to call + def register_event_handler(self, event_name, function, args, kwargs): + self.events.append([event_name, function, args, kwargs]) + + def stop( self ): + """ + kills process if still running + """ + if self.process.poll() != None: + print " already killed" + self.closed = True + return + + print "trying to kill" + self.killed = True + os.kill( self.process.pid, signal.SIGQUIT ) + ## gice it a second + time.sleep(1) + ## have to kill - as readline is blocking. + os.kill( self.process.pid, signal.SIGKILL ) + + +class ProcessInterface: + def __init__(self, command): + self.command = command.split()[0] + self.options = [command.split()[x] for x in range(1,len(command.split()))] + + #""" + ## ugly - handle options with spaces + new_options = [] + new_option = "" + is_escaped = False + for option in self.options: + if option.find("\"") >= 0: + if not new_option == "": + new_option = "".join([new_option, " ", option]) + new_options.append(new_option.strip().strip("\"")) +# new_options.append(new_option) + new_option = "" + is_escaped = True + else: + new_option = option + is_escaped = True + + if new_option == "" and not is_escaped: + ## found something escaped string + new_options.append(option) + if new_option != "" and not is_escaped: + new_option = "".join([new_option, " ", option]) + + if len(option.split("\"")) >= 3: + new_options.append(option.strip().strip("\"")) + + is_escaped = False + + self.options = new_options + #print "Options are: ---->%s<----" % self.options + # end ugly + #""" + + self.process = async_process(self.command, self.options, "/", timeout = 0) + + + while self.process.process_created == False: + if self.process.process_created_error: + self.process.closed = True + return -1 + time.sleep(0.1) + self.error_poller = error_poller(self.process.process.stderr) + + ## write string to buffer - new line is attached string + def write_to_process(self, string): + ## find out if process is still running before writing + if self.process.closed: + return False + + if self.process.process.poll() == None: # was == + self.process.process.stdin.write("%s\n" % string) + self.process.process.stdin.flush() + return True + else: + return False + + ## read back string with all output lines currently in buffer + def read_from_process(self): + out_string = "" + for x in self.process.out_data: + out_string += x + return out_string + + ## read back string with all error lines currently in buffer + def read_error_from_process(self): + out_string = "" + for x in self.error_poller.out_data: + out_string += x + return out_string + + ## removes first error in list + def get_error(self): + if len(self.error_poller.out_data) > 0: + out_string = self.error_poller.out_data[0] + self.error_poller.out_data.remove(out_string) + out_string = out_string.split("\n")[0] + return out_string + else: + return "" + + ## removes first output in list + def get_output(self): + if len(self.process.out_data) > 0: + out_string = self.process.out_data[0] + self.process.out_data.remove(out_string) + out_string = out_string.split("\n")[0] + return out_string + else: + return "" + + def register_event_handler(self, event_name, function, args = [], kwargs = {}): + self.process.register_event_handler(event_name, function, args, kwargs) + + def close(self): + self.close_process() + + def close_process(self): + self.process.keep_going = False + if not self.process.closed: + print "trying to kill process" + self.process.stop() + self.process.join(1) + + def process_finished(self): + return self.process.closed + + + + +def process_running(name): + ''' + name can be any string from the commandline to hit. + Parameters are seperated using the '\0' caracter. + + Example: to search for 'su -' use: + process_running("su\0-") + ''' + if not os.path.exists("/proc"): + return False + for key in os.listdir("/proc"): + if key.replace("/proc/", ""): + if key.isdigit(): + fd = open(os.path.join("/proc/", key, "cmdline")) + if fd.read().find(name) >= 0: + return True + return False + + +class test: + def do_test(self): + print "Test interface" + bash = ProcessInterface("/bin/sh") + print "subprocess created" + + time_running = 0 + while time_running < 5: + print "\nEntering while loop" + time_running = time_running + 1 + bash.write_to_process("echo hello") + bash.write_to_process("echo error > /dev/stderr") + time.sleep(0.2) + print "next output<%s>" % bash.get_output() +# print "===\nstdout: <%s> \n===" % bash.read_from_process() + print "next error<%s>" % bash.get_error() +# print "===\nstderr: <%s> \n===" % bash.read_error_from_process() +# time.sleep(0.2) + + bash.close_process() + print "halllooo" + + + def finished_app_test(self): + ls = ProcessInterface("ls") + + while not ls.process_finished(): + time.sleep(0.1) ## wait for command to compute + print "output of ls was [%s]" % ls.read_from_process() + + + def process_running_test(self): + print "Testing if process by name \"python\" is running... ", + if process_running("python"): + print "yes [OKAY]" + else: + print "no [ERROR?!]" + + print "Testing if process by name \"ononenamesitso\" is running... ", + if process_running("ononenamesitso"): + print "yes [ERROR?!]" + else: + print "no [OKAY]" + + + + # ToDo remove + ## self.process = subprocess.Popen(self.command, cwd = self.cwd, shell = True, stdout = subprocess.PIPE, stderr = subprocess.PIPE, stdin = subprocess.PIPE) + +#test = test() +#test.do_test() + + + diff --git a/SettingsGUI/tags/0.8/src/settingsgui/ScreenPanel.py b/SettingsGUI/tags/0.8/src/settingsgui/ScreenPanel.py new file mode 100644 index 0000000..76288df --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/ScreenPanel.py @@ -0,0 +1,122 @@ +""" + * ScreenPanel.py - SettingGUI - Screen Settings Section + * + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + + +import sys +import os +import gtk +from SysFSAccess import * +from GlobalConfiguration import * +#from settingsgui.SysFSAccess import * +#from settingsgui.GlobalConfiguration import * + +class ScreenPanel(gtk.VBox): + orientation = 0 + + def __init__(self): + gtk.VBox.__init__(self, False, 0) + self.create_notebook_page() + + def toggle_backlight(self, widget): + print "trying to toggle the backlight" + value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER) + if value.find("1") != -1: + set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER, 0) + value = "1" + else: + set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_POWER, 1) + value = "0" + + def toggle_orientation(self, widget): + print "trying to toggle screen orientation" + if self.orientation == 0: + os.system("/usr/bin/xrandr -o 1") + self.orientation = 1 + else: + os.system("/usr/bin/xrandr -o 0") + self.orientation = 0 + + + def restart_x_server(self, widget): + mbox = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_YES_NO, + "You hit the Restart-Phone-GUI-Button!\nThis will restart the X11-Server!\nDo you really want to quit ALL applications? (including SettingGUI)") + response = mbox.run() + mbox.hide() + mbox.destroy() + if response == gtk.RESPONSE_YES: + print "SettingsGUI is restarting X11..." + os.system("/etc/init.d/xserver-nodm restart") + + + def bl_level_changed(self, widget): + tmp_value = widget.value + tmp_value = tmp_value * 50 + print "trying to set backlight to %s" % tmp_value + set_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS, tmp_value) + + def create_notebook_page(self): + self.set_border_width(0) + + level_frame = gtk.Frame("Backlight Level") + level_frame.set_border_width(0) + level_box = gtk.VBox(False, 0) + level_box.set_border_width(15) + + init_value = get_sysfs_value(SYSFS_ENTRY_BACKLIGHT_BRIGHTNESS) + if len(init_value) > 0: + init_value = float(init_value) / 50 + else: + init_value = 50 + + + ## scale to set backlight level + scale_adj = gtk.Adjustment(init_value, 0.0, 100.0, 1.0, 1.0, 0.0) + scale_adj.connect("value_changed", self.bl_level_changed, ) + backlight_scale = gtk.HScale(scale_adj) + backlight_scale.set_digits(0) + level_box.add(backlight_scale) + + level_frame.add(level_box) + self.pack_start(level_frame, False, False, 0) + + button_box = gtk.HBox(False, 0) + button_box.set_border_width(0) + self.add(button_box) + + ## button to restart xserver + restart_x_btn = gtk.Button("Restart Phone GUI") + restart_x_btn.connect("clicked", self.restart_x_server) + # button_box.add(restart_x_btn) + + ## button to toggle backlight + bl_toggle_btn = gtk.Button("Backlight\non/off") + bl_toggle_btn.connect("clicked", self.toggle_backlight) + button_box.add(bl_toggle_btn) + + ## button to change orientation + orientation_toggle_btn = gtk.Button("Landscape/\nPortrait") + orientation_toggle_btn.connect("clicked", self.toggle_orientation) + button_box.add(orientation_toggle_btn) + + self.show_all() + ## label to describe notebook page + label = gtk.Label("Backlight") + return (self, label) diff --git a/SettingsGUI/tags/0.8/src/settingsgui/SettingsGUI.py b/SettingsGUI/tags/0.8/src/settingsgui/SettingsGUI.py new file mode 100644 index 0000000..abe2b9c --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/SettingsGUI.py @@ -0,0 +1,153 @@ +""" + * SettingsGUI.py - Creating the main window + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +import time +import sys +import gtk +import gobject +import time +import threading +#from settingsgui.GlobalConfiguration import * +from GlobalConfiguration import * + +class ToggleInterface(threading.Thread): + def __init__(self, settings_gui): + self.settings_gui = settings_gui + threading.Thread.__init__(self) + ## init + print "INIT THREAD FOR UI" + self.out_data = [] + self.keep_going = True + self.start() + + def run(self): + print "STARTING UI" + gtk.gdk.threads_init() + gtk.gdk.threads_enter() +# if : +# self.settings_gui.create_UI() + +class SettingsGUI: + def delete_event(self, widget, event, data=None): + gtk.main_quit() + print("Waiting for all processes to quit...") + time.sleep(1.5) + sys.exit(0) + return False + + def add_notebook_page(self, panel, icon_name): + image = gtk.Image() + image.set_from_icon_name(icon_name, gtk.ICON_SIZE_LARGE_TOOLBAR) + image.show() + image_alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0) + image_alignment.add(image) + image_alignment.set_padding(NOTEBK_PADDING, NOTEBK_PADDING, 0, 0) + image_alignment.show() + scroll_win = gtk.ScrolledWindow() + scroll_win.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scroll_win.show() + scroll_win.add_with_viewport(panel) + self.notebook.append_page(scroll_win, image_alignment) + + # do this in an extra method - so init can return faster + def create_UI(self): + if self.state != "init-done": + return + + self.state = "running" + self.window.remove(self.loading_lbl) + start_time = self.start_time + self.window.set_title("SettingsGUI") + print "0.2: %s" %(time.time() - start_time) + + ## not working from shell - is within package + #from settingsgui.ScreenPanel import ScreenPanel + #from settingsgui.AudioPanel import AudioPanel + #from settingsgui.GSMPanel import GSMPanel + #from settingsgui.GPRSPanel import GPRSPanel + #from settingsgui.BluetoothPanel import BluetoothPanel + + from ScreenPanel import ScreenPanel + from AudioPanel import AudioPanel + from GSMPanel import GSMPanel + from GPRSPanel import GPRSPanel + from BluetoothPanel import BluetoothPanel + + + print "0.3: %s" %(time.time() - start_time) + + + self.notebook = gtk.Notebook() + self.notebook.set_tab_pos(gtk.POS_BOTTOM) + + + print "1: %s" %(time.time() - start_time) + + self.add_notebook_page(ScreenPanel(), "preferences-desktop-screensaver") + + print "2: %s" %(time.time() - start_time) + + self.add_notebook_page(AudioPanel(), "moko-speaker") + print "3: %s" %(time.time() - start_time) + GSM_Panel = GSMPanel() + self.add_notebook_page(GSM_Panel, "moko-call-redial") + print "4: %s" %(time.time() - start_time) + self.add_notebook_page(GPRSPanel(GSM_Panel), "gtk-network") + print "5: %s" %(time.time() - start_time) + self.add_notebook_page(BluetoothPanel(), "gtk-connect") + print "6: %s" %(time.time() - start_time) + + ## expand page selectors to full width + for child in self.notebook.get_children(): + self.notebook.child_set_property(child, "tab_expand", True) + self.notebook.show() + + print "7: %s" %(time.time() - start_time) + + #self.main_panel.add(self.notebook) + + txt = gtk.Label("Loading ...") + self.window.add(self.notebook) + + self.window.show_all() + #self.window.queue_draw_area(0,0,-1,-1) + self.window.show() + + def __init__(self): + self.state = "init" + start_time = time.time() + self.start_time = start_time + self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) + self.window.set_border_width(0) + self.window.set_default_size(480, 640) + self.window.connect("delete_event", self.delete_event) + self.notebook = gtk.Notebook() + self.state = "init-done" + # we can't let them wait! + print "0.1: %s" %(time.time() - start_time) + self.loading_lbl = gtk.Label("Loading ...") + self.window.add(self.loading_lbl) + self.window.show_all() +# self.window.add(txt) + #self.main_panel = gtk.VBox() + #self.main_panel.add(self.notebook) +# self.notebook.show() +# self.window.add(self.notebook) + #interface_thread = ToggleInterface(self) diff --git a/SettingsGUI/tags/0.8/src/settingsgui/SysFSAccess.py b/SettingsGUI/tags/0.8/src/settingsgui/SysFSAccess.py new file mode 100644 index 0000000..2949bc2 --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/SysFSAccess.py @@ -0,0 +1,38 @@ +""" + * SysFSAccess.py - SettingsGUI - tools to access SysFS + * + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +""" + +def set_sysfs_value(entry_dir, value): + try: + file_descriptor = open(entry_dir, 'w') + except: + return False + file_descriptor.write("%d" % int(value)) + file_descriptor.close() + return True + +def get_sysfs_value(entry_dir): + try: + file_descriptor = open(entry_dir) + except: + return "" + value = file_descriptor.read() + file_descriptor.close() + return value diff --git a/SettingsGUI/tags/0.8/src/settingsgui/__init__.py b/SettingsGUI/tags/0.8/src/settingsgui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/SettingsGUI/tags/0.8/src/settingsgui/pppdConfigParser.py b/SettingsGUI/tags/0.8/src/settingsgui/pppdConfigParser.py new file mode 100644 index 0000000..2ecd124 --- /dev/null +++ b/SettingsGUI/tags/0.8/src/settingsgui/pppdConfigParser.py @@ -0,0 +1,681 @@ +#!/usr/bin/python +""" + * pppdConfigParser.py - Parsing the configuration of a pppd peer + * + * (C) 2007 by Kristian Mueller + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Thanks to Bartek Zdanowski for changing ATDT to ATD + * and suggesting #99* as dial string + * + * --- + * chat-script parsing is not complete at all + * we just parse what we need for gprs for now... + * + * --- + * Paramenters and how we parse them for now + * (the once called "FREQUENTLY USED OPTIONS" in the pppd man page) + * + * NFC - not fully compatible (can not parse all variants yet) + * FC - fully compatible (can parse all variants of the poarameter) + * NFC? - manpage was not explicit enough + * + * ttyname - a string starting with /dev/ (NFC) + * speed - a line only containing an integer (FC) + * asyncmap - 32 Bit Hex number (withoug "0x") default 0 (mask) (FC) + * auth - flag - default False (FC) + * call - filename of a file from relative to current dir (FC) + * connect