diff options
Diffstat (limited to 'lilo-config')
45 files changed, 4656 insertions, 0 deletions
diff --git a/lilo-config/COPYING b/lilo-config/COPYING new file mode 100644 index 0000000..8c1e969 --- /dev/null +++ b/lilo-config/COPYING @@ -0,0 +1,346 @@ +NOTE: The GPL below is copyrighted by the Free Software Foundation, but +the instance of code that it refers to are copyrighted by the author(s) who +actually wrote it. + +--------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The 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. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + 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 + + +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) 19yy 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. + + <signature of Ty Coon>, 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/lilo-config/Makefile.am b/lilo-config/Makefile.am new file mode 100644 index 0000000..2a20143 --- /dev/null +++ b/lilo-config/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = common kde-qt-common kde + +messages: + $(XGETTEXT) -k_ */*.cpp -o $(podir)/kcmlilo.pot + diff --git a/lilo-config/README b/lilo-config/README new file mode 100644 index 0000000..db83406 --- /dev/null +++ b/lilo-config/README @@ -0,0 +1,9 @@ +lilo-config is a kcontrol plugin for configuring LILO, the most commonly +used Linux boot loader. + +Parts of the code (basically all the code that does the real work) are designed +to be UI independent (if I ever have the time, there will be a textmode +frontend), which is why I'm using "String"s rather than "QString"s throughout +the code. Please don't change this. + +Send comments/suggestions to kde-devel@kde.org. diff --git a/lilo-config/common/Config.cc b/lilo-config/common/Config.cc new file mode 100644 index 0000000..37921ba --- /dev/null +++ b/lilo-config/common/Config.cc @@ -0,0 +1,66 @@ +/* Config.cc +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "Config.h" +void ConfigFile::set(String const &key, String const &value, bool const "e, bool const &removeIfEmpty, String const &prefix) +{ + String re="[ \t]*" + key + "[ \t]*="; + String s=grep(re); + if(value.empty() && removeIfEmpty) { + if(!s.empty()) + remove(s); + } else if(s.empty()) { + if(quote) + insert(end(), prefix + key + "=\"" + value + "\""); + else + insert(end(), prefix + key + "=" + value); + } else { + for(iterator it=begin(); it!=end(); it++) + if(!(*it).regex(re).empty()) { + if(quote) + (*it)=prefix + key + "=\"" + value +"\""; + else + (*it)=prefix + key + "=" + value; + break; + } + } +} +String const ConfigFile::get(String const &key, String const &dflt, bool const &unquote) +{ + String s=grep("[ \t]*" + key + "[ \t]*=").simplifyWhiteSpace(); + if(s.empty()) + return dflt; + s=s.mid(s.locate("=")+2).simplifyWhiteSpace(); + if(unquote) { + if(s.chr(0)=='"') + s=s.mid(2); + if(s.chr(s.size()-1)=='"') + s=s.left(s.size()-1); + } + return s.simplifyWhiteSpace(); +} diff --git a/lilo-config/common/Config.h b/lilo-config/common/Config.h new file mode 100644 index 0000000..6ac6334 --- /dev/null +++ b/lilo-config/common/Config.h @@ -0,0 +1,40 @@ +/* Config.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _CONFIGFILE_H_ +#define _CONFIGFILE_H_ 1 + +#include "String.h" +class ConfigFile:public StringList +{ +public: + void set(String const &key, String const &value, bool const "e=true, bool const &removeIfEmpty=true, String const &prefix=""); + String const get(String const &key, String const &dflt="", bool const &unquote=true); +}; + +#endif diff --git a/lilo-config/common/Disks.cc b/lilo-config/common/Disks.cc new file mode 100644 index 0000000..b4a417d --- /dev/null +++ b/lilo-config/common/Disks.cc @@ -0,0 +1,294 @@ +/* Disks.cc +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "Disks.h" +#include <unistd.h> +#include <stdio.h> +#include <fcntl.h> +#include <ctype.h> +#include <stdlib.h> +#include <string.h> + +StringList ptable::disklist() +{ + /* The basics behind scanning for a disk are simple: If it can be * + * opened, it exists. * + * Using access() is not sufficient - that's successful if the device * + * node exists but there's no actual device. * + * Checking /proc/devices would work, but it wouldn't autoload modules* + * so chances are we'd be missing something. */ + StringList dsk; + int fd; + bool finished=false; + #define CHECK_DEV(d) if((fd=open(d, O_RDONLY))<0) { \ + finished=true; \ + continue; \ + } \ + close(fd); \ + dsk+=d + String dev="/dev/hd"; // IDE devices: /dev/hd[a-t] + for(char a='a'; a<='t'; a++) { + // We can't use finished for IDE drives - it's perfectly OK + // to have a /dev/hdc but no /dev/hdb. + CHECK_DEV(dev+a); + } + finished=false; + dev="/dev/sd"; // SCSI disks 0-25 + for(char a='a'; a<='z' && !finished; a++) { + CHECK_DEV(dev+a); + } + for(char prefix='a'; prefix <='d' && !finished; prefix++) { + dev="/dev/sd" + prefix; // SCSI disks 26-127 + for(char a='a'; (a<='x' || (a<='z' && prefix<'d')) && !finished; a++) { + CHECK_DEV(dev+a); + } + } + finished=false; + dev="/dev/i2o/hd"; // I2O disks 0-25: /dev/i2o/hd[a-z] + for(char a='a'; a<='z' && !finished; a++) { + CHECK_DEV(dev+a); + } + for(char prefix='a'; prefix <='d' && !finished; prefix++) { + dev="/dev/i2o/hd" + prefix; // I2O disks 26-127 + for(char a='a'; (a<='x' || (a<='z' && prefix<'d')) && !finished; a++) { + CHECK_DEV(dev+a); + } + } + finished=false; + dev="/dev/pd"; // Parallel port disks: /dev/pd[a-d] + for(char a='a'; a<='d' && !finished; a++) { + CHECK_DEV(dev+a); + } + finished=false; + for(unsigned int i=0; i<=31 && !finished; i++) { // Software RAID + String device; + device.sprintf("/dev/md%u", i); + CHECK_DEV(device); + } + finished=false; + for(unsigned int i=0; i<=7; i++) { //Compaq Smart Array + for(unsigned int j=0; j<=15 && !finished; j++) { + String device; + device.sprintf("/dev/ida/c%ud%u", i, j); + CHECK_DEV(device); + } + } + finished=false; + for(unsigned int i=0; i<=7; i++) { // Mylex DAC960 + for(unsigned int j=0; j<=31 && !finished; j++) { + String device; + device.sprintf("/dev/rd/c%ud%u", i, j); + CHECK_DEV(device); + } + } + finished=false; + dev="/dev/ed"; // MCA ESDI harddisks: /dev/ed[ab] + for(char a='a'; a<='b' && !finished; a++) { + CHECK_DEV(dev+a); + } + finished=false; + dev="/dev/xd"; // XT (8-bit) harddisks: /dev/xd[ab] + for(char a='a'; a<='b' && !finished; a++) { + CHECK_DEV(dev+a); + } + return dsk; +} +StringList ptable::partlist() +{ + StringList s; + StringList d=disklist(); + for(StringList::const_iterator it=d.begin(); it!=d.end(); it++) { + for(int i=1; i<32; i++) { + String drive; + drive.sprintf("%s%u", (*it).cstr(), i); + int fd=open(drive, O_RDONLY); + if(fd>=0) { + char test; + if(read(fd, &test, 1)>0) + s += drive; + close(fd); + } else + break; + } + } + return s; +} +ptable::ptable(StringList const &disks) +{ + partition.clear(); + id.clear(); + mountpt.clear(); + for(StringList::const_iterator it=disks.begin(); it!=disks.end(); it++) + scandisk(*it); +} +ptable::ptable(String const &disk) +{ + partition.clear(); + id.clear(); + mountpt.clear(); + scandisk(disk); +} +void ptable::scandisk(String const &disk) +{ + String cmd; + cmd.sprintf("fdisk -l %s 2>&1", (char*)disk); + FILE *fdisk=popen(cmd, "r"); + char *buf=(char *) malloc(1024); + String dev; + while(fgets(buf, 1024, fdisk)) { + if(strncmp("/dev/", buf, 5)==0) { // Partition entry + // We don't care about active vs. non-active partitions. + // Remove the sign. + while(strchr(buf, '*')) *strchr(buf, '*')=' '; + // blanks are blanks... + while(strchr(buf, '\t')) *strchr(buf, '\t')=' '; + // Get the device + *strchr(buf, ' ')=0; + dev=buf; + partition += buf; + // And figure out where/if it's mounted + mountpt[dev]=mountpoint(dev); + // Lastly, get the partition type. + strcpy(buf, buf+strlen(buf)+1); + while(isspace(*buf)) strcpy(buf, buf+1); + strcpy(buf, strchr(buf, ' ')); // skip Start + while(isspace(*buf)) strcpy(buf, buf+1); + strcpy(buf, strchr(buf, ' ')); // skip End + while(isspace(*buf)) strcpy(buf, buf+1); + strcpy(buf, strchr(buf, ' ')); // skip Blocks + while(isspace(*buf)) strcpy(buf, buf+1); + id[dev]=strtol(buf, NULL, 16); + } + } + pclose(fdisk); + free(buf); +} +String ptable::mountpoint(String const &device, bool fstab_fallback) +{ + char *buf=new char[1024]; + FILE *f=fopen("/etc/mtab", "r"); + String mp=""; + while(fgets(buf, 1024, f)) { + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + if(device.cmp(buf)) { + strcpy(buf, buf+strlen(buf)+1); + while(isspace(*buf)) + strcpy(buf, buf+1); + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + mp=buf; + mp=mp.simplifyWhiteSpace(); + break; + } + } + fclose(f); + if(mp.empty() && fstab_fallback) { + f=fopen("/etc/fstab", "r"); + while(fgets(buf, 1024, f)) { + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + if(device.cmp(buf)) { + strcpy(buf, buf+strlen(buf)+1); + while(isspace(*buf)) + strcpy(buf, buf+1); + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + mp=buf; + mp=mp.simplifyWhiteSpace(); + break; + } + } + fclose(f); + } + delete buf; + return mp; +} +String ptable::device(String const &mountpt, bool fstab_fallback) +{ + char *buf=new char[1024]; + FILE *f=fopen("/etc/mtab", "r"); + String dev=""; + while(fgets(buf, 1024, f)) { + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + String device=buf; + strcpy(buf, buf+strlen(buf)+1); + while(isspace(*buf)) + strcpy(buf, buf+1); + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + String mp=buf; + mp=mp.simplifyWhiteSpace(); + if(mp==mountpt) { + dev=device; + break; + } + } + fclose(f); + + if(dev.empty() && fstab_fallback) { + // The FS is not mounted - maybe it could be, though. + f=fopen("/etc/fstab", "r"); + while(fgets(buf, 1024, f)) { + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + String device=buf; + strcpy(buf, buf+strlen(buf)+1); + while(isspace(*buf)) + strcpy(buf, buf+1); + if(strchr(buf,' ')) + *strchr(buf, ' ')=0; + if(strchr(buf,'\t')) + *strchr(buf, '\t')=0; + String mp=buf; + mp=mp.simplifyWhiteSpace(); + if(mp==mountpt) { + dev=device; + break; + } + } + fclose(f); + } + delete buf; + return dev; +} diff --git a/lilo-config/common/Disks.h b/lilo-config/common/Disks.h new file mode 100644 index 0000000..8965694 --- /dev/null +++ b/lilo-config/common/Disks.h @@ -0,0 +1,49 @@ +/* Disks.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _DISKS_H_ +#define _DISKS_H_ 1 +#include "String.h" +#include <list> +#include <map> +class ptable { +public: + ptable(StringList const &disks=disklist()); + ptable(String const &disk); + static StringList disklist(); + static StringList partlist(); + static String mountpoint(String const &device, bool fstab_fallback=false); + static String device(String const &mountpt, bool fstab_fallback=false); +protected: + void scandisk(String const &disk); +public: + StringList partition; + std::map<String,int> id; + std::map<String,String> mountpt; +}; +#endif diff --git a/lilo-config/common/Files.cc b/lilo-config/common/Files.cc new file mode 100644 index 0000000..19af29d --- /dev/null +++ b/lilo-config/common/Files.cc @@ -0,0 +1,70 @@ +/* Files.cc +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "Files.h" +#include <glob.h> +#include <sys/stat.h> +#define ISSET(x,y) ((x&y)==y) +StringList &Files::glob(String name, enum Types types, bool dotfiles, bool braces) +{ + glob_t gl; + int flags=0; + StringList *result; + if(dotfiles) + flags |= GLOB_PERIOD; + if(braces) + flags |= GLOB_BRACE; + ::glob(name, flags, NULL, &gl); + if(types==Any) + result=new StringList(gl.gl_pathv, gl.gl_pathc); + else { + struct stat s; + result=new StringList; + for(unsigned int i=0; i<gl.gl_pathc; i++) { + if(!lstat(gl.gl_pathv[i], &s)) { + if(S_ISLNK(s.st_mode) && !ISSET(types,Link)) + continue; + if(S_ISREG(s.st_mode) && !ISSET(types,File)) + continue; + if(S_ISDIR(s.st_mode) && !ISSET(types,Dir)) + continue; + if(S_ISCHR(s.st_mode) && !ISSET(types,CharDevice)) + continue; + if(S_ISBLK(s.st_mode) && !ISSET(types,BlockDevice)) + continue; + if(S_ISFIFO(s.st_mode) && !ISSET(types,Fifo)) + continue; + if(S_ISSOCK(s.st_mode) && !ISSET(types,Socket)) + continue; + result->insert(result->end(), gl.gl_pathv[i]); + } + } + } + globfree(&gl); + return *result; +} diff --git a/lilo-config/common/Files.h b/lilo-config/common/Files.h new file mode 100644 index 0000000..ad1fa3b --- /dev/null +++ b/lilo-config/common/Files.h @@ -0,0 +1,47 @@ +/* Files.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _FILES_H_ +#define _FILES_H_ 1 +#include "String.h" +class Files { +public: + enum Types { File = 0x1, + Dir = 0x2, + Link = 0x4, + CharDevice = 0x8, + BlockDevice= 0x10, + Device = CharDevice | BlockDevice, + Fifo = 0x20, + Socket = 0x40, + All = File | Dir | Link | Device | Fifo | Socket, + Any = All + }; + static StringList &glob(String name, enum Types types=All, bool dotfiles=true, bool braces=true); +}; +#endif diff --git a/lilo-config/common/Makefile.am b/lilo-config/common/Makefile.am new file mode 100644 index 0000000..37b44eb --- /dev/null +++ b/lilo-config/common/Makefile.am @@ -0,0 +1,11 @@ +# SUBDIRS = tests + +noinst_LTLIBRARIES = libcommon.la +INCLUDES = $(all_includes) + +noinst_HEADERS = \ + String.h Files.h Disks.h Config.h lilo.h + +libcommon_la_SOURCES = \ + String.cc Files.cc Disks.cc Config.cc lilo.cc + diff --git a/lilo-config/common/String.cc b/lilo-config/common/String.cc new file mode 100644 index 0000000..f8a0e35 --- /dev/null +++ b/lilo-config/common/String.cc @@ -0,0 +1,437 @@ +/* String.cc +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#define _GNU_SOURCE 1 +#include <features.h> +#include <string.h> +#include <string> +#include "String.h" +#include <stdio.h> +#include <regex.h> +#include <stdlib.h> + +using namespace std; + +void String::sprintf(const char *format, ...) +{ + va_list arg; + va_start(arg, format); + char *buf=0; + int size=vsnprintf(buf, 0, format, arg); + if(size==-1) { /* ARGH!!! */ + cerr << "WARNING: Your C library (libc) does not conform to the ISO C99 standard!" << endl << "Consider upgrading to glibc 2.1 or higher!" << endl; + int bufsiz=1024; + while(size==-1) { + buf=(char *) malloc(bufsiz); + size=vsnprintf(buf, 0, format, arg); + bufsiz+=1024; + free(buf); + } + } + buf=(char *) malloc(size+1); + vsnprintf(buf, size+1, format, arg); + string str=buf; + *this=buf; + va_end(arg); + free(buf); + return; +} +bool String::readfile(String filename) +{ + FILE *f=fopen(filename, "r"); + if(!f) + return false; + + string str=""; + char *buf=(char *) malloc(1024); + while(!feof(f) && !ferror(f)) { + if(!fgets(buf, 1024, f)) + continue; + str += buf; + }; + *this=buf; + free(buf); + fclose(f); + return true; +} +char *String::cstr() const +{ + char *a=new char[size()+1]; + a[size()]=0; + strncpy(a, data(), size()); + return a; +} +bool String::cmp(char const * const s) const +{ + if(size() != strlen(s)) + return false; + return (strncmp(data(), s, size())==0); +} +bool String::casecmp(char const * const s) const +{ + if(size() != strlen(s)) + return false; + return (strncasecmp(data(), s, size())==0); +} +bool String::contains(String const &s, bool cs) const +{ + if(cs) + if(strstr(cstr(), s.cstr())) + return true; + else + return false; + else + if(strcasestr(cstr(), s.cstr())) + return true; + else + return false; +} +int String::locate(String const &s, bool cs, unsigned int startat) const +{ + if(startat>=size()) + return -1; + + char *s0=cstr(), *s1=s.cstr(), *s2; + int r; + if(cs) + s2=strstr(s0+startat, s1); + else + s2=strcasestr(s0+startat, s1); + if(s2==NULL) { + delete [] s0; + delete [] s1; + return -1; + } + r=(s2-s0); + if(startat>0) r++; + delete [] s0; + delete [] s1; + return r; +} +String const String::operator +(char const &s) { + char a[2]; + a[0]=s; + a[1]=0; + String st=cstr(); + st+=a; + return st; +} +String const String::operator +(char const * const s) { + String st=cstr(); + st += s; + return st; +} +bool String::operator ==(char s) { + if(size()==1 && cstr()[0]==s) + return true; + else + return false; +} +bool String::operator !=(char s) { + if(size()!=1 || cstr()[0]!=s) + return true; + else + return false; +} +String String::simplifyWhiteSpace() const { + char *s=cstr(); + for(unsigned int i=0; i<size(); i++) + if(isspace(s[i])) + s[i]=' '; + while(*s==' ') + strcpy(s, s+1); + int l = strlen(s); + while(l && (s[l-1]==' ')) + s[--l]=0; + + while(strstr(s, " ")) + strcpy(strstr(s, " "), strstr(s, " ")+1); + return s; +} +String String::left(unsigned int num) const +{ + if(num==0) return ""; + char *s=cstr(); + if(size()<=num) + return s; + s[num]=0; + return s; +} +String String::right(unsigned int num) const +{ + if(num==0) return ""; + char *s=cstr(); + if(size()<=num) + return s; + strcpy(s, s+strlen(s)-num); + return s; +} +String String::mid(unsigned int start, unsigned int num) const +{ + if(start>=size()) + return ""; + char *s=cstr(); + start--; + if(start>0) + strcpy(s, s+start); + if(num>0 && num<=strlen(s)) + s[num]=0; + return s; +} +String &String::regex(String const &expr, bool cs) const +{ + regex_t regexp; + int err; + regmatch_t reg[1]; + String *ret=new String(""); + if((err=regcomp(®exp, expr, cs?REG_EXTENDED:REG_EXTENDED|REG_ICASE))) { + regfree(®exp); + return *ret; + } + err=regexec(®exp, cstr(), 1, reg, 0); + regfree(®exp); + if(err) + return *ret; + if(reg[0].rm_so!=-1) { + char *s=strdup(cstr()+reg[0].rm_so); + s[reg[0].rm_eo-reg[0].rm_so]=0; + delete ret; + ret=new String(s); + free(s); + } + return *ret; +} +String &String::replace(String const &what, String const &with, bool all) const +{ + String *result; + if(!contains(what)) { + result=new String(*this); + return *result; + } + result=new String; + *result=left(locate(what)); + *result+=with; + if(!all) { + *result+=right(size()-locate(what)-what.size()); + } else { + unsigned int start=locate(what)+what.size()+1; + int loc; + while((loc=locate(what, true, start+1))!=-1) { + *result+=mid(start, loc-start); + *result+=with; + start=locate(what, true, start)+what.size(); + } + if(size()>start) + *result+=right(size()-start+1); + } + return *result; +} +String String::escapeForRegExp(String const &s) +{ + static const char meta[] = "$()*+.?[\\]^{|}"; + String quoted = s; + int i = 0; + + while ( i < (int) quoted.length() ) { + if ( strchr(meta, quoted.at(i)) != 0 ) + quoted.insert( i++, "\\" ); + i++; + } + return quoted; +} +StringList::StringList(String const &s) +{ + clear(); + char *st=strdup((char const * const)s); + char *tok; + char *line=strtok_r(st, "\n", &tok); + while(line) { + if(line[strlen(line)-1]=='\r') // Handle sucking OSes + line[strlen(line)-1]=0; + insert(end(), line); + line=strtok_r(NULL, "\n", &tok); + } + free(st); +} + +StringList::StringList(char **strs, int num) +{ + clear(); + if(num>=0) { + for(int i=0; i<num; i++) + insert(end(), strs[i]); + } else { + for(int i=0; strs[i]!=NULL; i++) + insert(end(), strs[i]); + } +} + +bool StringList::readfile(String const &filename) +{ + clear(); + FILE *f=fopen(filename, "r"); + if(!f) + return false; + char *buf=(char *) malloc(1024); + while(!feof(f) && !ferror(f)) { + if(!fgets(buf, 1024, f)) + continue; + while(strlen(buf) && (buf[strlen(buf)-1]=='\n' || buf[strlen(buf)-1]=='\r')) + buf[strlen(buf)-1]=0; + insert(end(), buf); + }; + free(buf); + fclose(f); + return true; +} +bool StringList::writefile(String const &filename) const +{ + FILE *f=fopen(filename, "w"); + if(!f) + return false; + for(const_iterator it=begin(); it!=end(); it++) { + fputs(*it, f); + fputs("\n", f); + } + fclose(f); + return true; +} +void StringList::operator +=(StringList const &s) +{ + for(const_iterator it=s.begin(); it!=s.end(); it++) + insert(end(), *it); +} +void StringList::operator +=(StringList const * const s) +{ + for(const_iterator it=s->begin(); it!=s->end(); it++) + insert(end(), *it); +} +bool StringList::contains(String const &s) const +{ + for(const_iterator it=begin(); it!=end(); it++) + if(*it == s) + return true; + return false; +} +void StringList::remove(String const &s) +{ + bool done=false; + for(iterator it=begin(); !done && it!=end(); it++) + if(*it==s) { + erase(it); + done=true; + } +} +String const &StringList::grep(String const &s) const +{ + for(const_iterator it=begin(); it!=end(); it++) + if(!(*it).regex(s).empty()) + return *it; + String *r=new String; + return *r; +} +int __stringlist_compare(const void *a, const void *b) +{ + if(a==0 && b==0) + return 0; + else if(a==0) + return 1; + else if(b==0) + return -1; + else + return strcmp((const char *)a,(const char *)b); +} +int __stringlist_compare_noncs(const void *a, const void *b) +{ + if(a==0 && b==0) + return 0; + else if(a==0) + return 1; + else if(b==0) + return -1; + else + return strcasecmp((const char *)a,(const char *)b); +} +void StringList::sort(bool cs) +{ + unsigned int i=0, s=size(); + char **strings=new char*[s]; + for(const_iterator it=begin(); it!=end(); it++) + strings[i++]=(*it).cstr(); + if(cs) + qsort(strings, s, sizeof(char*), __stringlist_compare); + else + qsort(strings, s, sizeof(char*), __stringlist_compare_noncs); + clear(); + for(i=0; i<s; i++) { + insert(end(), strings[i]); + delete [] strings[i]; + } + delete [] strings; +} +StringList::operator String() const +{ + String s=""; + for(const_iterator it=begin(); it!=end(); it++) { + s+=(*it); + if(s.right()!=String("\n") && s.right()!=String("\r")) + s+="\n"; + } + return s; +} + +ostream &operator <<(ostream &os, String const &s) +{ + if(!s.empty()) + os << (char const * const) s; + return os; +} +ostream &operator <<(ostream &os, String const *s) +{ + if(!s->empty()) + os << (char const * const) *s; + return os; +} +ostream &operator <<(ostream &os, StringList const &s) +{ + for(StringList::const_iterator it=s.begin(); it!=s.end(); it++) { + os << *it; + if((*it).right()!=String("\n") && (*it).right()!=String("\r")) + os << endl; + } + return os; +} +ostream &operator <<(ostream &os, StringList const *s) +{ + for(StringList::const_iterator it=s->begin(); it!=s->end(); it++) { + os << *it; + if((*it).right()!=String("\n") && (*it).right()!=String("\r")) + os << endl; + } + return os; +} diff --git a/lilo-config/common/String.h b/lilo-config/common/String.h new file mode 100644 index 0000000..7b12af5 --- /dev/null +++ b/lilo-config/common/String.h @@ -0,0 +1,96 @@ +/* String.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +/* Somewhat more sane string handling functions... * + * Should be portable, therefore we aren't simply using QString. */ + +#ifndef _STRING_H_ +#define _STRING_H_ 1 +#include <string> +#include <list> +#include <iostream> +#include <stdarg.h> + +class String; +class StringList; + +typedef std::list<String> strlist; + +class String:public std::string { +public: + String():std::string("") { } + String(char const * const &s):std::string(s) { } + String(std::string const &s):std::string(s) { } + String const operator +(char const &s); + String const operator +(char const * const s); + bool operator ==(char s); + bool operator !=(char s); + operator char * () const { return cstr(); } + char * cstr() const; + bool cmp(char const * const s) const; + bool casecmp(char const * const s) const; + bool contains(String const &s, bool cs=true) const; + int locate(String const &s, bool cs=true, unsigned int startat=0) const; + void sprintf(const char *format, ...); + bool readfile(String filename); + String simplifyWhiteSpace() const; + String left(unsigned int num=1) const; + String right(unsigned int num=1) const; + String mid(unsigned int start, unsigned int num=0) const; + String ®ex(String const &expr, bool cs=true) const; + String &replace(String const &what, String const &with, bool all=true) const; + static String escapeForRegExp(String const &s); + char chr(unsigned int index) const { if(index>=size()) return 0; else return data()[index]; } + int length() const { return size(); } // For compatibility with QString + char const *latin1() const { return cstr(); } // For compatibility with QString +}; + +class StringList:public strlist { +public: + StringList() { clear(); } + StringList(String const &s); + StringList(char **strs, int num=-1); + bool readfile(String const &filename); + bool writefile(String const &filename) const; + void operator +=(String const &s) { insert(end(), s); } + void operator +=(char const * const &s) { insert(end(), s); } + void operator +=(StringList const &s); + void operator +=(StringList const * const s); + operator String() const; + bool contains(String const &s) const; + void remove(String const &s); + void add(String const &s) { insert(end(), s); } + String const &grep(String const &s) const; + void sort(bool cs=true); +}; + +std::ostream &operator <<(std::ostream &os, String const &s); +std::ostream &operator <<(std::ostream &os, String const *s); +std::ostream &operator <<(std::ostream &os, StringList const &s); +std::ostream &operator <<(std::ostream &os, StringList const *s); +#endif diff --git a/lilo-config/common/lilo.cc b/lilo-config/common/lilo.cc new file mode 100644 index 0000000..6625f0d --- /dev/null +++ b/lilo-config/common/lilo.cc @@ -0,0 +1,585 @@ +/* lilo.cc +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "lilo.h" +#include "Disks.h" +#include "Files.h" +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/mount.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <fstream> +#include <string.h> + +using namespace std; + +bool liloimage::isLinux() const { + const_iterator it=begin(); + if((*it).contains("image")) + return true; + else + return false; +} + +liloimage *liloimages::find(String const &s) const +{ + String t = String::escapeForRegExp(s); + + String regex="^[ \t]*label[ \t]*=[ \t]*\"?" + t + "\"?[ \t]*"; + for(const_iterator it=begin(); it!=end(); it++) { + if(!(*it).grep(regex).empty()) + return (liloimage*)&(*it); + } + return 0; +} +void liloimages::remove(String const &s) +{ + liloimage *i=find(s); + for(iterator it=begin(); it!=end(); it++) + if(*it==*i) { + erase(it); + break; + } +} + +liloconf::liloconf(String const &filename) +{ + checked=false; + defaults.clear(); + images.clear(); + if(filename.empty()) { + probe(); + } else { + StringList s; + if(s.readfile(filename)) + set(s); + else + probe(); + } +} +void liloconf::set(StringList const &s) +{ + defaults.clear(); + images.clear(); + checked=false; + bool inHeader=true; + bool start; + liloimage *image=0; + for(StringList::const_iterator it=s.begin(); it!=s.end(); it++) { + String s=*it; + start=false; + s=s.simplifyWhiteSpace(); + if(s.empty()) + continue; + if(s.left(5)==(String)"other" && (s.mid(6, 1)==' ' || s.mid(6, 1)=='=')) { + inHeader=false; + start=true; + } + if(s.left(5)==(String)"image" && (s.mid(6, 1)==' ' || s.mid(6, 1)=='=')) { + inHeader=false; + start=true; + } + if(inHeader) { + defaults+=*it; + } else if(start) { + if(image) + images.insert(images.end(), *image); + image=new liloimage; + *image += *it; + } else { + *image += *it; + } + } + if(image) + images.insert(images.end(), *image); +} +void liloconf::set(String const &s) +{ + set((StringList)s); +} +void liloconf::writeFile(String const &filename) +{ + ofstream f; + f.open(filename, ios::out); + f << *this << endl; + f.close(); + chmod(filename, 0600); +} +bool liloconf::install(bool probeonly) +{ + char *lilotmp=strdup("/tmp/liloXXXXXX"); + String command; + int fd=mkstemp(lilotmp); + // Unfortunately, gcc 3.1 and higher don't have ofstream::attach + // anymore. Pity, used to be immensely useful. + // f.attach(fd); + close(fd); + ofstream f(lilotmp, ios::out); + f << defaults << endl; + for(liloimages::iterator it=images.begin(); it!=images.end(); it++) { + f << *it << endl; + } + f.close(); + + if(probeonly) + command.sprintf("/sbin/lilo -v -t -C %s 2>&1", (char const * const)lilotmp); + else + command.sprintf("/sbin/lilo -v -C %s 2>&1", (char const * const)lilotmp); + output=""; + FILE *lilo=popen(command, "r"); + char *buf=(char *) malloc(1024); + while(fgets(buf, 1024, lilo)) + output += buf; + free(buf); + ok=(pclose(lilo)==0); + unlink(lilotmp); + free(lilotmp); + checked=true; + return ok; +} +bool const liloconf::isOk() +{ + if(!checked) + check(); + return ok; +} +String const liloconf::liloOut() +{ + if(!checked) + check(); + return output; +} +bool liloconf::probe() +{ + ptable p; + StringList drives=p.disklist(); + String const root=p.device("/", true); + checked=false; + defaults.clear(); + images.clear(); + /* Set some reasonable defaults... */ + // Try to figure out the boot device first... + if(drives.contains("/dev/hda")) { + defaults += "boot=/dev/hda"; // 1st IDE/ATAPI harddisk + defaults += "lba32"; // otherwise it is assumed + } + else if(drives.contains("/dev/sda")) { + defaults += "boot=/dev/sda"; // 1st SCSI harddisk + defaults += "linear"; // some SCSI disks need this + } else if(drives.contains("/dev/i2o/hda")) + defaults += "boot=/dev/i2o/hda"; // 1st I2O harddisk + else if(drives.contains("/dev/eda")) + defaults += "boot=/dev/eda"; // 1st MCA ESDI harddisk + else if(drives.contains("/dev/pda")) + defaults += "boot=/dev/pda"; // 1st Parallel port IDE disk + else + defaults += "boot=Insert_your_boot_device_here"; // shouldn't happen + defaults += "prompt"; + defaults += "timeout=50"; + if(!access("/boot/message", F_OK)) + defaults += "message=/boot/message"; + defaults += "root=" + root; + + /* Scan for available operating systems... + * The list of what to do for each partition type is based on my + * best guess. I don't have anything but Linux (Red Hat Linux 7.0), + * FreeBSD (5.0-CURRENT), OpenBSD (2.6), FreeDOS (some CVS snapshot) + * and DR-DOS (7.03), so anything else might be wrong. + * If you have any additions or corrections, please send them to + * bero@redhat.com. + */ + // Scan for Linux kernels in the currently running system + // The following may or may not be specific to Red Hat Linux and + // similar distributions... If you're using a distribution that does + // things differently, tell me how it should be done there. + StringList files=Files::glob("/boot/*", Files::File); + for(StringList::iterator it=files.begin(); it!=files.end(); it++) { + struct stat s; + if(lstat(*it, &s)) // If we can't stat it, it can't be a kernel + continue; + if(s.st_size<131072) // if you managed to compile a kernel at less than 128k, you're cheating. ;) + continue; + if((*it).contains("System.map") || (*it).contains("initrd")) // definitely not a kernel + continue; + if((*it).contains("vmlinux")) { + // If the kernel exists both in compressed and in + // uncompressed form, ignore the uncompressed one. + String compr=(*it).replace("vmlinux", "vmlinuz"); + if(!access(compr, F_OK)) + continue; + } + String version=(*it).regex("(test-?|pre-?)?([0-9]\\.[0-9]\\.[0-9]+)(-?[0-9A-Za-z]+)*"); + String label=version; + if(version.empty()) // not a recognized kernel + version="linux"; + + if (label.empty()) + { + label = (*it); + if (label.find('/') != string::npos) + label = label.right(label.length()-1-label.rfind('/')); + } + // Check if we have an initial ramdisk (initrd) for this kernel... + String initrd1; // first guess + String initrd2; // second guess + if((*it).contains("vmlinuz")) { + initrd1=(*it).replace("vmlinux", "initrd")+".img"; + initrd2=(*it).replace("vmlinuz", "initrd.img"); + } + else if((*it).contains("vmlinux")) { + initrd1=(*it).replace("vmlinux", "initrd")+".img"; + initrd2=(*it).replace("vmlinuz", "initrd.img"); + } + else if((*it).contains("kernel")) { + initrd1=(*it).replace("kernel", "initrd")+".img"; + initrd2=(*it).replace("vmlinuz", "initrd.img"); + } + else if((*it).contains("linux")) { + initrd1=(*it).replace("linux", "initrd")+".img"; + initrd2=(*it).replace("vmlinuz", "initrd.img"); + } + else { + initrd1="/boot/initrd-"+version+".img"; + initrd2="/boot/initrd.img-"+version; + } + + String initrd = ""; + if(!access(initrd1, F_OK)) + initrd = initrd1; + else if(!access(initrd2, F_OK)) + initrd = initrd2; + + if(label.size()>15) // LILO can't handle this + if(label.contains("enterprise")) + label=label.replace("enterprise", "E"); + if(label.size()>15) + label=label.left(15); + + // label, kernel, root, initrd, optional, append, vga, readonly, + // literal, ramdisk + addLinux(label, *it, root, initrd); + } + addLinux("Linux_Compiled", "/usr/src/linux/arch/i386/boot/bzImage", root, "", true); // User-compiled kernel that wasn't moved... + + // Scan for other OSes... and Linux kernels on other partitions. + for(StringList::iterator it=p.partition.begin(); it!=p.partition.end(); it++) { + switch(p.id[*it]) { + case 0x01: // FAT12... Might be some really really old DOS. + case 0x04: // FAT16 < 32 M... Probably another old DOS. + case 0x06: // FAT16 + case 0x0b: // FAT32 + case 0x0c: // FAT32 (LBA) + case 0x0e: // FAT16 (LBA) + case 0x14: // Hidden FAT16 < 32 M... + case 0x16: // Hidden FAT16 + case 0x1b: // Hidden FAT32 + case 0x1c: // Hidden FAT32 (LBA) + case 0x1e: // Hidden FAT16 (LBA) + case 0x24: // NEC DOS + case 0x55: // EZ-Drive... I think this was some DOS tool + // to see "large" disks ages ago, so it may be + // a DOS partition... Not sure about this one. + case 0xc1: // DRDOS/sec + case 0xc4: // DRDOS/sec + case 0xc6: // DRDOS/sec + { + // Try to determine which type of DOS we're using + String mp=p.mountpt[*it]; + String lbl="DOS"; + if(mp.empty()) { + char *tmp=tmpnam(NULL); + tmp=tmpnam(NULL); + mkdir(tmp, 0700); + if(!mount(*it, tmp, "msdos", MS_MGC_VAL|MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL)) + mp=tmp; + else if(!mount(*it, mp, "vfat", MS_MGC_VAL|MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC, NULL)) + mp=tmp; + } + if(!mp.empty()) { + struct stat s; + if(stat(mp+"/ibmbio.com", &s) && stat(mp+"/io.sys", &s) && stat(mp+"/ntldr", &s)) // Doesn't look like a bootable DOS partition, ignore it + break; + if(!stat(mp+"/drdos.386", &s)) + lbl="DR-DOS"; + else if(!stat(mp+"/ntldr", &s)) + lbl="NT"; + else if(!stat(mp+"/msdos.sys", &s)) { + if(s.st_size < 4096) + /* msdos.sys is actual code in DOS, it's a config file in SuckOS */ + if(!stat(mp+"/windows/system/sfc.exe", &s)) /* This is (supposed to be?) a component of Suck98 but not Suck95 */ + lbl="Windows98"; + else + lbl="Windows95"; + } + if(p.mountpt[*it].empty()) { + umount(mp); + sync(); + rmdir(mp); + } + } + addOther(lbl, *it); + break; + } + case 0x02: // Xenix root... Does Xenix actually boot this way? + addOther("Xenix", *it); + break; + case 0x07: // HPFS or NTFS... Is there any way to check which? + // (without trying to mount them... many kernels + // support neither) + case 0x17: // Hidden HPFS or NTFS + addOther("NT", *it); + break; + case 0x09: // AIX + addOther("AIX", *it); + break; + case 0x83: // My favorite :) + case 0xfd: // Linux RAID + // TODO: scan other FSes for kernels... + break; + case 0x84: + { + // CLASH: SystemSoft MobilePRO BIOS and + // various Dell BIOSes use the same + // ID (0x84) for its hibernation partitions + // as OS/2 does for hidden C: drives. + // Fortunately, hibernation partitions are easy to + // recognize... + int fd=open(*it, O_RDONLY); + char *header=(char *) malloc(20); + read(fd, header, 20); + close(fd); + if(strncmp(header, "SystemSoft", 10)==0) // It's a hibernation partition + break; + else if(strncmp(header+3, "Dell Suspend", 12)==0) { // It's a Dell hibernation partition + // Dell BIOSes are ultimately buggy: They don't do resume-from-disk + // properly. + // Hibernation partitions are bootable and need to be loaded by the + // boot manager instead. + addOther("SuspendToDisk", *it); + break; + } + addOther("OS2", *it, false, "/boot/os2_d.b"); + } + case 0x0a: // OS/2 Boot Manager + addOther("OS2", *it, false, "/boot/os2_d.b"); + break; + case 0x10: // OPUS... (what is that?) + addOther("OPUS", *it); + break; + case 0x3c: // Partition Magic + addOther("PartitionMagic", *it); + break; + case 0x40: // Venix 80286 + addOther("Venix", *it); + break; + case 0x4d: // QNX + addOther("QNX", *it); + break; + case 0x52: // CP/M (does anyone dual-boot between CP/M and + // Linux? Would be interesting to see. ;) ) + case 0xdb: // CP/M/CTOS + addOther("CPM", *it); + break; + case 0x63: // GNU/Hurd + addOther("GNU_Hurd", *it); + break; + case 0x64: // Novell Netware + case 0x65: // Novell Netware + addOther("Netware", *it); + break; + case 0x75: // PC/IX (what is that?) + addOther("PCIX", *it); + break; + case 0x80: // Old Minix + case 0x81: // Minix and some VERY old Linux kernels + addOther("Minix", *it); + break; + case 0x9f: // BSD/OS + case 0xb7: // BSDI + addOther("BSD_OS", *it); + break; + case 0xa5: // Some BSDs... Is there any way to determine which + // one? + addOther("BSD", *it); + break; + case 0xa6: // OpenBSD + addOther("OpenBSD", *it); + break; + case 0xa7: // NeXTSTEP + addOther("NeXT", *it); + break; + case 0xc7: // Syrinx (what is that?) + addOther("Syrinx", *it); + break; + case 0xeb: // BeOS + addOther("BeOS", *it); + break; + case 0xfe: // LANstep (what is that?) + addOther("LANstep", *it); + break; + case 0xff: // BBT (what is that?) + addOther("BBT", *it); + break; + } + } + // addOther("floppy", "/dev/fd0", true); + //Would be nice, but LILO can't handle an optional + //other=nonexistantdevice entry ATM. + return true; +} +void liloconf::addLinux(String const &label, String const &kernel, String const &root, String const &initrd, bool optional, String const &append, String const &vga, bool readonly, String const &literal, String const &ramdisk) +{ + liloimage *lx_image=new liloimage; + *lx_image += "image="+kernel; + *lx_image += "\tlabel=\""+label+"\""; + if(!root.empty()) + *lx_image += "\troot="+root; + if(readonly) + *lx_image += "\tread-only"; + else + *lx_image += "\tread-write"; + if(!initrd.empty()) + *lx_image += "\tinitrd=\""+initrd+"\""; + if(!append.empty()) + *lx_image += "\tappend=\""+append+"\""; + if(!vga.empty()) + *lx_image += "\tvga=\""+vga+"\""; + if(!literal.empty()) + *lx_image += "\tliteral=\""+literal+"\""; + if(!ramdisk.empty()) + *lx_image += "\tramdisk=\""+ramdisk+"\""; + if(optional) + *lx_image += "\toptional"; + images.insert(images.end(), *lx_image); +} +void liloconf::addOther(String const &name, String const &partition, bool const &optional, String const &chain) +{ + liloimage *other=new liloimage; + *other += "other="+partition; + *other += "\tlabel=\""+name+"\""; + if(optional) + *other += "\toptional"; + if(!chain.empty()) + *other += "\tloader="+chain+"\""; + images.insert(images.end(), *other); +} +void liloconf::remove(String const &label) +{ + String t = String::escapeForRegExp(label); + + String regex="[ \t]*label[ \t]*=[ \t]*\"?"+t+"\"?[ \t]*"; + for(liloimages::iterator it=images.begin(); it!=images.end(); it++) { + if(!(*it).grep(regex).empty()) { + images.erase(it); + break; + } + } +} +void liloconf::removeKernel(String const &kernel) +{ + String t = String::escapeForRegExp(kernel); + + String regex="[ \t]*(image|other)[ \t]*=[ \t]*\"?"+t+"\"?[ \t]*"; + for(liloimages::iterator it=images.begin(); it!=images.end(); it++) { + if(!(*it).grep(regex).empty()) { + images.erase(it); + break; + } + } +} +StringList const &liloconf::entries() const +{ + StringList *s=new StringList; + for(liloimages::const_iterator it=images.begin(); it!=images.end(); it++) { + String lbl=(*it).grep("[ \t]*label[ \t]*=.*"); + lbl=lbl.mid(lbl.locate("label")+6); + while(isspace(lbl.chr(0)) || lbl.chr(0)=='=' || lbl.chr(0)=='\"') + lbl=lbl.mid(2); + while(isspace(lbl.right().chr(0)) || lbl.right()==(String)"\"") + lbl=lbl.left(lbl.size()-1); + s->add(lbl); + } + return *s; +} +String const liloconf::dflt() const +{ + String dflt=""; + for(StringList::const_iterator it=defaults.begin(); it!=defaults.end() && dflt.empty(); it++) + if(!((*it).regex("^[ \t]*default[ \t]*=")).empty()) + dflt=(*it).simplifyWhiteSpace(); + if(dflt.empty()) { + liloimages::const_iterator it=images.begin(); + if (it != images.end()) + dflt=(*it).grep("^[ \t]*label[ \t]*=").simplifyWhiteSpace(); + } + if(!dflt.empty()) { + dflt=dflt.mid(dflt.locate("=")+2).simplifyWhiteSpace(); + if(dflt.left()==(String)"\"") + dflt=dflt.mid(2).simplifyWhiteSpace(); + if(dflt.right()==(String)"\"") + dflt=dflt.left(dflt.size()-1).simplifyWhiteSpace(); + } + return dflt; +} +void liloconf::setDefault(String const &dflt) +{ + bool ready=false; + for(StringList::const_iterator it=defaults.begin(); !ready && it!=defaults.end(); it++) + if(!((*it).regex("^[ \t]*default[ \t]*=")).empty()) { + defaults.remove(*it); + ready=true; + } + defaults+="default=" + dflt; +} +liloconf::operator String() const +{ + String s=defaults; + s+="\n"; + for(liloimages::const_iterator it=images.begin(); it!=images.end(); it++) { + s+=*it; + s+="\n"; + } + return s; +} + +ostream &operator <<(ostream &os, liloconf const &l) +{ + os << l.defaults << endl; + for(liloimages::const_iterator it=l.images.begin(); it!=l.images.end(); it++) + os << *it << endl; + return os; +} +ostream &operator <<(ostream &os, liloconf const *l) +{ + os << l->defaults << endl; + for(liloimages::const_iterator it=l->images.begin(); it!=l->images.end(); it++) + os << *it << endl; + return os; +} diff --git a/lilo-config/common/lilo.h b/lilo-config/common/lilo.h new file mode 100644 index 0000000..c992df0 --- /dev/null +++ b/lilo-config/common/lilo.h @@ -0,0 +1,77 @@ +/* lilo.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by A. Seigo and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _LILO_H_ +#define _LILO_H_ 1 +#include "Config.h" +#include <iostream> + +class liloimage:public ConfigFile { +public: + bool isLinux() const; +}; + +class liloimages:public std::list<liloimage> { +public: + void remove(String const &s); + liloimage *find(String const &s) const; + liloimage *operator[](String const &s) const { return find(s); } +}; + +class liloconf { + friend std::ostream &operator <<(std::ostream &os, liloconf const &l); + friend std::ostream &operator <<(std::ostream &os, liloconf const *l); +public: + liloconf(String const &filename="/etc/lilo.conf"); + void set(StringList const &s); + void set(String const &s); + void writeFile(String const &filename); + bool const isOk(); + String const liloOut(); + bool install(bool probeonly=false); + bool probe(); + void addLinux(String const &label, String const &kernel, String const &root="", String const &initrd="", bool optional=false, String const &append="", String const &vga="", bool readonly=true, String const &literal="", String const &ramdisk=""); + void addOther(String const &name, String const &partition, bool const &optional=false, String const &chain=""); + void remove(String const &label); + void removeKernel(String const &kernel); + StringList const &entries() const; + String const dflt() const; + void setDefault(String const &dflt); + operator String() const; +protected: + void check() { install(true); } + bool ok; + String output; +public: + bool checked; + ConfigFile defaults; + liloimages images; +}; +std::ostream &operator <<(std::ostream &os, liloconf const &l); +std::ostream &operator <<(std::ostream &os, liloconf const *l); +#endif diff --git a/lilo-config/common/tests/Makefile.am b/lilo-config/common/tests/Makefile.am new file mode 100644 index 0000000..8059a44 --- /dev/null +++ b/lilo-config/common/tests/Makefile.am @@ -0,0 +1,9 @@ +String_LDADD = ../.libs/libcommon.a +noinst_PROGRAMS = String +INCLUDES = -I.. $(all_includes) + +String_SOURCES = \ + String.cc + +messages: + diff --git a/lilo-config/common/tests/String.cc b/lilo-config/common/tests/String.cc new file mode 100644 index 0000000..7b0b60e --- /dev/null +++ b/lilo-config/common/tests/String.cc @@ -0,0 +1,77 @@ +/* +** +** Copyright (C) 2000 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ + +using namespace std; + +#include <String.h> +int main(int argc, char **argv) +{ + int bugs=0; + String s="Microsoft sucks! Red Hat doesn't suck!"; + String t="Microsoft sucks! Destroy Microsoft! Microsoft must die!"; + String u="Microsoft sucks!"; + if(s.left(16)!="Microsoft sucks!") { + cerr << "left() seems to be broken." << endl; + bugs++; + } + if(s.right(21) != "Red Hat doesn't suck!") { + cerr << "right() seems to be broken." << endl; + bugs++; + } + if(s.mid(18) != 'R') { + cerr << "mid() with one parameter seems to be broken." << endl; + bugs++; + } + if(s.mid(18, 7) != "Red Hat") { + cerr << "mid() with 2 parameters seems to be broken." << endl; + bugs++; + } + if(s.regex("Red ?[Hh]at|RED ?HAT")!="Red Hat") { + cerr << "regex() seems to be broken." << endl; + bugs++; + } + if(!s.contains("Red Hat")) { + cerr << "contains() seems to be broken." << endl; + bugs++; + } + if(t.replace("Microsoft", "Windows", false) != "Windows sucks! Destroy Microsoft! Microsoft must die!") { + cerr << "replace() [once] seems to be broken." << endl; + bugs++; + } + if(t.replace("Microsoft", "Windows") != "Windows sucks! Destroy Windows! Windows must die!") { + cerr << "replace() [all] seems to be broken." << endl; + bugs++; + } + if(u.replace("Microsoft", "Windows") != "Windows sucks!") { + cerr << "replace() [all, test case 2] seems to be broken." << endl; + bugs++; + } + + if(bugs==0) + cout << "No bugs in String class detected." << endl; + return bugs; +} diff --git a/lilo-config/configure.in.in b/lilo-config/configure.in.in new file mode 100644 index 0000000..6f608f7 --- /dev/null +++ b/lilo-config/configure.in.in @@ -0,0 +1,5 @@ +KDE_FIND_PATH(lilo, LILO, [/sbin /usr/sbin /usr/local/sbin /opt/lilo], +[ + DO_NOT_COMPILE="$DO_NOT_COMPILE lilo-config" +]) + diff --git a/lilo-config/kde-qt-common/EditWidget.cpp b/lilo-config/kde-qt-common/EditWidget.cpp new file mode 100644 index 0000000..fad957a --- /dev/null +++ b/lilo-config/kde-qt-common/EditWidget.cpp @@ -0,0 +1,81 @@ +/* EditWidget.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "EditWidget.moc" +#include "ui.h" +EditWidget::EditWidget(QString const label, QString const text, bool isFile, QWidget *parent, const char *name, WFlags f, bool allowLines):QHBox(allowLines, parent, name, f) +{ + setMargin(SPACE_MARGIN); + setSpacing(SPACE_INSIDE); + lbl=new QLabel(label, this); + setStretchFactor(lbl, 0); + line=new QLineEdit(text, this); + setStretchFactor(line, 1); + connect(line, SIGNAL(textChanged(const QString &)), SIGNAL(textChanged(const QString &))); + connect(line, SIGNAL(returnPressed()), SIGNAL(returnPressed())); + lbl->setBuddy(line); + if(isFile) { + select=new QPushButton(_("Select..."), this); + connect(select, SIGNAL(clicked()), SLOT(selectFileClicked())); + select->resize(select->minimumSizeHint()); + setStretchFactor(select, 0); + } else + select=0; +} +void EditWidget::selectFileClicked() +{ + QString filename=FileDlg::getOpenFileName(QString::null, QString::null, this); + if(!filename.isEmpty()) + line->setText(filename); +} +QSize EditWidget::sizeHint() const +{ + int w=2*SPACE_MARGIN+lbl->sizeHint().width()+SPACE_INSIDE+line->sizeHint().width(); + int h=lbl->sizeHint().height(); + if(h<line->sizeHint().height()) + h=line->sizeHint().height(); + if(select!=0) { + w+=SPACE_INSIDE+select->sizeHint().width(); + if(h<select->sizeHint().height()) + h=select->sizeHint().height(); + } + return QSize(w, h); +} +QSize EditWidget::minimumSizeHint() const +{ + int w=2*SPACE_MARGIN+lbl->minimumSizeHint().width()+SPACE_INSIDE+line->minimumSizeHint().width(); + int h=lbl->minimumSizeHint().height(); + if(h<line->minimumSizeHint().height()) + h=line->minimumSizeHint().height(); + if(select!=0) { + w+=SPACE_INSIDE+select->minimumSizeHint().width(); + if(h<select->minimumSizeHint().height()) + h=select->minimumSizeHint().height(); + } + return QSize(w, h); +} diff --git a/lilo-config/kde-qt-common/EditWidget.h b/lilo-config/kde-qt-common/EditWidget.h new file mode 100644 index 0000000..515c65e --- /dev/null +++ b/lilo-config/kde-qt-common/EditWidget.h @@ -0,0 +1,92 @@ +/* EditWidget.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _EDITWIDGET_H_ +#define _EDITWIDGET_H_ 1 +#include <qhbox.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qpushbutton.h> +class EditWidget:public QHBox +{ + Q_OBJECT +public: + EditWidget(QString const label="", QString const text="", bool isFile=false, QWidget *parent=0, const char *name=0, WFlags f=0, bool allowLines=true); + void setLabel(QString const &label) { lbl->setText(label); }; + QString text() const { return line->text(); }; + QString displayText() const { return line->displayText(); }; + int maxLength() const { return line->maxLength(); }; + virtual void setMaxLength(int l) { line->setMaxLength(l); }; + virtual void setFrame(bool b) { line->setFrame(b); }; + bool frame() const { return line->frame(); }; + virtual void setEchoMode(QLineEdit::EchoMode e) { line->setEchoMode(e); }; + QLineEdit::EchoMode echoMode() const { return line->echoMode(); }; + void setReadOnly(bool b) const { line->setReadOnly(b); }; + bool isReadOnly() const { return line->isReadOnly(); }; + virtual void setValidator(const QValidator *v) { line->setValidator(v); }; + const QValidator *validator() const { return line->validator(); }; + virtual void setSelection(int s, int e) { line->setSelection(s, e); }; + virtual void setCursorPosition(int p) { line->setCursorPosition(p); }; + int cursorPosition() const { return line->cursorPosition(); }; + bool validateAndSet(const QString &s, int a, int b, int c) { return line->validateAndSet(s, a, b, c); }; + void cut() { line->cut(); }; + void copy() const { line->copy(); }; + void paste() { line->paste(); }; + void setAlignment(int flag) { line->setAlignment(flag); }; + int alignment() const { return line->alignment(); }; + void cursorLeft(bool mark, int steps=1) { line->cursorLeft(mark, steps); }; + void cursorRight(bool mark, int steps=1) { line->cursorRight(mark, steps); }; + void cursorWordForward(bool mark) { line->cursorWordForward(mark); }; + void cursorWordBackward(bool mark) { line->cursorWordBackward(mark); }; + void backspace() { line->backspace(); }; + void del() { line->del(); }; + void home(bool mark) { line->home(mark); }; + void end(bool mark) { line->end(mark); }; + void setEdited(bool e) { line->setEdited(e); }; + bool edited() const { return line->edited(); }; + bool hasMarkedText() const { return line->hasMarkedText(); }; + QString markedText() const { return line->markedText(); }; + virtual QSize sizeHint() const; + virtual QSize minimumSizeHint() const; +public slots: + virtual void setText(const QString &text) { line->setText(text); }; + void selectAll() { line->selectAll(); }; + void deselect() { line->deselect(); }; + void clearValidator() { line->clearValidator(); }; + void insert(const QString &s) { line->insert(s); }; + void clear() { line->clear(); }; + void selectFileClicked(); +signals: + void textChanged(const QString &); + void returnPressed(); +private: + QLabel *lbl; + QLineEdit *line; + QPushButton *select; +}; +#endif diff --git a/lilo-config/kde-qt-common/Makefile.am b/lilo-config/kde-qt-common/Makefile.am new file mode 100644 index 0000000..f5b57eb --- /dev/null +++ b/lilo-config/kde-qt-common/Makefile.am @@ -0,0 +1,14 @@ +AM_CXXFLAGS = -DUSE_KDE +INCLUDES= -I$(srcdir)/../common -I$(srcdir)/.. -I. $(all_includes) + +noinst_LTLIBRARIES=libwidgets.la + +libwidgets_la_SOURCES = \ + mainwidget.cpp general.cpp images.cpp expert.cpp \ + EditWidget.cpp +libwidgets_la_LIBADD = $(LIB_QT) ../common/libcommon.la +libwidgets_la_METASOURCES = AUTO + +noinst_HEADERS = \ + mainwidget.h ui.h general.h images.h expert.h \ + EditWidget.h diff --git a/lilo-config/kde-qt-common/expert.cpp b/lilo-config/kde-qt-common/expert.cpp new file mode 100644 index 0000000..dea58e9 --- /dev/null +++ b/lilo-config/kde-qt-common/expert.cpp @@ -0,0 +1,63 @@ +/* expert.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "expert.moc" +#include <ui.h> +#include <qwhatsthis.h> +#include <String.h> +#include <strstream> +Expert::Expert(liloconf *l, QWidget *parent, const char *name):QWidget(parent, name) +{ + lilo=l; + layout=new QHBoxLayout(this); + edit=new QMultiLineEdit(this); + layout->addWidget(edit); + connect(edit, SIGNAL(textChanged()), SIGNAL(configChanged())); + QWhatsThis::add(edit, _("You can edit the lilo.conf file directly here. All changes you make here are automatically transferred to the graphical interface.")); + update(); +} +Expert::~Expert() +{ + delete edit; +} +void Expert::update() +{ + bool blocked = signalsBlocked(); + blockSignals(true); + edit->setText(((String)*lilo).cstr()); + blockSignals(blocked); +} +void Expert::saveChanges() +{ + lilo->set(edit->text().latin1()); +} + +void Expert::makeReadOnly() +{ + edit->setEnabled( false ); +} diff --git a/lilo-config/kde-qt-common/expert.h b/lilo-config/kde-qt-common/expert.h new file mode 100644 index 0000000..d9d6afb --- /dev/null +++ b/lilo-config/kde-qt-common/expert.h @@ -0,0 +1,53 @@ +/* expert.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _EXPERT_H_ +#define _EXPERT_H_ 1 +#include <lilo.h> +#include <qwidget.h> +#include <qmultilineedit.h> +#include <qlayout.h> +class Expert:public QWidget +{ + Q_OBJECT +public: + Expert(liloconf *l=0, QWidget *parent=0, const char *name=0); + ~Expert(); + void setCfg(liloconf *l) { lilo=l; }; + void makeReadOnly(); +public slots: + void update(); + void saveChanges(); +signals: + void configChanged(); +private: + liloconf *lilo; + QHBoxLayout *layout; + QMultiLineEdit *edit; +}; +#endif diff --git a/lilo-config/kde-qt-common/general.cpp b/lilo-config/kde-qt-common/general.cpp new file mode 100644 index 0000000..7944409 --- /dev/null +++ b/lilo-config/kde-qt-common/general.cpp @@ -0,0 +1,229 @@ +/* general.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "general.moc" +#include "EditWidget.h" +#include <Disks.h> +#include <qlayout.h> +#include <ui.h> +#include <qwhatsthis.h> + +#include <stdlib.h> + +General::General(liloconf *l, QWidget *parent, const char *name):QWidget(parent, name) +{ + lilo=l; + QVBoxLayout *layout=new QVBoxLayout(this); + layout->setMargin(SPACE_MARGIN); + layout->setSpacing(SPACE_INSIDE); + QHBox *drv=new QHBox(this); + QLabel *drive_lbl=new QLabel(_("Install &boot record to drive/partition:"), drv); + drive=new QComboBox(false, drv); + drive_lbl->setBuddy(drive); + StringList p=ptable::disklist(); + p+=ptable::partlist(); + p.sort(); + for(StringList::const_iterator it=p.begin(); it!=p.end(); it++) + drive->insertItem((*it).cstr()); + connect(drive, SIGNAL(activated(int)), SIGNAL(configChanged())); + layout->addWidget(drv); + QWhatsThis::add(drv, _("Select the drive or partition you want to install the LILO boot loader to here. Unless you intend to use other boot managers in addition to LILO, this should be the MBR (master boot record) of your boot drive.<br>In this case, you should probably select <i>/dev/hda</i> if your boot drive is an IDE drive or <i>/dev/sda</i> if your boot drive is SCSI.")); + + QHBox *to=new QHBox(this); + QLabel *to_lbl=new QLabel(_("Boot the default kernel/OS &after:"), to); + timeout=new QSpinBox(0, 1000000, 1, to); + timeout->setSuffix(_("/10 seconds")); + connect(timeout, SIGNAL(valueChanged(int)), SIGNAL(configChanged())); + to_lbl->setBuddy(timeout); + layout->addWidget(to); + QWhatsThis::add(to, _("LILO will wait the amount of time specified here before booting the kernel (or OS) marked as <i>default</i> in the <b>Images</b> tab.")); + + QHBox *modes=new QHBox(this); + linear=new QCheckBox(_("Use &linear mode"), modes); + connect(linear, SIGNAL(clicked()), SIGNAL(configChanged())); + QWhatsThis::add(linear, _("Check this box if you want to use the linear mode.<br>Linear mode tells the boot loader the location of kernels in linear addressing rather than sector/head/cylinder.<br>linear mode is required for some SCSI drives, and shouldn't hurt unless you're planning to create a boot disk to be used with a different computer.<br>See the lilo.conf man page for details.")); + compact=new QCheckBox(_("Use &compact mode"), modes); + connect(compact, SIGNAL(clicked()), SIGNAL(configChanged())); + QWhatsThis::add(compact, _("Check this box if you want to use the compact mode.<br>The compact mode tries to merge read requests for adjacent sectors into a single read request. This reduces load time and keeps the boot map smaller, but will not work on all systems.")); + layout->addWidget(modes); + + QHBox *opts=new QHBox(this); + lock=new QCheckBox(_("&Record boot command lines for defaults"), opts); + connect(lock, SIGNAL(clicked()), SIGNAL(configChanged())); + QWhatsThis::add(lock, "<qt>"+_("Checking this box enables automatic recording of boot command lines as the defaults for the following boots. This way, lilo \"locks\" on a choice until it is manually overridden.\nThis sets the <b>lock</b> option in lilo.conf.")); + restricted=new QCheckBox(_("R&estrict parameters"), opts); + connect(restricted, SIGNAL(clicked()), SIGNAL(configChanged())); + connect(restricted, SIGNAL(clicked()), SLOT(check_pw())); + QWhatsThis::add(restricted, _("If this box is checked, a password (entered below) is required only if any parameters are changed (i.e. the user can boot <i>linux</i>, but not <i>linux single</i> or <i>linux init=/bin/sh</i>).\nThis sets the <b>restricted</b> option in lilo.conf.<br>This sets a default for all Linux kernels you want to boot. If you need a per-kernel setting, go to the <i>Operating systems</i> tab and select <i>Details</i>.")); + layout->addWidget(opts); + + QHBox *pw=new QHBox(this); + use_password=new QCheckBox(_("Require &password:"), pw); + connect(use_password, SIGNAL(clicked()), SIGNAL(configChanged())); + connect(use_password, SIGNAL(clicked()), SLOT(check_pw())); + password=new QLineEdit(pw); + password->setMaxLength(15); + password->setEchoMode(QLineEdit::Password); + connect(password, SIGNAL(textChanged(const QString &)), SIGNAL(configChanged())); + QWhatsThis::add(pw, _("Enter the password required for bootup (if any) here. If <i>restricted</i> above is checked, the password is required for additional parameters only.<br><b>WARNING:</b> The password is stored in clear text in /etc/lilo.conf. You'll want to make sure nobody untrusted can read this file. Also, you probably don't want to use your normal/root password here.<br>This sets a default for all Linux kernels you want to boot. If you need a per-kernel setting, go to the <i>Operating systems</i> tab and select <i>Details</i>.")); + layout->addWidget(pw); + + QHBox *vgab=new QHBox(this); + QLabel *vlbl=new QLabel(_("&Default graphics mode on text console:"), vgab); + vga=new QComboBox(false, vgab); + vlbl->setBuddy(vga); + QWhatsThis::add(vgab, _("You can select the default graphics mode here.<br>If you intend to use a VGA graphics mode, you must compile the kernel with support for framebuffer devices. The <i>ask</i> setting brings up a prompt at boot time.<br>This sets a default for all Linux kernels you want to boot. If you need a per-kernel setting, go to the <i>Operating systems</i> tab and select <i>Details</i>.")); + vga->insertItem(_("default")); + vga->insertItem(_("ask")); + vga->insertItem(_("text 80x25 (0)")); + vga->insertItem(_("text 80x50 (1)")); + vga->insertItem(_("text 80x43 (2)")); + vga->insertItem(_("text 80x28 (3)")); + vga->insertItem(_("text 80x30 (4)")); + vga->insertItem(_("text 80x34 (5)")); + vga->insertItem(_("text 80x60 (6)")); + vga->insertItem(_("text 40x25 (7)")); + vga->insertItem(_("VGA 640x480, 256 colors (769)")); + vga->insertItem(_("VGA 640x480, 32767 colors (784)")); + vga->insertItem(_("VGA 640x480, 65536 colors (785)")); + vga->insertItem(_("VGA 640x480, 16.7M colors (786)")); + vga->insertItem(_("VGA 800x600, 256 colors (771)")); + vga->insertItem(_("VGA 800x600, 32767 colors (787)")); + vga->insertItem(_("VGA 800x600, 65536 colors (788)")); + vga->insertItem(_("VGA 800x600, 16.7M colors (789)")); + vga->insertItem(_("VGA 1024x768, 256 colors (773)")); + vga->insertItem(_("VGA 1024x768, 32767 colors (790)")); + vga->insertItem(_("VGA 1024x768, 65536 colors (791)")); + vga->insertItem(_("VGA 1024x768, 16.7M colors (792)")); + vga->insertItem(_("VGA 1280x1024, 256 colors (775)")); + vga->insertItem(_("VGA 1280x1024, 32767 colors (793)")); + vga->insertItem(_("VGA 1280x1024, 65536 colors (794)")); + vga->insertItem(_("VGA 1280x1024, 16.7M colors (795)")); + connect( vga, SIGNAL(activated ( int )), SIGNAL(configChanged())); + layout->addWidget(vgab); + + prompt=new QCheckBox(_("Enter LILO &prompt automatically"), this); + QWhatsThis::add(prompt, _("If this box is checked, LILO goes to the LILO prompt whether or not a key is pressed. If it is turned off, LILO boots the default operating system unless shift is pressed (in that case, it goes to the LILO prompt).<br>This sets the <i>prompt</i> option in lilo.conf.")); + connect(prompt, SIGNAL(clicked()), SIGNAL(configChanged())); + + layout->addWidget(prompt); + + update(); +} +void General::saveChanges() +{ + QString to; + to.sprintf("%u", timeout->value()); + QString boot = drive->currentText(); + lilo->defaults.set("boot", boot.isEmpty() ? "" : boot.latin1()); + lilo->defaults.set("timeout", to.latin1()); + if(compact->isChecked() && lilo->defaults.grep("^[ \t]*compact[ \t]*$").empty()) + lilo->defaults += "compact"; + else if(!compact->isChecked() && !lilo->defaults.grep("^[ \t]*compact[ \t]*$").empty()) + lilo->defaults.remove(lilo->defaults.grep("^[ \t]*compact[ \t]*$")); + if(linear->isChecked() && lilo->defaults.grep("^[ \t]*linear[ \t]*$").empty()) + lilo->defaults += "linear"; + else if(!linear->isChecked() && !lilo->defaults.grep("^[ \t]*linear[ \t]*$").empty()) + lilo->defaults.remove(lilo->defaults.grep("^[ \t]*linear[ \t]*$")); + if(lock->isChecked() && lilo->defaults.grep("^[ \t]*lock[ \t]*$").empty()) + lilo->defaults += "lock"; + else if(!lock->isChecked() && !lilo->defaults.grep("^[ \t]*lock[ \t]*$").empty()) + lilo->defaults.remove(lilo->defaults.grep("^[ \t]*lock[ \t]*$")); + if(restricted->isChecked() && lilo->defaults.grep("^[ \t]*restricted[ \t]*$").empty()) + lilo->defaults += "restricted"; + else if(!restricted->isChecked() && !lilo->defaults.grep("^[ \t]*restricted[ \t]*$").empty()) + lilo->defaults.remove(lilo->defaults.grep("^[ \t]*restricted[ \t]*$")); + if(restricted->isChecked() || use_password->isChecked()) + lilo->defaults.set("password", password->text().latin1()); + else + lilo->defaults.remove(lilo->defaults.grep("^[ \t]*password[ \t]*=.*")); + if(vga->currentText()=="default") { + if(!lilo->defaults.grep("[ \t]*vga[ \t]*=").empty()) + lilo->defaults.remove(lilo->defaults.grep("[ \t]*vga[ \t]*=")); + } else { + QString mode=vga->currentText(); + if(mode!="ask") { + mode=mode.mid(mode.find('(')+1); + mode=mode.left(mode.length()-1); + } + lilo->defaults.set("vga", mode.latin1()); + } + if(prompt->isChecked() && lilo->defaults.grep("^[ \t]*prompt[ \t]*$").empty()) + lilo->defaults += "prompt"; + else if(!prompt->isChecked() && !lilo->defaults.grep("^[ \t]*prompt[ \t]*$").empty()) + lilo->defaults.remove(lilo->defaults.grep("^[ \t]*prompt[ \t]*$")); +} +void General::update() +{ + QString boot=lilo->defaults.get("boot").cstr(); + for(int i=0; i<drive->count(); i++) + if(drive->text(i)==boot) + drive->setCurrentItem(i); + timeout->setValue(atoi(lilo->defaults.get("timeout"))); + compact->setChecked(!lilo->defaults.grep("^[ \t]*compact[ \t]*$").empty()); + linear->setChecked(!lilo->defaults.grep("^[ \t]*linear[ \t]*$").empty()); + lock->setChecked(!lilo->defaults.grep("^[ \t]*lock[ \t]*$").empty()); + restricted->setChecked(!lilo->defaults.grep("^[ \t]*restricted[ \t]*$").empty()); + String pw=lilo->defaults.grep("^[ \t]*password[ \t]*=.*"); + use_password->setChecked(!pw.empty()); + if(!pw.empty()) + password->setText(lilo->defaults.get("password").cstr()); + check_pw(); + QString mode=lilo->defaults.get("vga", "").cstr(); + if(mode.isEmpty()) + vga->setCurrentItem(0); + else if(mode=="ask") + vga->setCurrentItem(1); + else + for(int i=0; i<vga->count(); i++) { + if(vga->text(i).contains("(" + mode + ")")) { + vga->setCurrentItem(i); + break; + } + } + prompt->setChecked(!lilo->defaults.grep("^[ \t]*prompt[ \t]*$").empty()); +} +void General::check_pw() +{ + password->setEnabled(restricted->isChecked() || use_password->isChecked()); +} + +void General::makeReadOnly() +{ + drive->setEnabled( false ); + timeout->setEnabled( false ); + linear->setEnabled( false ); + compact->setEnabled( false ); + lock->setEnabled( false ); + restricted->setEnabled( false ); + use_password->setEnabled( false ); + password->setEnabled( false ); + vga->setEnabled( false ); + prompt->setEnabled( false ); + +} diff --git a/lilo-config/kde-qt-common/general.h b/lilo-config/kde-qt-common/general.h new file mode 100644 index 0000000..7e88a90 --- /dev/null +++ b/lilo-config/kde-qt-common/general.h @@ -0,0 +1,62 @@ +/* general.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _GENERAL_H_ +#define _GENERAL_H_ 1 +#include <lilo.h> +#include <qwidget.h> +#include <qcombobox.h> +#include <qspinbox.h> +#include <qcheckbox.h> +class General:public QWidget +{ + Q_OBJECT +public: + General(liloconf *l=0, QWidget *parent=0, const char *name=0); + void makeReadOnly(); +signals: + void configChanged(); +public slots: + void saveChanges(); + void update(); +private slots: + void check_pw(); +private: + liloconf *lilo; + QComboBox *drive; + QSpinBox *timeout; + QCheckBox *linear; + QCheckBox *compact; + QCheckBox *lock; + QCheckBox *restricted; + QCheckBox *use_password; + QLineEdit *password; + QComboBox *vga; + QCheckBox *prompt; +}; +#endif diff --git a/lilo-config/kde-qt-common/images.cpp b/lilo-config/kde-qt-common/images.cpp new file mode 100644 index 0000000..98dd1cb --- /dev/null +++ b/lilo-config/kde-qt-common/images.cpp @@ -0,0 +1,334 @@ +/* images.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "images.moc" +#include <ui.h> +#include <qwhatsthis.h> +#include <qregexp.h> +#include <qstring.h> + +#ifdef USE_KDE +#include "kde/InputBox.h" +#include "kde/Details.h" +#else +#include "qt/InputBox.h" +#include "qt/Details.h" +#endif + +Images::Images(liloconf *l, QWidget *parent, const char *name):QWidget(parent, name) +{ + current=""; previous=""; // Using QString::null gives problems! + lilo=l; + layout=new QHBoxLayout(this); + layout->setMargin(SPACE_MARGIN); + layout->setSpacing(SPACE_INSIDE); + images=new QListBox(this); + layout->addWidget(images, 1); + connect(images, SIGNAL(highlighted(const QString &)), SLOT(imageSelected(const QString &))); + QWhatsThis::add(images, _("This is the list of kernels and operating systems you can currently boot. Select which one you want to edit here.")); + + parameters=new QVBox(this); + parameters->setMargin(SPACE_MARGIN); + parameters->setSpacing(SPACE_INSIDE); + layout->addWidget(parameters, 2); + image=new EditWidget(_("&Kernel:"), "", true, parameters); + QWhatsThis::add(image, _("Enter the filename of the kernel you want to boot here.")); + connect(image, SIGNAL(textChanged(const QString &)), this, SIGNAL(configChanged())); + label=new EditWidget(_("&Label:"), "", false, parameters); + QWhatsThis::add(label, _("Enter the label (name) of the kernel you want to boot here.")); + connect(label, SIGNAL(textChanged(const QString &)), this, SIGNAL(configChanged())); + root=new EditWidget(_("&Root filesystem:"), "", true, parameters); + QWhatsThis::add(root, _("Enter the root filesystem (i.e. the partition that will be mounted as / at boot time) for the kernel you want to boot here.")); + connect(root, SIGNAL(textChanged(const QString &)), this, SIGNAL(configChanged())); + initrd=new EditWidget(_("&Initial ramdisk:"), "", true, parameters); + QWhatsThis::add(initrd, _("If you want to use an initial ramdisk (initrd) for this kernel, enter its filename here. Leave this field blank if you don't intend to use an initial ramdisk for this kernel.")); + connect(initrd, SIGNAL(textChanged(const QString &)), this, SIGNAL(configChanged())); + append=new EditWidget(_("E&xtra parameters:"), "", false, parameters); + QWhatsThis::add(append, _("Enter any extra parameters you wish to pass to the kernel here. Usually, this can be left blank.<br>This sets the <i>append</i> option in lilo.conf.")); + connect(append, SIGNAL(textChanged(const QString &)), this, SIGNAL(configChanged())); + + actions=new QVBox(this); + actions->setMargin(SPACE_MARGIN); + actions->setSpacing(SPACE_INSIDE); + layout->addWidget(actions); + dflt=new QPushButton(_("Set &Default"), actions); + QWhatsThis::add(dflt, _("Boot this kernel/OS if the user doesn't make a different choice")); + connect(dflt, SIGNAL(clicked()), SLOT(dfltClicked())); + details=new QPushButton(_("De&tails"), actions); + QWhatsThis::add(details, _("This button brings up a dialog box with further, less commonly used, options.")); + connect(details, SIGNAL(clicked()), SLOT(detailsClicked())); + probe=new QPushButton(_("&Probe"), actions); + connect(probe, SIGNAL(clicked()), SLOT(probeClicked())); + QWhatsThis::add(probe, _("Automatically generate a (hopefully) reasonable lilo.conf for your system")); + check=new QPushButton(_("&Check Configuration"), actions); + connect(check, SIGNAL(clicked()), SLOT(checkClicked())); + QWhatsThis::add(check, _("Run LILO in test mode to see if the configuration is ok")); + addKrnl=new QPushButton(_("Add &Kernel..."), actions); + connect(addKrnl, SIGNAL(clicked()), SLOT(addKrnlClicked())); + QWhatsThis::add(addKrnl, _("Add a new Linux kernel to the boot menu")); + addOS=new QPushButton(_("Add Other &OS..."), actions); + connect(addOS, SIGNAL(clicked()), SLOT(addOSClicked())); + QWhatsThis::add(addOS, _("Add a non-Linux OS to the boot menu")); + remove=new QPushButton(_("&Remove Entry"), actions); + connect(remove, SIGNAL(clicked()), SLOT(removeClicked())); + QWhatsThis::add(remove, _("Remove entry from the boot menu")); + update(); +} +Images::~Images() +{ + delete probe; +} +void Images::update() // SLOT +{ + int selection=images->currentItem(); + if(selection==-1) selection=0; + String dflt=lilo->dflt(); + String entry; + StringList imgs=lilo->entries(); + images->clear(); + for(StringList::const_iterator it=imgs.begin(); it!=imgs.end(); it++) { + if(*it==dflt) + entry=*it + " (default)"; + else + entry=*it; + images->insertItem(entry.cstr()); + } + if((unsigned int)selection>images->count()) selection=images->count(); + images->setSelected(selection, true); + imageSelected(images->text(selection)); +} +void Images::probeClicked() // SLOT +{ + lilo->probe(); + update(); + emit configChanged(); +} +void Images::dfltClicked() // SLOT +{ + if (images->currentItem() < 0) return; + lilo->setDefault(images->currentText().replace(QRegExp(" (default)", true, true), "").latin1()); + update(); + emit configChanged(); +} +void Images::detailsClicked() // SLOT +{ + liloimage *l=lilo->images[current.latin1()]; + Details *d = new Details(l, this); + if(d->exec()==QDialog::Accepted) { + String tmp; + tmp=l->grep("^[ \t]*read-only[ \t]*"); + if(d->isReadOnly() && tmp.empty()) + l->insert(l->end(), "\tread-only"); + else if(!d->isReadOnly() && !tmp.empty()) + l->remove(tmp); + l->set("vga", d->vgaMode().latin1(), true, true, "\t"); + tmp=l->grep("^[ \t]*unsafe[ \t]*"); + if(d->isUnsafe() && tmp.empty()) + l->insert(l->end(), "\tunsafe"); + else if(!d->isUnsafe() && !tmp.empty()) + l->remove(tmp); + tmp=l->grep("^[ \t]*lock[ \t]*"); + if(d->isLocked() && tmp.empty()) + l->insert(l->end(), "\tlock"); + else if(!d->isLocked() && !tmp.empty()) + l->remove(tmp); + tmp=l->grep("^[ \t]*restricted[ \t]*"); + if(d->isRestricted() && tmp.empty()) + l->insert(l->end(), "\trestricted"); + else if(!d->isRestricted() && !tmp.empty()) + l->remove(tmp); + if(d->isRestricted() || d->usePassword()) + l->set("password", d->Password().latin1(), true, true, "\t"); + + l->set("password", d->Password().latin1(), true, true, "\t"); + emit configChanged(); + } + delete d; +} +void Images::checkClicked() // SLOT +{ + QString LiloOut=lilo->liloOut().cstr(); + if(lilo->isOk()) { + LiloOut=_("Configuration ok. LILO said:\n")+LiloOut; + InformationOK(this, LiloOut, _("Configuration OK"), "lilo-config.confOK"); + } else { + LiloOut=_("Configuration NOT ok. LILO said:\n")+LiloOut; + ErrorOK(this, _("Configuration NOT ok"), LiloOut); + } +} +void Images::addKrnlClicked() // SLOT +{ + InputBox::entries e; + InputBox::entry l0={ _("&Kernel filename:"), "", true, _("Enter the filename of the kernel you want to boot here.") }; + InputBox::entry l1={ _("&Label:"), "", false, _("Enter the label (name) of the kernel you want to boot here.") }; + InputBox::entry l2={ _("&Root filesystem:"), "", true, _("Enter the root filesystem (i.e. the partition that will be mounted as / at boot time) for the kernel you want to boot here.") }; + InputBox::entry l3={ _("&Initial ramdisk:"), "", true, _("If you want to use an initial ramdisk (initrd) for this kernel, enter its filename here. Leave this field blank if you don't intend to use an initial ramdisk for this kernel.") }; + e.insert(e.end(), l0); + e.insert(e.end(), l1); + e.insert(e.end(), l2); + e.insert(e.end(), l3); + InputBox *label=new InputBox(e, this); + if(label->exec()==QDialog::Accepted) { + QStringList s=label->text(); + QStringList::Iterator it=s.begin(); + String kernel=(*it).latin1(); + it++; + String label=(*it).latin1(); + it++; + String root=(*it).latin1(); + it++; + String initrd=(*it).latin1(); + lilo->addLinux(label, kernel, root, initrd); + update(); + emit configChanged(); + } + delete label; +} +void Images::addOSClicked() // SLOT +{ + InputBox::entries e; + InputBox::entry l0={_("Boot from dis&k:"), "", true, _("Enter the partition containing the operating system you'd like to boot here.") }; + InputBox::entry l1={_("&Label:"), "", false, _("Enter the label (name) of the operating system here.") }; + e.insert(e.end(), l0); + e.insert(e.end(), l1); + InputBox *label=new InputBox(e, this); + if(label->exec()==QDialog::Accepted) { + QStringList s=label->text(); + QStringList::Iterator it=s.begin(); + String disk=(*it).latin1(); + it++; + String label=(*it).latin1(); + lilo->addOther(label, disk); + update(); + emit configChanged(); + } + delete label; +} +void Images::removeClicked() // SLOT +{ + if(images->currentItem()==-1) + return; + QString s=images->currentText(); + if(s.right(10)==" (default)") + s=s.left(s.length()-10); + if (s.isNull()) + s = ""; + lilo->images.remove(s.latin1()); + previous=""; current=""; + update(); + emit configChanged(); +} + +QString value(QString const &s) +{ + QString r=s.mid(s.find('=')+1).simplifyWhiteSpace(); + if(r.left(1)=="\"") + r=r.mid(1); + if(r.right(1)=="\"") + r=r.left(r.length()-1); + if (r.isNull()) + r = ""; + return r; +} + +void Images::imageSelected(const QString &i) // SLOT +{ + bool blocked = signalsBlocked(); + blockSignals(true); + QString s=i; + if(s.right(10)==" (default)") + s=s.left(s.length()-10); + if(previous!=s && !previous.isEmpty()) { + previous=s; + saveChanges(); + } else if(previous.isEmpty()) + previous=s; + + if (s.isNull()) + s = ""; + current=s; + liloimage *l=lilo->images[s.latin1()]; + if(l) { + QString img=value(l->grep("^[ \t]*(image|other)[ \t]*=").cstr()); + image->setText(img); + label->setText(s); + if(l->isLinux()) { + image->setLabel(_("&Kernel:")); + String rt=l->grep("^[ \t]*root[ \t]*="); + if(!rt.empty()) + root->setText(value(rt.cstr())); + else + root->setText(""); + String rd=l->grep("^[ \t]*initrd[ \t]*="); + if(!rd.empty()) + initrd->setText(value(rd.cstr())); + else + initrd->setText(""); + append->setText(l->get("append").cstr()); + root->show(); + initrd->show(); + append->show(); + } else { + image->setLabel(_("Dis&k:")); + root->hide(); + initrd->hide(); + append->hide(); + } + } + blockSignals(blocked); +} +void Images::saveChanges() // SLOT +{ + if(!current.isEmpty()) { + liloimage *l=lilo->images[current.latin1()]; + if(l) { + l->set("image", image->text().latin1(), true, true); + l->set("label", label->text().latin1(), true, true, "\t"); + l->set("root", root->text().latin1(), true, true, "\t"); + l->set("initrd", initrd->text().latin1(), true, true, "\t"); + l->set("append", append->text().latin1(), true, true, "\t"); + } + } +} + +void Images::makeReadOnly() +{ + images->setEnabled( false ); + image->setEnabled( false ); + label->setEnabled( false ); + root->setEnabled( false ); + initrd->setEnabled( false ); + append->setEnabled( false ); + dflt->setEnabled( false ); + details->setEnabled( false ); + probe->setEnabled( false ); + check->setEnabled( false ); + addKrnl->setEnabled( false ); + addOS->setEnabled( false ); + remove->setEnabled( false ); +} diff --git a/lilo-config/kde-qt-common/images.h b/lilo-config/kde-qt-common/images.h new file mode 100644 index 0000000..62c6124 --- /dev/null +++ b/lilo-config/kde-qt-common/images.h @@ -0,0 +1,82 @@ +/* images.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _IMAGES_H_ +#define _IMAGES_H_ 1 +#include <lilo.h> +#include <qwidget.h> +#include <qmultilineedit.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qlistbox.h> +#include <qvbox.h> +#include "EditWidget.h" +class Images:public QWidget +{ + Q_OBJECT +public: + Images(liloconf *l=0, QWidget *parent=0, const char *name=0); + ~Images(); + void setCfg(liloconf *l) { lilo=l; }; + void makeReadOnly(); +public slots: + void update(); + void saveChanges(); +private slots: + void probeClicked(); + void dfltClicked(); + void detailsClicked(); + void checkClicked(); + void addKrnlClicked(); + void addOSClicked(); + void removeClicked(); + void imageSelected(const QString &i); +signals: + void configChanged(); +private: + liloconf *lilo; + QString previous; + QString current; + QHBoxLayout *layout; + QListBox *images; + QVBox *parameters; + EditWidget *image; + EditWidget *label; + EditWidget *root; + EditWidget *initrd; + EditWidget *append; + QVBox *actions; + QPushButton *dflt; + QPushButton *details; + QPushButton *probe; + QPushButton *check; + QPushButton *addKrnl; + QPushButton *addOS; + QPushButton *remove; +}; +#endif diff --git a/lilo-config/kde-qt-common/mainwidget.cpp b/lilo-config/kde-qt-common/mainwidget.cpp new file mode 100644 index 0000000..6d76dc5 --- /dev/null +++ b/lilo-config/kde-qt-common/mainwidget.cpp @@ -0,0 +1,107 @@ +/* mainwidget.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "mainwidget.moc" +#include "ui.h" + +MainWidget::MainWidget(QWidget *parent, const char *name) + : QTabWidget(parent, name) +{ + l=new liloconf(); + general=new General(l, this); + connect(general, SIGNAL(configChanged()), SIGNAL(configChanged())); + images=new Images(l, this); + connect(images, SIGNAL(configChanged()), SIGNAL(configChanged())); + expert=new Expert(l, this); + connect(expert, SIGNAL(configChanged()), SIGNAL(configChanged())); + connect(expert, SIGNAL(configChanged()), images, SLOT(update())); + addTab(general, _("&General Options")); + addTab(images, _("&Operating Systems")); + addTab(expert, _("&Expert")); + connect(this, SIGNAL(selected(const QString &)), SLOT(tabChanged(const QString &))); + load(); + arrangeWidgets(); +} + +void MainWidget::makeReadOnly() +{ + general->makeReadOnly(); + images->makeReadOnly(); + expert->makeReadOnly(); +} + +void MainWidget::load() +{ + defaults(); +} + +void MainWidget::save() +{ + if(previous==_("&Expert")) + expert->saveChanges(); + else { + general->saveChanges(); + images->saveChanges(); + } + l->checked=false; + if(!l->isOk()) { + if(WarningYesNo(this, "About to write a faulty lilo.conf", "WARNING: the config file is currently NOT ok.\nDo you really want to override /etc/lilo.conf?\n\nIf you aren't sure, select \"no\" and click the \"Check configuration\" button to see the details.\nIf you don't know what's wrong, try clicking the \"Probe\" button to auto-generate a working lilo.conf.\nIf you're getting this message after using the \"Probe\" button, please send a full bug report,\nincluding the output of \"Check configuration\" and the generated lilo.conf (displayed in the \"Expert\" tab),\nto bero@kde.org.")!=IDYES) + return; + } + l->writeFile("/etc/lilo.conf"); + l->install(); +} + +void MainWidget::defaults() +{ +} + +void MainWidget::reset() +{ + load(); +} + +void MainWidget::arrangeWidgets() +{ +} +void MainWidget::tabChanged(QString const &lbl) // SLOT +{ + if(previous==_("&Expert")) + expert->saveChanges(); + else if(previous==_("&General options")) + general->saveChanges(); + else if(previous==_("&Operating systems")) + images->saveChanges(); + if(lbl==_("&Expert")) + expert->update(); + else if(lbl==_("&Operating systems")) + images->update(); + else if(lbl==_("&General options")) + general->update(); + previous=lbl; +} diff --git a/lilo-config/kde-qt-common/mainwidget.h b/lilo-config/kde-qt-common/mainwidget.h new file mode 100644 index 0000000..46696e8 --- /dev/null +++ b/lilo-config/kde-qt-common/mainwidget.h @@ -0,0 +1,60 @@ +/* mainwidget.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _MAINWIDGET_H_ +#define _MAINWIDGET_H_ 1 +#include <qwidget.h> +#include <qlistbox.h> +#include <qtabwidget.h> +#include <qevent.h> +#include "general.h" +#include "images.h" +#include "expert.h" + +class MainWidget: public QTabWidget { + Q_OBJECT +public: + MainWidget(QWidget *parent, const char *name=0); + void arrangeWidgets(); + void makeReadOnly(); +public slots: + void load(); + void save(); + void reset(); + void defaults(); + void tabChanged(const QString &lbl); +signals: + void configChanged(); +private: + QString previous; + General *general; + Images *images; + Expert *expert; + liloconf *l; +}; +#endif diff --git a/lilo-config/kde-qt-common/ui.h b/lilo-config/kde-qt-common/ui.h new file mode 100644 index 0000000..e672847 --- /dev/null +++ b/lilo-config/kde-qt-common/ui.h @@ -0,0 +1,77 @@ +/* ui.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +/* UI definitions... Coding these things twice (with and without KDE) + * wouldn't make sense... */ + +#ifndef _UI_H +#define _UI_H + +#ifdef USE_KDE +#include <kmessagebox.h> +#include <klocale.h> +#include <ktabctl.h> +#include <kdialog.h> +#include <kfiledialog.h> +#define _(x) i18n(x) +#define WarningYesNo(parent, caption, text) \ + KMessageBox::warningYesNo(parent, text, caption) +#define ErrorOK(parent, caption, text) \ + KMessageBox::sorry(parent, text, caption) +#define InformationOK(parent, text, caption, dontShowAgainName) \ + KMessageBox::information(parent, text, caption, dontShowAgainName) +#define CriticalErrorOK(parent, text, caption) \ + KMessageBox::error(parent, text, caption) +#define TabBar KTabCtl +#define FileDlg KFileDialog +#define SPACE_MARGIN KDialog::marginHint() +#define SPACE_INSIDE KDialog::spacingHint() +#else +#include <qmessagebox.h> +#include <qtabwidget.h> +#include <qdialog.h> +#include <qfiledialog.h> +#define _(x) tr(x) +#define WarningYesNo(parent, caption, text) \ + QMessageBox::warning(parent, caption, text, QMessageBox::Yes, QMessageBox::No) +#define ErrorOK(parent, caption, text) \ + QMessageBox::information(parent, caption, text) +#define InformationOK(parent, text, caption, dontShowAgainName) \ + QMessageBox::information(parent, caption, text) +#define CriticalErrorOK(parent, text, caption) \ + QMessageBox::critical(parent, caption, text) +#define TabBar QTabWidget +#define FileDlg QFileDialog +#define SPACE_MARGIN 5 +#define SPACE_INSIDE 5 +#endif +#define IDYES 3 +#define IDNO 4 + +#endif + diff --git a/lilo-config/kde/Details.cpp b/lilo-config/kde/Details.cpp new file mode 100644 index 0000000..4e19b14 --- /dev/null +++ b/lilo-config/kde/Details.cpp @@ -0,0 +1,134 @@ +/* Details.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "Details.moc" + +#include <qlayout.h> +#include <qhbox.h> +#include <qvbox.h> +#include <qwhatsthis.h> +#include <qlabel.h> +#include <ui.h> + +Details::Details(liloimage *lilo, QWidget *parent, const char *name, WFlags /* f */) + : KDialogBase(parent, name, true, QString::null, Ok|Cancel, Ok, true) +{ + l=lilo; + + QVBox *page = makeVBoxMainWidget(); + + QHBox *vgab=new QHBox(page); + QLabel *vlbl=new QLabel(_("&Graphics mode on text console:"), vgab); + vga=new QComboBox(false, vgab); + vlbl->setBuddy(vga); + QWhatsThis::add(vgab, _("You can select the graphics mode for this kernel here.<br>If you intend to use a VGA graphics mode, you must compile the kernel with support for framebuffer devices. The <i>ask</i> setting brings up a prompt at boot time.")); + vga->insertItem(_("default")); + vga->insertItem(_("ask")); + vga->insertItem(_("text 80x25 (0)")); + vga->insertItem(_("text 80x50 (1)")); + vga->insertItem(_("text 80x43 (2)")); + vga->insertItem(_("text 80x28 (3)")); + vga->insertItem(_("text 80x30 (4)")); + vga->insertItem(_("text 80x34 (5)")); + vga->insertItem(_("text 80x60 (6)")); + vga->insertItem(_("text 40x25 (7)")); + vga->insertItem(_("VGA 640x480, 256 colors (769)")); + vga->insertItem(_("VGA 640x480, 32767 colors (784)")); + vga->insertItem(_("VGA 640x480, 65536 colors (785)")); + vga->insertItem(_("VGA 640x480, 16.7M colors (786)")); + vga->insertItem(_("VGA 800x600, 256 colors (771)")); + vga->insertItem(_("VGA 800x600, 32767 colors (787)")); + vga->insertItem(_("VGA 800x600, 65536 colors (788)")); + vga->insertItem(_("VGA 800x600, 16.7M colors (789)")); + vga->insertItem(_("VGA 1024x768, 256 colors (773)")); + vga->insertItem(_("VGA 1024x768, 32767 colors (790)")); + vga->insertItem(_("VGA 1024x768, 65536 colors (791)")); + vga->insertItem(_("VGA 1024x768, 16.7M colors (792)")); + vga->insertItem(_("VGA 1280x1024, 256 colors (775)")); + vga->insertItem(_("VGA 1280x1024, 32767 colors (793)")); + vga->insertItem(_("VGA 1280x1024, 65536 colors (794)")); + vga->insertItem(_("VGA 1280x1024, 16.7M colors (795)")); + + readonly=new QCheckBox(_("Mount root filesystem &read-only"), page); + QWhatsThis::add(readonly, _("Mount the root filesystem for this kernel read-only. Since the init scripts normally take care of remounting the root filesystem in read-write mode after running some checks, this should always be turned on.<br>Don't turn this off unless you know what you're doing.")); + + unsafe=new QCheckBox(_("Do not check &partition table"), page); + QWhatsThis::add(unsafe, _("This turns off some sanity checks while writing the configuration. This should not be used under \"normal\" circumstances, but it can be useful, for example, by providing the capability of booting from a floppy disk, without having a floppy in the drive every time you run lilo.<br>This sets the <i>unsafe</i> keyword in lilo.conf.")); + + QHBox *opts=new QHBox(page); + lock=new QCheckBox(_("&Record boot command lines for defaults"), opts); + QWhatsThis::add(lock, "<qt>" + _("Checking this box enables automatic recording of boot command lines as the default for the following bootups. This way, lilo \"locks\" on a choice until it is manually overridden.<br>This sets the <b>lock</b> option in lilo.conf")); + restricted=new QCheckBox(_("R&estrict parameters"), opts); + connect(restricted, SIGNAL(clicked()), SLOT(check_pw())); + QWhatsThis::add(restricted, _("If this box is checked, a password (entered below) is required only if any parameters are changed (i.e. the user can boot <i>linux</i>, but not <i>linux single</i> or <i>linux init=/bin/sh</i>).\nThis sets the <b>restricted</b> option in lilo.conf.")); + + QHBox *pw=new QHBox(page); + use_password=new QCheckBox(_("Require &password:"), pw); + connect(use_password, SIGNAL(clicked()), SLOT(check_pw())); + password=new QLineEdit(pw); + password->setMaxLength(15); + password->setEchoMode(QLineEdit::Password); + QWhatsThis::add(pw, _("Enter the password required for bootup (if any) here. If <i>restricted</i> above is checked, the password is required for additional parameters only.<br><b>WARNING:</b> The password is stored in clear text in /etc/lilo.conf. You'll want to make sure nobody untrusted can read this file. Also, you probably don't want to use your normal/root password here.")); + + if(l) { + QString mode=l->get("vga", "").cstr(); + if(mode.isEmpty()) + vga->setCurrentItem(0); + else if(mode=="ask") + vga->setCurrentItem(1); + else + for(int i=0; i<vga->count(); i++) { + if(vga->text(i).contains("(" + mode + ")")) { + vga->setCurrentItem(i); + break; + } + } + readonly->setChecked(!l->grep("[ \t]*read-only[ \t]*").empty()); + unsafe->setChecked(!l->grep("[ \t]*unsafe[ \t]*").empty()); + lock->setChecked(!l->grep("[ \t]*lock[ \t]*").empty()); + restricted->setChecked(!l->grep("[ \t]*restricted[ \t]*").empty()); + password->setText(l->get("password").cstr()); + } + + check_pw(); +} + +void Details::check_pw() +{ + password->setEnabled(restricted->isChecked() || use_password->isChecked()); +} + +QString Details::vgaMode() const +{ + QString s=vga->currentText(); + if(s=="default") + return ""; + else if(s!="ask") { + s=s.mid(s.find('(')+1); + s=s.left(s.length()-1); + } + return s; +} diff --git a/lilo-config/kde/Details.h b/lilo-config/kde/Details.h new file mode 100644 index 0000000..e752f0b --- /dev/null +++ b/lilo-config/kde/Details.h @@ -0,0 +1,61 @@ +/* Details.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ + +#ifndef _DETAILS_H_ +#define _DETAILS_H_ 1 + +#include <lilo.h> +#include <kdialogbase.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qlineedit.h> + +class Details:public KDialogBase +{ + Q_OBJECT +public: + Details(liloimage *lilo, QWidget *parent=0, const char *name=0, WFlags f=0); + bool isReadOnly() const { return readonly->isChecked(); }; + QString vgaMode() const; + bool isUnsafe() const { return unsafe->isChecked(); }; + bool isLocked() const { return lock->isChecked(); }; + bool isRestricted() const { return restricted->isChecked(); }; + bool usePassword() const { return use_password->isChecked(); }; + QString Password() const { return password->text(); }; +private slots: + void check_pw(); +private: + liloimage *l; + QCheckBox *readonly; + QComboBox *vga; + QCheckBox *unsafe; + QCheckBox *lock; + QCheckBox *restricted; + QCheckBox *use_password; + QLineEdit *password; +}; +#endif diff --git a/lilo-config/kde/InputBox.cpp b/lilo-config/kde/InputBox.cpp new file mode 100644 index 0000000..a338c20 --- /dev/null +++ b/lilo-config/kde/InputBox.cpp @@ -0,0 +1,43 @@ +/* InputBox.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "InputBox.moc" +#include <qvbox.h> +#include <qwhatsthis.h> +#include <ui.h> + +InputBox::InputBox(entries e, QWidget *parent, const char *name, bool hasCancel, WFlags f) + : KDialogBase(parent, name, true, QString::null, hasCancel ? Ok | Cancel : Ok, Ok, true ) +{ + QVBox *page = makeVBoxMainWidget(); + for(entries::iterator it=e.begin(); it!=e.end(); it++) { + EditWidget *ed=new EditWidget((*it).label, (*it).dflt, (*it).isFile, page); + QWhatsThis::add(ed, (*it).help); + edit.insert(edit.end(), ed); + } +} diff --git a/lilo-config/kde/InputBox.h b/lilo-config/kde/InputBox.h new file mode 100644 index 0000000..d263161 --- /dev/null +++ b/lilo-config/kde/InputBox.h @@ -0,0 +1,50 @@ +/* InputBox.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _INPUTBOX_H_ +#define _INPUTBOX_H_ 1 + +#include <kdialogbase.h> + +#include <qlabel.h> +#include <qlineedit.h> + +#include "EditWidget.h" +#include <list> +class InputBox:public KDialogBase +{ + Q_OBJECT +public: + typedef struct { QString label; QString dflt; bool isFile; QString help; } entry; + typedef std::list<entry> entries; + InputBox(entries e, QWidget *parent=0, const char *name=0, bool hasCancel=true, WFlags f=0); + QStringList const text() const { QStringList s; for(std::list<EditWidget*>::const_iterator it=edit.begin(); it!=edit.end(); it++) s << (*it)->text(); return s; }; +private: + std::list<EditWidget*> edit; +}; +#endif diff --git a/lilo-config/kde/Makefile.am b/lilo-config/kde/Makefile.am new file mode 100644 index 0000000..08c52b8 --- /dev/null +++ b/lilo-config/kde/Makefile.am @@ -0,0 +1,13 @@ +INCLUDES= -I$(srcdir)/../common -I$(srcdir)/../kde-qt-common $(all_includes) + +kde_module_LTLIBRARIES = kcm_lilo.la + +kcm_lilo_la_SOURCES = kcontrol.cpp Details.cpp InputBox.cpp +kcm_lilo_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined +kcm_lilo_la_LIBADD = ../kde-qt-common/libwidgets.la $(LIB_KIO) +kcm_lilo_la_METASOURCES = AUTO +AM_CXXFLAGS = -DUSE_KDE + +noinst_HEADERS = Details.h InputBox.h + +xdg_apps_DATA = lilo.desktop diff --git a/lilo-config/kde/kcontrol.cpp b/lilo-config/kde/kcontrol.cpp new file mode 100644 index 0000000..2db98af --- /dev/null +++ b/lilo-config/kde/kcontrol.cpp @@ -0,0 +1,87 @@ +/* kcontrol.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include "kcontrol.moc" +#include <mainwidget.h> +#include <ui.h> +#include <kglobal.h> +#include <klocale.h> +#include <qlayout.h> +#include <kaboutdata.h> +#include <unistd.h> + +KControl::KControl(QWidget *parent, const char *name) + : KCModule(parent, name) +{ + QVBoxLayout *layout=new QVBoxLayout(this); + m=new MainWidget(this, name); + layout->addWidget(m); + connect(m, SIGNAL(configChanged()), SLOT(configChanged())); + if (getuid() != 0) { + m->makeReadOnly(); + } + KAboutData *about = new KAboutData(I18N_NOOP("kcmlilo"), I18N_NOOP("LILO Configuration"), + 0, 0, KAboutData::License_GPL, + I18N_NOOP("(c) 2000, Bernhard Rosenkraenzer")); + about->addAuthor("Bernhard \"Bero\" Rosenkraenzer", 0, "bero@redhat.com"); + setAboutData(about); +} + +void KControl::load() +{ + m->load(); +} + +void KControl::save() +{ + m->save(); +} + +void KControl::defaults() +{ + m->defaults(); +} + +void KControl::reset() +{ + m->reset(); +} + +void KControl::configChanged() // SLOT +{ + emit changed(true); +} + +extern "C" +{ + KDE_EXPORT KCModule *create_lilo(QWidget *parent, const char *name) + { + return new KControl(parent, "kcmlilo"); + } +} + diff --git a/lilo-config/kde/kcontrol.h b/lilo-config/kde/kcontrol.h new file mode 100644 index 0000000..d06d834 --- /dev/null +++ b/lilo-config/kde/kcontrol.h @@ -0,0 +1,54 @@ +/* kcontrol.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +** Contributions by M. Laurent and W. Bastian. +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +#ifndef _KCONTROL_H_ +#define _KCONTROL_H_ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#include <qwidget.h> +#include <qevent.h> +#include <kcmodule.h> +#include "mainwidget.h" + +class KAboutData; + +class KControl: public KCModule { + Q_OBJECT +public: + KControl(QWidget *parent, const char *name); + void load(); + void save(); + void defaults(); + void reset(); +public slots: + void configChanged(); +private: + MainWidget *m; +}; + +#endif + diff --git a/lilo-config/kde/lilo.desktop b/lilo-config/kde/lilo.desktop new file mode 100644 index 0000000..cd1c7ba --- /dev/null +++ b/lilo-config/kde/lilo.desktop @@ -0,0 +1,212 @@ +[Desktop Entry] +Exec=kcmshell lilo +Icon=hdd_unmount +Type=Application + +X-KDE-ModuleType=Library +X-KDE-Library=lilo +X-KDE-RootOnly=true +X-KDE-HasReadOnlyMode=false + +Name=Boot Manager (LILO) +Name[af]=Boot Bestuurder (Lilo) +Name[ar]=مدير إنطلاق النظام (LILO) +Name[az]=Açılış İdarəçisi (LILO) +Name[be]=Кіраўнік загрузкі LILO +Name[bg]=Стартиране +Name[bn]=বুট ম্যানেজার (LILO) +Name[br]=C'Harger loc'hañ (LILO) +Name[ca]=Gestor d'arrencada (LILO) +Name[cs]=Správce spuštění (LILO) +Name[cy]=Rheolydd Cychwyn (LILO) +Name[da]=Boothåndtering (LILO) +Name[de]=Bootmanager (Lilo) +Name[el]=Διαχειριστής Εκκίνησης (LILO) +Name[eo]=Linukslanĉilo (LILO) +Name[es]=Administrador de arranque (LILO) +Name[et]=Alglaadur (LILO) +Name[eu]=Letra-tipoen kudeatzailea +Name[fa]=مدیر راهاندازی (LILO) +Name[fi]=Käynnistyksenhallinta (LILO) +Name[fo]=Sjálvbyrjarahandfarari (LILO) +Name[fr]=Gestionnaire de démarrage (LILO) +Name[ga]=Bainisteoir Tosaithe (LILO) +Name[gl]=Xestor de Arranque (LILO) +Name[he]=מנהל האתחול (LILO) +Name[hi]=बूट प्रबंधक (लिलो) +Name[hr]=Upravljanje pokretanjem (LILO) +Name[hu]=Rendszerindító (LILO) +Name[id]=Manajer Boot (LILO) +Name[is]=Ræsistjóri (LILO) +Name[it]=Gestore di avvio (LILO) +Name[ja]=ブートマネージャ (LILO) +Name[ka]=ჩატვირთვის მმართველი (LILO) +Name[kk]=Жүктеуіш (LILO) +Name[km]=កម្មវិធីគ្រប់គ្រងការចាប់ផ្ដើមឡើងវិញ (LILO) +Name[ko]=부트 관리자 (LILO) +Name[lt]=Užkrovos tvarkyklė (LILO) +Name[lv]=Sāknēšanas Menedžeris (LILO) +Name[mn]=Бүүт Менежер (Лило) +Name[ms]=Pengurus Boot (LILO) +Name[nb]=Oppstartsbehandler (LILO) +Name[nds]=Systeemstart-Pleger (LILO) +Name[ne]=बुट प्रबन्धक (एलआईएलओ) +Name[nl]=Opstartbeheerder (LILO) +Name[nn]=Oppstartshandsamar (LILO) +Name[pa]=ਬੂਟ ਪਰਬੰਧਕ (LILO) +Name[pl]=Uruchamianie systemu (LILO) +Name[pt]=Gestor de Arranque (LILO) +Name[pt_BR]=Gerenciador de Inicialização (LILO) +Name[ro]=Manager de boot-are (LILO) +Name[ru]=Загрузчик LILO +Name[se]=Vuolggahangieđahalli (LILO) +Name[sk]=Správca bootovania (LILO) +Name[sl]=Upravljalnik zagona (LILO) +Name[sr]=Бут менаџер (LILO) +Name[sr@Latn]=But menadžer (LILO) +Name[sv]=Starthanterare (Lilo) +Name[ta]=ஆரம்ப இயக்க மேலாளர்(LILO) +Name[tg]=Роҳбари Пурборкардан (LILO) +Name[th]=จัดการการบูต (LILO) +Name[tr]=Açılış Yöneticisi (LILO) +Name[uk]=Менеджер завантаження (LILO) +Name[ven]=Muranga phanda wa Butu (LILO) +Name[vi]=Bộ quản lý khởi động (LILO) +Name[wa]=Apontiaedje del enondrece (LILO) +Name[xh]=Umphathi wesiNgxobo (LILO) +Name[zh_CN]=启动管理器(LILO) +Name[zh_HK]=開機管理員(LILO) +Name[zh_TW]=開機啟動管理程式(LILO) +Name[zu]=Umphathi Wesingxobo (LILO) +Comment=Configure LILO (the Linux boot manager) +Comment[af]=Konfigureer Lilo (die Linux boot bestuurder) +Comment[ar]=إعدادات LILO (مدير إنطلاق نظام لينكس) +Comment[az]=LILO Qurğuları (Linuks açılış idarəçisi) +Comment[be]=Наставіць LILO (кіраўнік загрузкі Linux) +Comment[bg]=Графично настройване на първоначалното зареждането на Линукс +Comment[bn]=LILO (লিনাক্স বুট ম্যানেজার) কনফিগার করে +Comment[br]=Kefluniañ LILO (ar c'harger loc'hañ evit Linux) +Comment[bs]=Podesi LILO (Linux boot manager) +Comment[ca]=Aquí podreu configurar el LILO (el gestor d'arrencada de Linux) +Comment[cs]=Zde je možné nastavit LILO (LInux LOader) +Comment[cy]=Ffurfweddu LILO (rheolydd cychwyn Linux) +Comment[da]=Indstil LILO (Linux-boothåndtering) +Comment[de]=Hier können Sie Lilo (den Bootmanager von Linux) einrichten +Comment[el]=Ρύθμιση LILO (Ο διαχειριστής εκκίνησης του Linux) +Comment[eo]=Agordu LILOn (la Linukslanĉilon) +Comment[es]=Configurar LILO (el administrador de arranque de Linux) +Comment[et]=Linuxi alglaaduri LILO seadistamine +Comment[eu]=LILO konfiguratu (Linuxen abikoko kudeatzailea) +Comment[fa]=پیکربندی LILO (مدیر راهاندازی لینوکس) +Comment[fi]=Aseta LILO:a (Linuxin käynnistysmanageri) +Comment[fr]=Configuration de LILO (le gestionnaire de démarrage de Linux) +Comment[ga]=Cumraigh LILO (bainisteoir tosaithe Linux) +Comment[gl]=Configurar LILO (O xestor de arranque de linux) +Comment[he]=שינוי הגדרות LILO (מנהל האתחול של לינוקס) +Comment[hi]=लिलो कॉन्फ़िगर करें (लिनक्स बूट प्रबंधक) +Comment[hr]=Konfigurirajte LILO (Linux upravitelj pokretanja sustava) +Comment[hu]=a LILO beállításai +Comment[is]=Stilla LILO (Linux ræsistjórann) +Comment[it]=Configura LILO (il gestore dell'avvio di Linux) +Comment[ja]=LILO (Linux ブートマネージャ) の設定 +Comment[ka]=LILO-ს კონფიგურაცია (ლინუქსის ჩატვირთვის მმართველი) +Comment[kk]=LILO (Linux жүктеуішін) баптауы +Comment[km]=កំណត់រចនាសម្ព័ន្ធ LILO (កម្មវិធីគ្រប់គ្រងការចាប់ផ្ដើមឡើងវិញលីនុច) +Comment[ko]=LILO(리눅스 부트 관리자) 설정 +Comment[lt]=Konfigūruoti LILO (Linux užkrovos tvarkyklę) +Comment[mk]=Конфигурирајте го LILO (менаџерот за подигање на Линукс) +Comment[mn]=Лило (Линүкс эхлүүлэгч менежер) Тохируулах +Comment[ms]=Selaraskan LILO (pengurus boot Linux) +Comment[mt]=Ikkonfigura l-LILO (Linux Loader) +Comment[nb]=Her kan du sette opp LILO (Linux oppstartssystem) +Comment[nds]=LILO (Systeemstart-Pleger vun Linux) instellen +Comment[ne]=एलआईएलओ कन्फिगर गर्नुहोस् (लिनक्स बुट प्रबन्धक) +Comment[nl]=Lilo (Linux Opstartmanager) instellen +Comment[nn]=LILO-oppsett (Linux-oppstartssystemet) +Comment[pa]=LILO ਸੰਰਚਨਾ(ਲੀਨਕਸ ਬੂਟ ਪਰਬੰਧਕ) +Comment[pl]=Konfiguracja LILO (menedżera rozruchu systemu w Linuksie) +Comment[pt]=Configuração do LILO (o gestor de arranque do Linux) +Comment[pt_BR]=Configura o LILO (o gerenciador de boot do Linux) +Comment[ro]=Configurează managerul de boot-are LILO +Comment[ru]=Утилита настройки LILO (менеджера загрузки Linux) +Comment[se]=Heivet LILO (Linux-vuolggahanvuogádaga) +Comment[sk]=Nastavenie LILO (správca bootovania pre Linux) +Comment[sl]=Nastavitve LILO (zagonski upravljalnik za Linux) +Comment[sr]=Подесите LILO (Линукс бут менаџер) +Comment[sr@Latn]=Podesite LILO (Linuks but menadžer) +Comment[sv]=Anpassa Lilo (starthanterare för Linux) +Comment[ta]=வடிவமை LILO(லினக்ஸ் இயக்க மேலாளர்) +Comment[tg]=Танзимоти LILO (Роҳбари Пурборкунии Линукс) +Comment[th]=ปรับแต่ง LILO (เครื่องมือจัดการการบูตของลินุกซ์) +Comment[tr]=LILO'yu Yapılandır +Comment[uk]=Налаштувати LILO (менеджер завантаження Linux) +Comment[ven]=Dzudzanyani LILO (mulanguli wa boot ya Linux) +Comment[vi]=Cấu hình LILO (bộ quản lý khởi động Linux) +Comment[wa]=Chal vos ploz apontyî LILO (l' enondrece Linux) +Comment[xh]=Qwalalsela LILO (umphathi we boot ye Linux) +Comment[zh_CN]=配置 LILO (Linux 启动管理程序) +Comment[zh_HK]=設定 LILO (Linux 的開機管理員) +Comment[zh_TW]=你可在此設定 LILO (Linux 的開機管理程式) + +Keywords=lilo,boot,bootup,boot manager,linux,Other OS,MBR,startup,start +Keywords[ar]=lilo,boot,bootup,مسيير الإقلاع,لينكس,أنظمة التشغيل الأخرى,MBR,بدء التشغيل,إبدء +Keywords[az]=lilo,açılış,başlanğıc,açılış idarəçisi,linuks,digər əməliyyat sistemləri, MBR +Keywords[bg]=зареждане, стартиране, сектор, запис, Линукс, ядро, мениджър, lilo, boot, bootup, boot manager, linux, Other OS, MBR, startup, start +Keywords[bn]= lilo,boot,bootup,boot manager,linux,Other OS,MBR,startup,start +Keywords[ca]=lilo,arrencada,gestor d'arrencada,linux,d'altres SO,MBR +Keywords[cs]=Lilo,Boot,Bootup,Boot manager,Linux,Jiný OS,MBR,Startup,Start,Spuštění +Keywords[cy]=lilo,cychwyn, rheolydd cychwyn, linux, CG Arall, MBR, dechrau +Keywords[da]=lilo,boot,bootup,boothåndtering,linux,Andet OS,MBR,opstart,start +Keywords[de]=Lilo,Booten,Linux,MBR,Start,Systemstart,Bootmanager,andere OS +Keywords[el]=lilo,εκκίνηση,διαδικασία εκκίνησης,διαχειριστής εκκίνησης,linux,Άλλο ΛΣ,MBRδιαδικασία εκκίνησης,εκκίνηση +Keywords[eo]=lilo,lanĉo,lanĉadministrilo,Linukso,alia operaciumo,MBR,rulo +Keywords[es]=lilo,arranque,administrador de arranque,linux,Otro SO,MBR,inicio +Keywords[et]=lilo,boot,bootup,alglaadimine,linux,teine OS,MBR,käivitamine,start +Keywords[fa]=lilo، راهاندازی، راهاندازی، مدیر راهاندازی، لینوکس، سیستم عامل دیگر، MBR، راهاندازی، آغاز +Keywords[fi]=lilo,boot,bootup,käynnistyksenhallinta,linux,MBR,käynnistys,käynnistä +Keywords[fo]=lilo,sjálvbyrja,byrja,handfarari,Linux,annað stýrikervi,MBR +Keywords[fr]=lilo, boot, démarrage, gestionnaire de démarrage, linux, autre OS, MBR +Keywords[ga]=lilo,tosaigh,tosú,bainisteoir tosaithe,linux,CO eile,MBR,tosú,tús +Keywords[he]=הפעלה,התחלה,MBR,אתחול,מנהל אתחול,לינוקס,מערכות הפעלה אחרות,רשומת אתחול ראשית,lilo +Keywords[hi]=लिलो, बूट, बूटअप,बूट प्रबंधक, लिनक्स, अन्य ओएस, एमबीआर, प्रारंभ में, प्रारंभ, शुरू +Keywords[hr]=lilo,boot,bootup,boot manager,linux,Other OS,MBR,startup,start,pokretanje,početak,počinjanje,ostali OS,upravitelj pokretanjem +Keywords[hu]=lilo,boot,rendszerindítás,rendszerindítás-kezelő,Linux,más operációs rendszerek,MBR,indulás,start +Keywords[id]=lilo,boot,bootup,manajer boot,linux,OS Lainnya,MBR,startup,start +Keywords[is]=lilo,boot,bootup,boot manager,linux,Other OS,MBR,startup,start,ræsa +Keywords[it]=lilo,boot,boot manager,linux,altri sistemi operativi,MBR,avvio,gestore avvio +Keywords[ja]=lilo,ブート,ブートマネージャ,linux,他のOS,MBR,起動,開始 +Keywords[ka]=lilo,ჩატვირთვა,ჩატვირთვის მმართველი,linux,სხვა ოს,MBR,შესრულება,დაწყება +Keywords[km]=lilo,ចាប់ផ្ដើមឡើងវិញ,bootup,កម្មវិធីគ្រប់គ្រងការចាប់ផ្ដើមឡើងវិញ,លីនុច,OS ផ្សេងទៀត,MBR,ចាប់ផ្ដើមឡើងវិញ,ចាប់ផ្ដើម +Keywords[ko]=lilo,부팅,부트로더,리눅스,MBR,시작 +Keywords[lt]=lilo,boot,bootup,boot manager,linux,Other OS,MBR,startup,start,užkrova,krovimasis,kitos OS +Keywords[lv]=lilo,sāknēt,sāknēšana,sāknēšanas menedžeris,linux,Citas OS,MBR,startēšana,startēt +Keywords[mk]=lilo,boot,bootup,boot manager,linux,Other OS,MBR,startup,start,подигање,менаџер,линукс,старт +Keywords[mn]=лило,бүүт,бүүт хийх,бүүт менежер,линүкс,Өөр ҮС,МБР,эхлүүлэх,эхлэл +Keywords[ms]=lilo,boot,bootup,pengurus boot,linux,OS lain,MBR,startup,mula +Keywords[nb]=lilo,boot,oppstart,linux,andre operativsystem,MBR,start +Keywords[nds]=lilo,Systeemstart,boot,hoochfohren,boot manager,Systeemstart-Pleger,linux,Anner BS,MBR,starten,start +Keywords[ne]=लिलो, बुट, बुटअप, बुट प्रबन्धक, लिनक्स, अन्य ओएस, एमबीआर, सुरुआत, सुरु +Keywords[nl]=lilo,boot,bootup,boot manager,beheerder,linux,mbr,startup,start, ander besturingssysteem,opstarten,Windows,OS\2,BeOS +Keywords[nn]=lilo,boot,oppstart,linux,andre operativsystem,MBR,start +Keywords[pa]=ਲੀਲੋ, ਬੂਟ, ਬੂਟਅੱਪ, ਬੂਟ ਪਰਬੰਧਕ,ਲੀਨਕਸ, ਹੋਰ OS,MBR,ਸ਼ੁਰੂਆਤੀ, ਸ਼ੁਰੂ +Keywords[pl]=lilo,boot,menedżer,uruchamianie systemu,linux,linuks,inne systemy,MBR,start +Keywords[pt]=lilo,arranque,gestor de arranque,linux,outro SO,MBR,iniciar,início +Keywords[pt_BR]=lilo,boot,bootup,gerenciador de boot,linux,outro SO,MBR,inicialização,iniciar +Keywords[ro]=lilo,boot,boot-are,bootare,manager de boot-are,linux,alte S.O.,MBR,pornire,start +Keywords[ru]=lilo,boot,bootup,boot manager,linux,Other OS,MBR,загрузка,start +Keywords[se]=lilo,boot,vuolggaheapmi,linux,eará operatiivavuogádagat,MBR,álggaheapmi +Keywords[sk]=lilo,boot,bootup,správca bootu,linux,Iný OS,MBR,startup,štart +Keywords[sl]=lilo,boot,bootup,boot manager,linux,drugi OS,MBR,zagon +Keywords[sv]=lilo,boot,bootning,bootväljare,linux,Annat OS,MBR,uppstart,start +Keywords[ta]= லிலோ,துவக்கம்,மேலே துவக்கு,துவக்க மேலாளர்,லினக்ஸ்,மற்ற OS,MBR,துவக்கம்,துவக்கு +Keywords[th]=lilo,บูต,bootup,เครื่องมือจัดการการบูต,ลินุกซ์,ระบบปฏิบัตการอื่น ๆ,MBR,การเริ่มระบบ,เริ่ม +Keywords[tr]=lilo,açılış,başlangıç,açılış yöneticisi,linux,diğer işletim sistemleri +Keywords[uk]=lilo,boot,завантаження,менеджер завантаження,linux,інші ОС,MBR,запуск +Keywords[ven]=lilo,boot,bootup,boot manager,linux,Other Os,MBR,Mathomoni,Thoma +Keywords[vi]=lilo,boot,khởi động,bootup,mở máy,quản lý khởi động,boot manager,linux,Other OS,hệ điều hành,HĐH,MBR,khởi chạy,startup,start +Keywords[wa]=LILO,boot,bootup,linux,Ôtes SO,MBR,startup,start,enondrece,enondaedje +Keywords[xh]=lilo,isingxobo,faka isingxobo, uphathi wesingxobo,linux,Ezinye OS,MBR,faka isiqalo,qala +Keywords[zh_CN]=lilo,boot,bootup,boot manager,linux,Other OS,MBR,startup,start,启动,启动管理器,其它操作系统 +Keywords[zu]=lilo,isingxobo,faka isingxobo umphathi wesingxobo,linux,Ezinye OS,MBR,faka isiqalo,qala + +Categories=Qt;KDE;Settings;X-KDE-settings-system; diff --git a/lilo-config/qt/Details.cpp b/lilo-config/qt/Details.cpp new file mode 100644 index 0000000..eae3ed5 --- /dev/null +++ b/lilo-config/qt/Details.cpp @@ -0,0 +1,144 @@ +/* Details.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ + +#include "Details.moc" +#include <qlayout.h> +#include <qhbox.h> +#include <qwhatsthis.h> +#include <qlabel.h> +#include <ui.h> + +Details::Details(liloimage *lilo, QWidget *parent, const char *name, WFlags f):QDialog(parent, name, true, f) +{ + l=lilo; + + QVBoxLayout *layout=new QVBoxLayout(this); + layout->setMargin(SPACE_MARGIN); + layout->setSpacing(SPACE_INSIDE); + + QHBox *vgab=new QHBox(this); + QLabel *vlbl=new QLabel(_("&Graphics mode on text console:"), vgab); + vga=new QComboBox(false, vgab); + vlbl->setBuddy(vga); + QWhatsThis::add(vgab, _("You can select the graphics mode for this kernel here.<br>If you intend to use a VGA graphics mode, you must compile the kernel with support for framebuffer devices. The <i>ask</i> setting brings up a prompt at boot time.")); + vga->insertItem(_("default")); + vga->insertItem(_("ask")); + vga->insertItem(_("text 80x25 (0)")); + vga->insertItem(_("text 80x50 (1)")); + vga->insertItem(_("text 80x43 (2)")); + vga->insertItem(_("text 80x28 (3)")); + vga->insertItem(_("text 80x30 (4)")); + vga->insertItem(_("text 80x34 (5)")); + vga->insertItem(_("text 80x60 (6)")); + vga->insertItem(_("text 40x25 (7)")); + vga->insertItem(_("VGA 640x480, 256 colors (769)")); + vga->insertItem(_("VGA 640x480, 32767 colors (784)")); + vga->insertItem(_("VGA 640x480, 65536 colors (785)")); + vga->insertItem(_("VGA 640x480, 16.7M colors (786)")); + vga->insertItem(_("VGA 800x600, 256 colors (771)")); + vga->insertItem(_("VGA 800x600, 32767 colors (787)")); + vga->insertItem(_("VGA 800x600, 65536 colors (788)")); + vga->insertItem(_("VGA 800x600, 16.7M colors (789)")); + vga->insertItem(_("VGA 1024x768, 256 colors (773)")); + vga->insertItem(_("VGA 1024x768, 32767 colors (790)")); + vga->insertItem(_("VGA 1024x768, 65536 colors (791)")); + vga->insertItem(_("VGA 1024x768, 16.7M colors (792)")); + vga->insertItem(_("VGA 1280x1024, 256 colors (775)")); + vga->insertItem(_("VGA 1280x1024, 32767 colors (793)")); + vga->insertItem(_("VGA 1280x1024, 65536 colors (794)")); + vga->insertItem(_("VGA 1280x1024, 16.7M colors (795)")); + layout->addWidget(vgab); + + readonly=new QCheckBox(_("Mount root filesystem &read-only"), this); + QWhatsThis::add(readonly, _("Mount the root filesystem for this kernel read-only. Since the init scripts normally take care of remounting the root filesystem in read-write mode after running some checks, this should always be turned on.<br>Don't turn this off unless you know what you're doing.")); + layout->addWidget(readonly); + + unsafe=new QCheckBox(_("Do not check &partition table"), this); + QWhatsThis::add(unsafe, _("This turns off some sanity checks while writing the configuration. This shouldn't be used under \"normal\" circumstances, but it's useful, for example, for installing the possibility to boot from a floppy disk without having a floppy in the drive every time you run lilo.<br>This sets the <i>unsafe</i> keyword in lilo.conf.")); + layout->addWidget(unsafe); + + QHBox *opts=new QHBox(this); + lock=new QCheckBox(_("&Record boot command lines for defaults"), opts); + QWhatsThis::add(lock, "<qt>"+_("Checking this box enables automatic recording of boot command lines as the default for the following bootups. This way, lilo \"locks\" on a choice until it is manually overridden.<br>This sets the <b>lock</b> option in lilo.conf")); + restricted=new QCheckBox(_("R&estrict parameters"), opts); + connect(restricted, SIGNAL(clicked()), SLOT(check_pw())); + QWhatsThis::add(restricted, _("If this box is checked, a password (entered below) is required only if any parameters are changed (i.e. the user can boot <i>linux</i>, but not <i>linux single</i> or <i>linux init=/bin/sh</i>).\nThis sets the <b>restricted</b> option in lilo.conf.")); + layout->addWidget(opts); + + QHBox *pw=new QHBox(this); + use_password=new QCheckBox(_("Require &password:"), pw); + connect(use_password, SIGNAL(clicked()), SLOT(check_pw())); + password=new QLineEdit(pw); + password->setMaxLength(15); + password->setEchoMode(QLineEdit::Password); + QWhatsThis::add(pw, _("Enter the password required for bootup (if any) here. If <i>restricted</i> above is checked, the password is required for additional parameters only.<br><b>WARNING:</b> The password is stored in clear text in /etc/lilo.conf. You'll want to make sure nobody untrusted can read this file. Also, you probably don't want to use your normal/root password here.")); + layout->addWidget(pw); + + QHBox *btns=new QHBox(this); + ok=new QPushButton(_("&OK"), btns); + cancel=new QPushButton(_("&Cancel"), btns); + layout->addWidget(btns); + connect(cancel, SIGNAL(clicked()), SLOT(reject())); + connect(ok, SIGNAL(clicked()), SLOT(accept())); + + if(l) { + QString mode=l->get("vga", "").cstr(); + if(mode.isEmpty()) + vga->setCurrentItem(0); + else if(mode=="ask") + vga->setCurrentItem(1); + else + for(int i=0; i<vga->count(); i++) { + if(vga->text(i).contains("(" + mode + ")")) { + vga->setCurrentItem(i); + break; + } + } + readonly->setChecked(!l->grep("[ \t]*read-only[ \t]*").empty()); + unsafe->setChecked(!l->grep("[ \t]*unsafe[ \t]*").empty()); + lock->setChecked(!l->grep("[ \t]*lock[ \t]*").empty()); + restricted->setChecked(!l->grep("[ \t]*restricted[ \t]*").empty()); + password->setText(l->get("password").cstr()); + } + + check_pw(); +} +void Details::check_pw() +{ + password->setEnabled(restricted->isChecked() || use_password->isChecked()); +} +QString Details::vgaMode() const +{ + QString s=vga->currentText(); + if(s=="default") + return ""; + else if(s!="ask") { + s=s.mid(s.find('(')+1); + s=s.left(s.length()-1); + } + return s; +} diff --git a/lilo-config/qt/Details.h b/lilo-config/qt/Details.h new file mode 100644 index 0000000..f189430 --- /dev/null +++ b/lilo-config/qt/Details.h @@ -0,0 +1,61 @@ +/* Details.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ +#ifndef _DETAILS_H_ +#define _DETAILS_H_ 1 +#include <lilo.h> +#include <qdialog.h> +#include <qcheckbox.h> +#include <qcombobox.h> +#include <qlineedit.h> +#include <qpushbutton.h> +class Details:public QDialog +{ + Q_OBJECT +public: + Details(liloimage *lilo, QWidget *parent=0, const char *name=0, WFlags f=0); + bool isReadOnly() const { return readonly->isChecked(); }; + QString vgaMode() const; + bool isUnsafe() const { return unsafe->isChecked(); }; + bool isLocked() const { return lock->isChecked(); }; + bool isRestricted() const { return restricted->isChecked(); }; + bool usePassword() const { return use_password->isChecked(); }; + QString Password() const { return password->text(); }; +private slots: + void check_pw(); +private: + liloimage *l; + QCheckBox *readonly; + QComboBox *vga; + QCheckBox *unsafe; + QCheckBox *lock; + QCheckBox *restricted; + QCheckBox *use_password; + QLineEdit *password; + QPushButton *ok; + QPushButton *cancel; +}; +#endif diff --git a/lilo-config/qt/InputBox.cpp b/lilo-config/qt/InputBox.cpp new file mode 100644 index 0000000..f95989b --- /dev/null +++ b/lilo-config/qt/InputBox.cpp @@ -0,0 +1,56 @@ +/* InputBox.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ + +#include "InputBox.moc" +#include <qlayout.h> +#include <qhbox.h> +#include <qwhatsthis.h> +#include <ui.h> + +InputBox::InputBox(entries e, QWidget *parent, const char *name, bool hasCancel, WFlags f):QDialog(parent, name, true, f) +{ + QVBoxLayout *layout=new QVBoxLayout(this); + layout->setMargin(SPACE_MARGIN); + layout->setSpacing(SPACE_INSIDE); + for(entries::iterator it=e.begin(); it!=e.end(); it++) { + EditWidget *ed=new EditWidget((*it).label, (*it).dflt, (*it).isFile, this); + QWhatsThis::add(ed, (*it).help); + layout->addWidget(ed); + edit.insert(edit.end(), ed); + } + if(hasCancel) { + QHBox *btns=new QHBox(this); + ok=new QPushButton(_("&OK"), btns); + cancel=new QPushButton(_("&Cancel"), btns); + layout->addWidget(btns); + connect(cancel, SIGNAL(clicked()), SLOT(reject())); + } else { + ok=new QPushButton(_("&OK"), this); + layout->addWidget(ok); + } + connect(ok, SIGNAL(clicked()), SLOT(accept())); +} diff --git a/lilo-config/qt/InputBox.h b/lilo-config/qt/InputBox.h new file mode 100644 index 0000000..da2371b --- /dev/null +++ b/lilo-config/qt/InputBox.h @@ -0,0 +1,49 @@ +/* InputBox.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ + +#ifndef _INPUTBOX_H_ +#define _INPUTBOX_H_ 1 +#include <qdialog.h> +#include <qlabel.h> +#include <qlineedit.h> +#include <qpushbutton.h> +#include "EditWidget.h" +#include <list> +class InputBox:public QDialog +{ + Q_OBJECT +public: + typedef struct { QString label; QString dflt; bool isFile; QString help; } entry; + typedef std::list<entry> entries; + InputBox(entries e, QWidget *parent=0, const char *name=0, bool hasCancel=true, WFlags f=0); + QStringList const text() const { QStringList s; for(std::list<EditWidget*>::const_iterator it=edit.begin(); it!=edit.end(); it++) s << (*it)->text(); return s; }; +private: + std::list<EditWidget*> edit; + QPushButton *ok; + QPushButton *cancel; +}; +#endif diff --git a/lilo-config/qt/Makefile.am b/lilo-config/qt/Makefile.am new file mode 100644 index 0000000..fa0fd6c --- /dev/null +++ b/lilo-config/qt/Makefile.am @@ -0,0 +1,21 @@ +libwidgets.a: ../kde-qt-common/*.cpp ../kde-qt-common/*.h + rm -f ../kde-qt-common/.COMPILED_KDE + if ! test -e ../kde-qt-common/.COMPILED_QT; then \ + perl -pi -e "s,^AM_CXXFLAGS.*,AM_CXXFLAGS = -UUSE_KDE," ../kde-qt-common/Makefile.am; \ + perl -pi -e "s,libwidgets_la_LIBADD.*,libwidgets_la_LIBADD = -lqt ../common/libcommon.la," ../kde-qt-common/Makefile.am; \ + make -C ../kde-qt-common clean; fi + make -C ../kde-qt-common + install -c -m755 ../kde-qt-common/.libs/libwidgets.a . + touch ../kde-qt-common/.COMPILED_QT + +INCLUDES= -I../common -I../kde-qt-common $(all_includes) + +bin_PROGRAMS = lilo-config + +lilo_config_SOURCES = standalone.cpp Details.cpp InputBox.cpp +lilo_config_LDFLAGS = $(all_libraries) +lilo_config_LDADD = $(LIB_QT) libwidgets.a +lilo_config_METASOURCES = AUTO +AM_CXXFLAGS = -UUSE_KDE + +KDE_OPTIONS = qtonly diff --git a/lilo-config/qt/configure.in.in b/lilo-config/qt/configure.in.in new file mode 100644 index 0000000..db37557 --- /dev/null +++ b/lilo-config/qt/configure.in.in @@ -0,0 +1,4 @@ +# There's no point in compiling the Qt-only frontend inside a KDE package... +# Leaving it out, but there's not much of a point in removing the code (it still +# has its uses), and it's quite short, so... +DO_NOT_COMPILE="$DO_NOT_COMPILE qt" diff --git a/lilo-config/qt/standalone.cpp b/lilo-config/qt/standalone.cpp new file mode 100644 index 0000000..268ad21 --- /dev/null +++ b/lilo-config/qt/standalone.cpp @@ -0,0 +1,126 @@ +/* standalone.cpp +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ + +#include <qapplication.h> +#include <qobject.h> +#include <qwhatsthis.h> +#include <qwindowsstyle.h> +#include <mainwidget.h> +#include <ui.h> +#include "standalone.moc" + +Standalone::Standalone(QWidget *parent, const char *name):QWidget(parent,name) +{ + m=new MainWidget(this); + connect(m, SIGNAL(configChanged()), SLOT(configChanged())); + actions=new QHButtonGroup(this); + _whatsthis=new QPushButton(_("&What's This?"), actions); + _whatsthis->setAccel(SHIFT+Key_F1); + QWhatsThis::add(_whatsthis, _("The <i>What's This?</i> button is part of this program's help system. Click on the What's This? button then on any widget in the window to get information (like this) on it.")); + connect(_whatsthis, SIGNAL(clicked()), SLOT(whatsthis())); + _help=new QPushButton(_("&Help"), actions); + _help->setAccel(Key_F1); + QWhatsThis::add(_help, _("This button calls up the program's online help system. If it does nothing, no help file has been written (yet); in that case, use the <i>What's This</i> button on the left.")); + connect(_help, SIGNAL(clicked()), this, SLOT(help())); + _deflt=new QPushButton(_("&Default"), actions); + QWhatsThis::add(_deflt, _("This button resets all parameters to some (hopefully sane) default values.")); + connect(_deflt, SIGNAL(clicked()), this, SLOT(defaults())); + _reset=new QPushButton(_("&Reset"), actions); + QWhatsThis::add(_reset, _("This button resets all parameters to what they were before you started the program.")); + connect(_reset, SIGNAL(clicked()), this, SLOT(reset())); + _apply=new QPushButton(_("&Apply"), actions); + QWhatsThis::add(_apply, _("This button saves all your changes without exiting.")); + connect(_apply, SIGNAL(clicked()), this, SLOT(apply())); + _ok=new QPushButton(_("&OK"), actions); + QWhatsThis::add(_ok, _("This button saves all your changes and exits the program.")); + connect(_ok, SIGNAL(clicked()), this, SLOT(ok())); + _cancel=new QPushButton(_("&Cancel"), actions); + QWhatsThis::add(_cancel, _("This button exits the program without saving your changes.")); + connect(_cancel, SIGNAL(clicked()), this, SLOT(cancel())); + _apply->setEnabled(false); + setMinimumWidth(actions->sizeHint().width()+10); + arrangeWidgets(); +} + +void Standalone::arrangeWidgets() +{ + m->setGeometry(SPACE_MARGIN, SPACE_MARGIN, width()-2*SPACE_MARGIN, height()-actions->sizeHint().height()-SPACE_MARGIN-SPACE_INSIDE); + actions->setGeometry(SPACE_MARGIN, height()-actions->sizeHint().height()-SPACE_MARGIN, width()-2*SPACE_MARGIN, actions->sizeHint().height()); +} + +void Standalone::resizeEvent(QResizeEvent *e) +{ + QWidget::resizeEvent(e); + arrangeWidgets(); +} + +void Standalone::whatsthis() +{ + QWhatsThis::enterWhatsThisMode(); +} +void Standalone::help() +{ +} +void Standalone::defaults() +{ + m->defaults(); +} +void Standalone::reset() +{ + m->reset(); +} +void Standalone::apply() +{ + m->save(); +} +void Standalone::ok() +{ + m->save(); + emit done(); +} +void Standalone::cancel() +{ + emit done(); +} + +void Standalone::configChanged() // SLOT +{ + _apply->setEnabled(true); +} + +int main(int argc, char **argv) { + QApplication a(argc, argv); + Standalone *s=new Standalone(0); + int ret; + a.setStyle(new QWindowsStyle()); + a.setMainWidget(s); + QObject::connect(s, SIGNAL(done()), &a, SLOT(quit())); + s->show(); + ret=a.exec(); + delete s; + return ret; +} diff --git a/lilo-config/qt/standalone.h b/lilo-config/qt/standalone.h new file mode 100644 index 0000000..8b0fa16 --- /dev/null +++ b/lilo-config/qt/standalone.h @@ -0,0 +1,64 @@ +/* standalone.h +** +** Copyright (C) 2000,2001 by Bernhard Rosenkraenzer +** +*/ + +/* +** 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 in a file called COPYING; if not, write to +** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +** MA 02110-1301, USA. +*/ + +/* +** Bug reports and questions can be sent to kde-devel@kde.org +*/ + +#ifndef _STANDALONE_H_ +#define _STANDALONE_H_ 1 +#include <qwidget.h> +#include <qpushbutton.h> +#include <qhbuttongroup.h> +#include <qevent.h> +#include "mainwidget.h" +class Standalone: public QWidget +{ + Q_OBJECT +public: + Standalone(QWidget *parent=0, const char *name=0); + void resizeEvent(QResizeEvent *e); +public slots: + void whatsthis(); + void help(); + void defaults(); + void reset(); + void apply(); + void ok(); + void cancel(); + void configChanged(); +signals: + void done(); +private: + void arrangeWidgets(); + MainWidget *m; + QHButtonGroup *actions; + QPushButton *_whatsthis; + QPushButton *_help; + QPushButton *_deflt; + QPushButton *_reset; + QPushButton *_apply; + QPushButton *_ok; + QPushButton *_cancel; +}; +#endif |