• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeinit
 

tdeinit

  • tdeinit
tdedostartupconfig.cpp
1/****************************************************************************
2
3 Copyright (C) 2005 Lubos Lunak <l.lunak@kde.org>
4
5Permission is hereby granted, free of charge, to any person obtaining a
6copy of this software and associated documentation files (the "Software"),
7to deal in the Software without restriction, including without limitation
8the rights to use, copy, modify, merge, publish, distribute, sublicense,
9and/or sell copies of the Software, and to permit persons to whom the
10Software is furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21DEALINGS IN THE SOFTWARE.
22
23****************************************************************************/
24
25#undef TQT_NO_CAST_ASCII
26
27// See description in tdestartupconfig.cpp .
28
29#include <tqfile.h>
30#include <tqtextstream.h>
31#include <kinstance.h>
32#include <tdestandarddirs.h>
33#include <tdeconfig.h>
34#include <kdebug.h>
35
36TQString get_entry( TQString* ll )
37 {
38 TQString& l = *ll;
39 l = l.stripWhiteSpace();
40 if( l.isEmpty())
41 return TQString::null;
42 TQString ret;
43 if( l[ 0 ] == '\'' )
44 {
45 unsigned int pos = 1;
46 while( pos < l.length() && l[ pos ] != '\'' )
47 ret += l[ pos++ ];
48 if( pos >= l.length())
49 {
50 *ll = TQString::null;
51 return TQString::null;
52 }
53 *ll = l.mid( pos + 1 );
54 return ret;
55 }
56 unsigned int pos = 0;
57 while( pos < l.length() && l[ pos ] != ' ' )
58 ret += l[ pos++ ];
59 *ll = l.mid( pos );
60 return ret;
61 }
62
63int main()
64 {
65 TDEInstance inst( "tdedostartupconfig" );
66 kdDebug() << "Running tdedostartupconfig." << endl;
67 TQString keysname = locateLocal( "config", "startupconfigkeys" );
68 TQFile keys( keysname );
69 if( !keys.open( IO_ReadOnly ))
70 return 3;
71 TQFile f1( locateLocal( "config", "startupconfig" ));
72 if( !f1.open( IO_WriteOnly ))
73 return 4;
74 TQFile f2( locateLocal( "config", "startupconfigfiles" ));
75 if( !f2.open( IO_WriteOnly ))
76 return 5;
77 TQTextStream startupconfig( &f1 );
78 TQTextStream startupconfigfiles( &f2 );
79 startupconfig << "#! /bin/sh\n";
80 for(;;)
81 {
82 TQString line;
83 if( keys.readLine( line, 1024 ) < 0 )
84 break;
85 line = line.stripWhiteSpace();
86 if( line.isEmpty())
87 break;
88 TQString tmp = line;
89 TQString file, group, key, def;
90 file = get_entry( &tmp );
91 group = get_entry( &tmp );
92 key = get_entry( &tmp );
93 def = get_entry( &tmp );
94 if( file.isEmpty() || group.isEmpty())
95 return 6;
96 if( group.left( 1 ) == "[" && group.right( 1 ) == "]" )
97 { // whole config group
98 TDEConfig cfg( file );
99 group = group.mid( 1, group.length() - 2 );
100 TQMap< TQString, TQString > entries = cfg.entryMap( group );
101 startupconfig << "# " << line << "\n";
102 for( TQMap< TQString, TQString >::ConstIterator it = entries.begin();
103 it != entries.end();
104 ++it )
105 {
106 TQString key = it.key();
107 TQString value = *it;
108 startupconfig << TQString(file.replace( ' ', '_' )).lower()
109 << "_" << TQString(group.replace( ' ', '_' )).lower()
110 << "_" << TQString(key.replace( ' ', '_' )).lower()
111 << "=\"" << value.replace( "\"", "\\\"" ) << "\"\n";
112 }
113 }
114 else
115 { // a single key
116 if( key.isEmpty())
117 return 7;
118 TDEConfig cfg( file );
119 cfg.setGroup( group );
120 TQString value = cfg.readEntry( key, def );
121 startupconfig << "# " << line << "\n";
122 startupconfig << TQString(file.replace( ' ', '_' )).lower()
123 << "_" << TQString(group.replace( ' ', '_' )).lower()
124 << "_" <<TQString( key.replace( ' ', '_' )).lower()
125 << "=\"" << value.replace( "\"", "\\\"" ) << "\"\n";
126 }
127 startupconfigfiles << line << endl;
128 // use even currently non-existing paths in $TDEDIRS
129 TQStringList dirs = TQStringList::split( KPATH_SEPARATOR, TDEGlobal::dirs()->kfsstnd_prefixes());
130 for( TQStringList::ConstIterator it = dirs.begin();
131 it != dirs.end();
132 ++it )
133 {
134 TQString cfg = *it + "share/config/" + file;
135 if( TDEStandardDirs::exists( cfg ))
136 startupconfigfiles << cfg << "\n";
137 else
138 startupconfigfiles << "!" << cfg << "\n";
139 }
140 startupconfigfiles << "*\n";
141 }
142 return 0;
143 }

tdeinit

Skip menu "tdeinit"
  • Main Page
  • File List
  • Related Pages

tdeinit

Skip menu "tdeinit"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeinit by doxygen 1.9.4
This website is maintained by Timothy Pearson.