author | tille <tille> | 2002-05-12 12:07:14 (UTC) |
---|---|---|
committer | tille <tille> | 2002-05-12 12:07:14 (UTC) |
commit | 06e723cc7942af2691828e7fdc6a6ec47b44edab (patch) (unidiff) | |
tree | f96bd547911c4fdc2aa8db95bd6175ebae02b027 | |
parent | 026a99ad2360a9abc2964cbdc3b71b49adcd66e6 (diff) | |
download | opie-06e723cc7942af2691828e7fdc6a6ec47b44edab.zip opie-06e723cc7942af2691828e7fdc6a6ec47b44edab.tar.gz opie-06e723cc7942af2691828e7fdc6a6ec47b44edab.tar.bz2 |
fixed crash when remove dest
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 10 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/settings.cpp | 4 |
5 files changed, 20 insertions, 10 deletions
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 19a1420..a23c900 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp | |||
@@ -1,493 +1,493 @@ | |||
1 | // adadpted form qpe/qipkg | 1 | // adadpted form qpe/qipkg |
2 | 2 | ||
3 | 3 | ||
4 | #include "mainwindow.h" | 4 | #include "mainwindow.h" |
5 | 5 | ||
6 | #include <qpe/qpemenubar.h> | 6 | #include <qpe/qpemenubar.h> |
7 | #include <qpe/qpemessagebox.h> | 7 | #include <qpe/qpemessagebox.h> |
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | #include <qpe/qpetoolbar.h> | 10 | #include <qpe/qpetoolbar.h> |
11 | #include <qpe/qcopenvelope_qws.h> | 11 | #include <qpe/qcopenvelope_qws.h> |
12 | #include <qaction.h> | 12 | #include <qaction.h> |
13 | #include <qmessagebox.h> | 13 | #include <qmessagebox.h> |
14 | #include <qpopupmenu.h> | 14 | #include <qpopupmenu.h> |
15 | #include <qtoolbutton.h> | 15 | #include <qtoolbutton.h> |
16 | #include <qstring.h> | 16 | #include <qstring.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qfile.h> | 18 | #include <qfile.h> |
19 | #include <qlistview.h> | 19 | #include <qlistview.h> |
20 | #include <qtextview.h> | 20 | #include <qtextview.h> |
21 | #include <qcheckbox.h> | 21 | #include <qcheckbox.h> |
22 | #include <qlineedit.h> | 22 | #include <qlineedit.h> |
23 | #include <qtabwidget.h> | 23 | #include <qtabwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | 28 | ||
29 | #include "pksettingsbase.h" | 29 | #include "pksettingsbase.h" |
30 | #include "utils.h" | 30 | #include "utils.h" |
31 | #include "packagelistitem.h" | 31 | #include "packagelistitem.h" |
32 | 32 | ||
33 | 33 | ||
34 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : | 34 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : |
35 | QMainWindow( parent, name, f ) | 35 | QMainWindow( parent, name, f ) |
36 | { | 36 | { |
37 | setCaption( tr("Package Manager") ); | 37 | setCaption( tr("Package Manager") ); |
38 | settings = new PackageManagerSettings(this,0,TRUE); | 38 | settings = new PackageManagerSettings(this,0,TRUE); |
39 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); | 39 | listViewPackages = new PackageListView( this,"listViewPackages",settings ); |
40 | setCentralWidget( listViewPackages ); | 40 | setCentralWidget( listViewPackages ); |
41 | listViewPackages->addList( tr("feeds"), &packageListServers ); | 41 | listViewPackages->addList( tr("feeds"), &packageListServers ); |
42 | listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); | 42 | listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); |
43 | listViewPackages->addList( tr("documents"), &packageListDocLnk ); | 43 | listViewPackages->addList( tr("documents"), &packageListDocLnk ); |
44 | //wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); | 44 | //wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); |
45 | //wait = new QMessageBox(this); | 45 | //wait = new QMessageBox(this); |
46 | // wait->setText(tr("Please wait")); | 46 | // wait->setText(tr("Please wait")); |
47 | ipkg = new PmIpkg( settings, this ); | 47 | ipkg = new PmIpkg( settings, this ); |
48 | // settings->setIpkg( ipkg ); | 48 | // settings->setIpkg( ipkg ); |
49 | packageListServers.setSettings( settings ); | 49 | packageListServers.setSettings( settings ); |
50 | packageListSearch.setSettings( settings ); | 50 | packageListSearch.setSettings( settings ); |
51 | packageListDocLnk.setSettings( settings ); | 51 | packageListDocLnk.setSettings( settings ); |
52 | pvDebug(9,"packageListServers.update"); | 52 | pvDebug(9,"packageListServers.update"); |
53 | packageListServers.update(); | 53 | packageListServers.update(); |
54 | pvDebug(9,"packageListDocLnk.update"); | 54 | pvDebug(9,"packageListDocLnk.update"); |
55 | packageListDocLnk.update(); | 55 | packageListDocLnk.update(); |
56 | pvDebug(9,"makeMenu"); | 56 | pvDebug(9,"makeMenu"); |
57 | makeMenu(); | 57 | makeMenu(); |
58 | makeChannel(); | 58 | makeChannel(); |
59 | //opie is hardcoded default ;) | 59 | //opie is hardcoded default ;) |
60 | pvDebug(9,"section->setCurrentItem"); | 60 | //pvDebug(9,"section->setCurrentItem"); |
61 | for (int i=0;i<section->count();i++) | 61 | // for (int i=0;i<section->count();i++) |
62 | if (section->text(i)=="opie") | 62 | // if (section->text(i)=="opie") |
63 | section->setCurrentItem(i); | 63 | // section->setCurrentItem(i); |
64 | sectionChanged(); | 64 | // sectionChanged(); |
65 | 65 | ||
66 | connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); | 66 | connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); |
67 | connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); | 67 | connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); |
68 | 68 | ||
69 | connect( settings->removeLinksButton, SIGNAL( clicked()), | 69 | connect( settings->removeLinksButton, SIGNAL( clicked()), |
70 | SLOT(removeLinks()) ); | 70 | SLOT(removeLinks()) ); |
71 | connect( settings->createLinksButton, SIGNAL( clicked()), | 71 | connect( settings->createLinksButton, SIGNAL( clicked()), |
72 | SLOT(createLinks()) ); | 72 | SLOT(createLinks()) ); |
73 | 73 | ||
74 | pvDebug(9,"displayList"); | 74 | pvDebug(9,"displayList"); |
75 | displayList(); | 75 | displayList(); |
76 | } | 76 | } |
77 | 77 | ||
78 | void MainWindow::makeMenu() | 78 | void MainWindow::makeMenu() |
79 | { | 79 | { |
80 | 80 | ||
81 | QPEToolBar *toolBar = new QPEToolBar( this ); | 81 | QPEToolBar *toolBar = new QPEToolBar( this ); |
82 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); | 82 | QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); |
83 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); | 83 | QPopupMenu *srvMenu = new QPopupMenu( menuBar ); |
84 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); | 84 | QPopupMenu *viewMenu = new QPopupMenu( menuBar ); |
85 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); | 85 | QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); |
86 | // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); | 86 | // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); |
87 | 87 | ||
88 | setToolBarsMovable( false ); | 88 | setToolBarsMovable( false ); |
89 | toolBar->setHorizontalStretchable( true ); | 89 | toolBar->setHorizontalStretchable( true ); |
90 | menuBar->insertItem( tr( "Package" ), srvMenu ); | 90 | menuBar->insertItem( tr( "Package" ), srvMenu ); |
91 | menuBar->insertItem( tr( "View" ), viewMenu ); | 91 | menuBar->insertItem( tr( "View" ), viewMenu ); |
92 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 92 | menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
93 | // menuBar->insertItem( tr( "Sections" ), sectMenu ); | 93 | // menuBar->insertItem( tr( "Sections" ), sectMenu ); |
94 | 94 | ||
95 | QLabel *spacer; | 95 | QLabel *spacer; |
96 | // spacer = new QLabel( "", toolBar ); | 96 | // spacer = new QLabel( "", toolBar ); |
97 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); | 97 | // spacer->setBackgroundColor( toolBar->backgroundColor() ); |
98 | // toolBar->setStretchableWidget( spacer ); | 98 | // toolBar->setStretchableWidget( spacer ); |
99 | 99 | ||
100 | 100 | ||
101 | runAction = new QAction( tr( "Apply" ), | 101 | runAction = new QAction( tr( "Apply" ), |
102 | Resource::loadPixmap( "oipkg/install" ), | 102 | Resource::loadPixmap( "oipkg/install" ), |
103 | QString::null, 0, this, 0 ); | 103 | QString::null, 0, this, 0 ); |
104 | connect( runAction, SIGNAL( activated() ), | 104 | connect( runAction, SIGNAL( activated() ), |
105 | this, SLOT( runIpkg() ) ); | 105 | this, SLOT( runIpkg() ) ); |
106 | runAction->addTo( toolBar ); | 106 | runAction->addTo( toolBar ); |
107 | runAction->addTo( srvMenu ); | 107 | runAction->addTo( srvMenu ); |
108 | 108 | ||
109 | srvMenu->insertSeparator (); | 109 | srvMenu->insertSeparator (); |
110 | 110 | ||
111 | updateAction = new QAction( tr( "Update" ), | 111 | updateAction = new QAction( tr( "Update" ), |
112 | Resource::loadIconSet( "oipkg/update" ), | 112 | Resource::loadIconSet( "oipkg/update" ), |
113 | QString::null, 0, this, 0 ); | 113 | QString::null, 0, this, 0 ); |
114 | connect( updateAction, SIGNAL( activated() ), | 114 | connect( updateAction, SIGNAL( activated() ), |
115 | this , SLOT( updateList() ) ); | 115 | this , SLOT( updateList() ) ); |
116 | updateAction->addTo( toolBar ); | 116 | updateAction->addTo( toolBar ); |
117 | updateAction->addTo( srvMenu ); | 117 | updateAction->addTo( srvMenu ); |
118 | 118 | ||
119 | QAction *cfgact; | 119 | QAction *cfgact; |
120 | 120 | ||
121 | cfgact = new QAction( tr( "Setups" ), | 121 | cfgact = new QAction( tr( "Setups" ), |
122 | QString::null, 0, this, 0 ); | 122 | QString::null, 0, this, 0 ); |
123 | connect( cfgact, SIGNAL( activated() ), | 123 | connect( cfgact, SIGNAL( activated() ), |
124 | SLOT( showSettings() ) ); | 124 | SLOT( showSettings() ) ); |
125 | cfgact->addTo( cfgMenu ); | 125 | cfgact->addTo( cfgMenu ); |
126 | 126 | ||
127 | cfgact = new QAction( tr( "Servers" ), | 127 | cfgact = new QAction( tr( "Servers" ), |
128 | QString::null, 0, this, 0 ); | 128 | QString::null, 0, this, 0 ); |
129 | connect( cfgact, SIGNAL( activated() ), | 129 | connect( cfgact, SIGNAL( activated() ), |
130 | SLOT( showSettingsSrv() ) ); | 130 | SLOT( showSettingsSrv() ) ); |
131 | cfgact->addTo( cfgMenu ); | 131 | cfgact->addTo( cfgMenu ); |
132 | cfgact = new QAction( tr( "Destinations" ), | 132 | cfgact = new QAction( tr( "Destinations" ), |
133 | QString::null, 0, this, 0 ); | 133 | QString::null, 0, this, 0 ); |
134 | connect( cfgact, SIGNAL( activated() ), | 134 | connect( cfgact, SIGNAL( activated() ), |
135 | SLOT( showSettingsDst() ) ); | 135 | SLOT( showSettingsDst() ) ); |
136 | cfgact->addTo( cfgMenu ); | 136 | cfgact->addTo( cfgMenu ); |
137 | 137 | ||
138 | QAction *a; | 138 | QAction *a; |
139 | 139 | ||
140 | // SECTIONS | 140 | // SECTIONS |
141 | sectionBar = new QPEToolBar( this ); | 141 | sectionBar = new QPEToolBar( this ); |
142 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); | 142 | addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); |
143 | sectionBar->setHorizontalStretchable( true ); | 143 | sectionBar->setHorizontalStretchable( true ); |
144 | QLabel *label = new QLabel( tr("Section: "), sectionBar ); | 144 | QLabel *label = new QLabel( tr("Section: "), sectionBar ); |
145 | label->setBackgroundColor( sectionBar->backgroundColor() ); | 145 | label->setBackgroundColor( sectionBar->backgroundColor() ); |
146 | sectionBar->setStretchableWidget( label ); | 146 | sectionBar->setStretchableWidget( label ); |
147 | section = new QComboBox( false, sectionBar ); | 147 | section = new QComboBox( false, sectionBar ); |
148 | label = new QLabel( " / ", sectionBar ); | 148 | label = new QLabel( " / ", sectionBar ); |
149 | label->setBackgroundColor( sectionBar->backgroundColor() ); | 149 | label->setBackgroundColor( sectionBar->backgroundColor() ); |
150 | subsection = new QComboBox( false, sectionBar ); | 150 | subsection = new QComboBox( false, sectionBar ); |
151 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 151 | a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
152 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); | 152 | connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); |
153 | a->addTo( sectionBar ); | 153 | a->addTo( sectionBar ); |
154 | setSections(); | 154 | setSections(); |
155 | setSubSections(); | 155 | setSubSections(); |
156 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); | 156 | sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); |
157 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); | 157 | connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); |
158 | sectionAction->setToggleAction( true ); | 158 | sectionAction->setToggleAction( true ); |
159 | sectionAction->addTo( viewMenu ); | 159 | sectionAction->addTo( viewMenu ); |
160 | 160 | ||
161 | //FIND | 161 | //FIND |
162 | findBar = new QPEToolBar(this); | 162 | findBar = new QPEToolBar(this); |
163 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); | 163 | addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); |
164 | label = new QLabel( tr("Filter: "), findBar ); | 164 | label = new QLabel( tr("Filter: "), findBar ); |
165 | label->setBackgroundColor( findBar->backgroundColor() ); | 165 | label->setBackgroundColor( findBar->backgroundColor() ); |
166 | findBar->setHorizontalStretchable( TRUE ); | 166 | findBar->setHorizontalStretchable( TRUE ); |
167 | findEdit = new QLineEdit( findBar, "findEdit" ); | 167 | findEdit = new QLineEdit( findBar, "findEdit" ); |
168 | findBar->setStretchableWidget( findEdit ); | 168 | findBar->setStretchableWidget( findEdit ); |
169 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), | 169 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), |
170 | this, SLOT( displayList() ) ); | 170 | this, SLOT( displayList() ) ); |
171 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 171 | a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
172 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); | 172 | connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); |
173 | a->addTo( findBar ); | 173 | a->addTo( findBar ); |
174 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 174 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
175 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 175 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
176 | a->addTo( findBar ); | 176 | a->addTo( findBar ); |
177 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); | 177 | findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); |
178 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); | 178 | connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); |
179 | findAction->setToggleAction( true ); | 179 | findAction->setToggleAction( true ); |
180 | findAction->addTo( viewMenu ); | 180 | findAction->addTo( viewMenu ); |
181 | 181 | ||
182 | //SEARCH | 182 | //SEARCH |
183 | searchBar = new QPEToolBar(this); | 183 | searchBar = new QPEToolBar(this); |
184 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 184 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
185 | label = new QLabel( tr("ipkgfind: "), searchBar ); | 185 | label = new QLabel( tr("ipkgfind: "), searchBar ); |
186 | label->setBackgroundColor( searchBar->backgroundColor() ); | 186 | label->setBackgroundColor( searchBar->backgroundColor() ); |
187 | searchBar->setHorizontalStretchable( TRUE ); | 187 | searchBar->setHorizontalStretchable( TRUE ); |
188 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 188 | searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
189 | searchBar->setStretchableWidget( searchEdit ); | 189 | searchBar->setStretchableWidget( searchEdit ); |
190 | // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 190 | // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
191 | // this, SLOT( displayList() ) ); | 191 | // this, SLOT( displayList() ) ); |
192 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 192 | a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
193 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); | 193 | connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); |
194 | a->addTo( searchBar ); | 194 | a->addTo( searchBar ); |
195 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 195 | searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
196 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); | 196 | connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); |
197 | searchCommit->addTo( searchBar ); | 197 | searchCommit->addTo( searchBar ); |
198 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 198 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
199 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); | 199 | connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); |
200 | a->addTo( searchBar ); | 200 | a->addTo( searchBar ); |
201 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); | 201 | searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); |
202 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); | 202 | connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); |
203 | searchAction->setToggleAction( true ); | 203 | searchAction->setToggleAction( true ); |
204 | searchAction->addTo( viewMenu ); | 204 | searchAction->addTo( viewMenu ); |
205 | 205 | ||
206 | //DEST | 206 | //DEST |
207 | destBar = new QPEToolBar(this); | 207 | destBar = new QPEToolBar(this); |
208 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); | 208 | addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); |
209 | label = new QLabel( tr("Destination: "), destBar ); | 209 | label = new QLabel( tr("Destination: "), destBar ); |
210 | label->setBackgroundColor( destBar->backgroundColor() ); | 210 | label->setBackgroundColor( destBar->backgroundColor() ); |
211 | destBar->setHorizontalStretchable( TRUE ); | 211 | destBar->setHorizontalStretchable( TRUE ); |
212 | destination = new QComboBox( false, destBar ); | 212 | destination = new QComboBox( false, destBar ); |
213 | destination->insertStringList( settings->getDestinationNames() ); | 213 | destination->insertStringList( settings->getDestinationNames() ); |
214 | setComboName(destination,settings->getDestinationName()); | 214 | setComboName(destination,settings->getDestinationName()); |
215 | connect( destination, SIGNAL(activated(int)), | 215 | connect( destination, SIGNAL(activated(int)), |
216 | settings, SLOT(activeDestinationChange(int)) ); | 216 | settings, SLOT(activeDestinationChange(int)) ); |
217 | spacer = new QLabel( " ", destBar ); | 217 | spacer = new QLabel( " ", destBar ); |
218 | spacer->setBackgroundColor( destBar->backgroundColor() ); | 218 | spacer->setBackgroundColor( destBar->backgroundColor() ); |
219 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); | 219 | CheckBoxLink = new QCheckBox( tr("Link"), destBar); |
220 | CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); | 220 | CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); |
221 | CheckBoxLink->setChecked( settings->createLinks() ); | 221 | CheckBoxLink->setChecked( settings->createLinks() ); |
222 | connect( CheckBoxLink, SIGNAL(toggled(bool)), | 222 | connect( CheckBoxLink, SIGNAL(toggled(bool)), |
223 | settings, SLOT(linkEnabled(bool)) ); | 223 | settings, SLOT(linkEnabled(bool)) ); |
224 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); | 224 | destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); |
225 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); | 225 | connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); |
226 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 226 | a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
227 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); | 227 | connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); |
228 | a->addTo( destBar ); | 228 | a->addTo( destBar ); |
229 | destBar->setStretchableWidget( CheckBoxLink ); | 229 | destBar->setStretchableWidget( CheckBoxLink ); |
230 | destAction->setToggleAction( true ); | 230 | destAction->setToggleAction( true ); |
231 | // destAction->addTo( viewMenu ); | 231 | // destAction->addTo( viewMenu ); |
232 | 232 | ||
233 | // configure the menus | 233 | // configure the menus |
234 | Config cfg( "oipkg", Config::User ); | 234 | Config cfg( "oipkg", Config::User ); |
235 | cfg.setGroup( "gui" ); | 235 | cfg.setGroup( "gui" ); |
236 | 236 | ||
237 | findShow( cfg.readBoolEntry( "findBar", true ) ); | 237 | findShow( cfg.readBoolEntry( "findBar", true ) ); |
238 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); | 238 | searchShow( cfg.readBoolEntry( "searchBar", true ) ); |
239 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); | 239 | sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); |
240 | destShow( cfg.readBoolEntry( "destBar", false ) ); | 240 | destShow( cfg.readBoolEntry( "destBar", false ) ); |
241 | } | 241 | } |
242 | 242 | ||
243 | MainWindow::~MainWindow() | 243 | MainWindow::~MainWindow() |
244 | { | 244 | { |
245 | Config cfg( "oipkg", Config::User ); | 245 | Config cfg( "oipkg", Config::User ); |
246 | cfg.setGroup( "gui" ); | 246 | cfg.setGroup( "gui" ); |
247 | cfg.writeEntry( "findBar", !findBar->isHidden() ); | 247 | cfg.writeEntry( "findBar", !findBar->isHidden() ); |
248 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); | 248 | cfg.writeEntry( "searchBar", !searchBar->isHidden() ); |
249 | cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); | 249 | cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); |
250 | cfg.writeEntry( "destBar", !destBar->isHidden() ); | 250 | cfg.writeEntry( "destBar", !destBar->isHidden() ); |
251 | 251 | ||
252 | } | 252 | } |
253 | 253 | ||
254 | void MainWindow::runIpkg() | 254 | void MainWindow::runIpkg() |
255 | { | 255 | { |
256 | packageListServers.allPackages(); | 256 | packageListServers.allPackages(); |
257 | ipkg->loadList( &packageListSearch ); | 257 | ipkg->loadList( &packageListSearch ); |
258 | ipkg->loadList( &packageListDocLnk ); | 258 | ipkg->loadList( &packageListDocLnk ); |
259 | ipkg->loadList( &packageListServers ); | 259 | ipkg->loadList( &packageListServers ); |
260 | ipkg->commit(); | 260 | ipkg->commit(); |
261 | // ##### If we looked in the list of files, we could send out accurate | 261 | // ##### If we looked in the list of files, we could send out accurate |
262 | // ##### messages. But we don't bother yet, and just do an "all". | 262 | // ##### messages. But we don't bother yet, and just do an "all". |
263 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 263 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
264 | QString lf = QString::null; | 264 | QString lf = QString::null; |
265 | e << lf; | 265 | e << lf; |
266 | displayList(); | 266 | displayList(); |
267 | } | 267 | } |
268 | 268 | ||
269 | void MainWindow::updateList() | 269 | void MainWindow::updateList() |
270 | { | 270 | { |
271 | //wait->show(); | 271 | //wait->show(); |
272 | QTimer *t = new QTimer( this ); | 272 | QTimer *t = new QTimer( this ); |
273 | connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) ); | 273 | connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) ); |
274 | t->start( 0, false ); | 274 | t->start( 0, false ); |
275 | packageListServers.clear(); | 275 | packageListServers.clear(); |
276 | packageListSearch.clear(); | 276 | packageListSearch.clear(); |
277 | packageListDocLnk.clear(); | 277 | packageListDocLnk.clear(); |
278 | ipkg->update(); | 278 | ipkg->update(); |
279 | packageListServers.update(); | 279 | packageListServers.update(); |
280 | packageListSearch.update(); | 280 | packageListSearch.update(); |
281 | packageListDocLnk.update(); | 281 | packageListDocLnk.update(); |
282 | t->stop(); | 282 | t->stop(); |
283 | // wait->hide(); | 283 | // wait->hide(); |
284 | } | 284 | } |
285 | 285 | ||
286 | void MainWindow::filterList() | 286 | void MainWindow::filterList() |
287 | { | 287 | { |
288 | //wait->show(); | 288 | //wait->show(); |
289 | QString f = ""; | 289 | QString f = ""; |
290 | if ( findAction->isOn() ) f = findEdit->text(); | 290 | if ( findAction->isOn() ) f = findEdit->text(); |
291 | packageListServers.filterPackages( f ); | 291 | packageListServers.filterPackages( f ); |
292 | //wait->hide(); | 292 | //wait->hide(); |
293 | } | 293 | } |
294 | 294 | ||
295 | void MainWindow::displayList() | 295 | void MainWindow::displayList() |
296 | { | 296 | { |
297 | //wait->hide(); | 297 | //wait->hide(); |
298 | filterList(); | 298 | filterList(); |
299 | listViewPackages->display(); | 299 | listViewPackages->display(); |
300 | } | 300 | } |
301 | 301 | ||
302 | void MainWindow::sectionChanged() | 302 | void MainWindow::sectionChanged() |
303 | { | 303 | { |
304 | disconnect( section, SIGNAL( activated(int) ), | 304 | disconnect( section, SIGNAL( activated(int) ), |
305 | this, SLOT( sectionChanged() ) ); | 305 | this, SLOT( sectionChanged() ) ); |
306 | disconnect( subsection, SIGNAL(activated(int) ), | 306 | disconnect( subsection, SIGNAL(activated(int) ), |
307 | this, SLOT( subSectionChanged() ) ); | 307 | this, SLOT( subSectionChanged() ) ); |
308 | subsection->clear(); | 308 | subsection->clear(); |
309 | packageListServers.setSection( section->currentText() ); | 309 | packageListServers.setSection( section->currentText() ); |
310 | setSubSections(); | 310 | setSubSections(); |
311 | connect( section, SIGNAL( activated(int) ), | 311 | connect( section, SIGNAL( activated(int) ), |
312 | this, SLOT( sectionChanged() ) ); | 312 | this, SLOT( sectionChanged() ) ); |
313 | connect( subsection, SIGNAL(activated(int) ), | 313 | connect( subsection, SIGNAL(activated(int) ), |
314 | this, SLOT( subSectionChanged() ) ); | 314 | this, SLOT( subSectionChanged() ) ); |
315 | displayList(); | 315 | displayList(); |
316 | } | 316 | } |
317 | 317 | ||
318 | void MainWindow::subSectionChanged() | 318 | void MainWindow::subSectionChanged() |
319 | { | 319 | { |
320 | disconnect( section, SIGNAL( activated(int) ), | 320 | disconnect( section, SIGNAL( activated(int) ), |
321 | this, SLOT( sectionChanged() ) ); | 321 | this, SLOT( sectionChanged() ) ); |
322 | disconnect( subsection, SIGNAL(activated(int) ), | 322 | disconnect( subsection, SIGNAL(activated(int) ), |
323 | this, SLOT( subSectionChanged() ) ); | 323 | this, SLOT( subSectionChanged() ) ); |
324 | packageListServers.setSubSection( subsection->currentText() ); | 324 | packageListServers.setSubSection( subsection->currentText() ); |
325 | connect( section, SIGNAL( activated(int) ), | 325 | connect( section, SIGNAL( activated(int) ), |
326 | this, SLOT( sectionChanged() ) ); | 326 | this, SLOT( sectionChanged() ) ); |
327 | connect( subsection, SIGNAL(activated(int) ), | 327 | connect( subsection, SIGNAL(activated(int) ), |
328 | this, SLOT( subSectionChanged() ) ); | 328 | this, SLOT( subSectionChanged() ) ); |
329 | displayList(); | 329 | displayList(); |
330 | } | 330 | } |
331 | 331 | ||
332 | void MainWindow::setSections() | 332 | void MainWindow::setSections() |
333 | { | 333 | { |
334 | section->clear(); | 334 | section->clear(); |
335 | section->insertStringList( packageListServers.getSections() ); | 335 | section->insertStringList( packageListServers.getSections() ); |
336 | } | 336 | } |
337 | 337 | ||
338 | void MainWindow::setSubSections() | 338 | void MainWindow::setSubSections() |
339 | { | 339 | { |
340 | subsection->clear(); | 340 | subsection->clear(); |
341 | subsection->insertStringList( packageListServers.getSubSections() ); | 341 | subsection->insertStringList( packageListServers.getSubSections() ); |
342 | } | 342 | } |
343 | 343 | ||
344 | 344 | ||
345 | void MainWindow::showSettings() | 345 | void MainWindow::showSettings() |
346 | { | 346 | { |
347 | if ( settings->showDialog( 0 ) ) | 347 | if ( settings->showDialog( 0 ) ) |
348 | updateList(); | 348 | updateList(); |
349 | } | 349 | } |
350 | void MainWindow::showSettingsSrv() | 350 | void MainWindow::showSettingsSrv() |
351 | { | 351 | { |
352 | if ( settings->showDialog( 1 ) ) | 352 | if ( settings->showDialog( 1 ) ) |
353 | updateList(); | 353 | updateList(); |
354 | } | 354 | } |
355 | void MainWindow::showSettingsDst() | 355 | void MainWindow::showSettingsDst() |
356 | { | 356 | { |
357 | if ( settings->showDialog( 2 ) ) | 357 | if ( settings->showDialog( 2 ) ) |
358 | updateList(); | 358 | updateList(); |
359 | } | 359 | } |
360 | 360 | ||
361 | void MainWindow::sectionShow(bool b) | 361 | void MainWindow::sectionShow(bool b) |
362 | { | 362 | { |
363 | if (b) sectionBar->show(); | 363 | if (b) sectionBar->show(); |
364 | else sectionBar->hide(); | 364 | else sectionBar->hide(); |
365 | sectionAction->setOn( b ); | 365 | sectionAction->setOn( b ); |
366 | } | 366 | } |
367 | 367 | ||
368 | void MainWindow::sectionClose() | 368 | void MainWindow::sectionClose() |
369 | { | 369 | { |
370 | sectionAction->setOn( false ); | 370 | sectionAction->setOn( false ); |
371 | } | 371 | } |
372 | 372 | ||
373 | void MainWindow::findShow(bool b) | 373 | void MainWindow::findShow(bool b) |
374 | { | 374 | { |
375 | if (b) findBar->show(); | 375 | if (b) findBar->show(); |
376 | else findBar->hide(); | 376 | else findBar->hide(); |
377 | findAction->setOn( b ); | 377 | findAction->setOn( b ); |
378 | } | 378 | } |
379 | 379 | ||
380 | void MainWindow::findClose() | 380 | void MainWindow::findClose() |
381 | { | 381 | { |
382 | findAction->setOn( false ); | 382 | findAction->setOn( false ); |
383 | } | 383 | } |
384 | 384 | ||
385 | void MainWindow::searchShow(bool b) | 385 | void MainWindow::searchShow(bool b) |
386 | { | 386 | { |
387 | if (b) searchBar->show(); | 387 | if (b) searchBar->show(); |
388 | else searchBar->hide(); | 388 | else searchBar->hide(); |
389 | searchAction->setOn( b ); | 389 | searchAction->setOn( b ); |
390 | } | 390 | } |
391 | 391 | ||
392 | void MainWindow::searchClose() | 392 | void MainWindow::searchClose() |
393 | { | 393 | { |
394 | searchAction->setOn( false ); | 394 | searchAction->setOn( false ); |
395 | } | 395 | } |
396 | 396 | ||
397 | 397 | ||
398 | void MainWindow::destShow(bool b) | 398 | void MainWindow::destShow(bool b) |
399 | { | 399 | { |
400 | if (b) destBar->show(); | 400 | if (b) destBar->show(); |
401 | else destBar->hide(); | 401 | else destBar->hide(); |
402 | destAction->setOn( b ); | 402 | destAction->setOn( b ); |
403 | } | 403 | } |
404 | 404 | ||
405 | void MainWindow::destClose() | 405 | void MainWindow::destClose() |
406 | { | 406 | { |
407 | destAction->setOn( false ); | 407 | destAction->setOn( false ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void MainWindow::rotateUpdateIcon() | 410 | void MainWindow::rotateUpdateIcon() |
411 | { | 411 | { |
412 | pvDebug(2, "MainWindow::rotateUpdateIcon"); | 412 | pvDebug(2, "MainWindow::rotateUpdateIcon"); |
413 | if ( updateIcon ) | 413 | if ( updateIcon ) |
414 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); | 414 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); |
415 | else | 415 | else |
416 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) ); | 416 | updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) ); |
417 | updateIcon = !updateIcon; | 417 | updateIcon = !updateIcon; |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
421 | void MainWindow::setDocument(const QString &fileName) | 421 | void MainWindow::setDocument(const QString &fileName) |
422 | { | 422 | { |
423 | installFile(fileName); | 423 | installFile(fileName); |
424 | // ##### If we looked in the list of files, we could send out accurate | 424 | // ##### If we looked in the list of files, we could send out accurate |
425 | // ##### messages. But we don't bother yet, and just do an "all". | 425 | // ##### messages. But we don't bother yet, and just do an "all". |
426 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 426 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
427 | QString lf = QString::null; | 427 | QString lf = QString::null; |
428 | e << lf; | 428 | e << lf; |
429 | // displayList(); | 429 | // displayList(); |
430 | exit; | 430 | exit; |
431 | } | 431 | } |
432 | 432 | ||
433 | void MainWindow::installFile(const QString &fileName) | 433 | void MainWindow::installFile(const QString &fileName) |
434 | { | 434 | { |
435 | pvDebug(3, "MainWindow::installFile "+fileName); | 435 | pvDebug(3, "MainWindow::installFile "+fileName); |
436 | if ( !QFile::exists( fileName ) ) return; | 436 | if ( !QFile::exists( fileName ) ) return; |
437 | ipkg->installFile( fileName ); | 437 | ipkg->installFile( fileName ); |
438 | // ##### If we looked in the list of files, we could send out accurate | 438 | // ##### If we looked in the list of files, we could send out accurate |
439 | // ##### messages. But we don't bother yet, and just do an "all". | 439 | // ##### messages. But we don't bother yet, and just do an "all". |
440 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 440 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
441 | QString lf = QString::null; | 441 | QString lf = QString::null; |
442 | e << lf; | 442 | e << lf; |
443 | displayList(); | 443 | displayList(); |
444 | } | 444 | } |
445 | 445 | ||
446 | void MainWindow::makeChannel() | 446 | void MainWindow::makeChannel() |
447 | { | 447 | { |
448 | channel = new QCopChannel( "QPE/Application/oipkg", this ); | 448 | channel = new QCopChannel( "QPE/Application/oipkg", this ); |
449 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 449 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
450 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 450 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
451 | } | 451 | } |
452 | 452 | ||
453 | 453 | ||
454 | 454 | ||
455 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) | 455 | void MainWindow::receive(const QCString &msg, const QByteArray &arg) |
456 | { | 456 | { |
457 | pvDebug(3, "QCop "+msg+" "+QCString(arg)); | 457 | pvDebug(3, "QCop "+msg+" "+QCString(arg)); |
458 | if ( msg == "installFile(QString)" ) | 458 | if ( msg == "installFile(QString)" ) |
459 | { | 459 | { |
460 | ipkg->installFile( QString(arg) ); | 460 | ipkg->installFile( QString(arg) ); |
461 | }else if( msg == "removeFile(QString)" ) | 461 | }else if( msg == "removeFile(QString)" ) |
462 | { | 462 | { |
463 | ipkg->removeFile( QString(arg) ); | 463 | ipkg->removeFile( QString(arg) ); |
464 | }else if( msg == "createLinks(QString)" ) | 464 | }else if( msg == "createLinks(QString)" ) |
465 | { | 465 | { |
466 | ipkg->createLinks( QString(arg) ); | 466 | ipkg->createLinks( QString(arg) ); |
467 | }else if( msg == "removeLinks(QString)" ) | 467 | }else if( msg == "removeLinks(QString)" ) |
468 | { | 468 | { |
469 | ipkg->removeLinks( QString(arg) ); | 469 | ipkg->removeLinks( QString(arg) ); |
470 | }else{ | 470 | }else{ |
471 | pvDebug(2,"Huh what do ya want") | 471 | pvDebug(2,"Huh what do ya want") |
472 | } | 472 | } |
473 | } | 473 | } |
474 | 474 | ||
475 | 475 | ||
476 | void MainWindow::createLinks() | 476 | void MainWindow::createLinks() |
477 | { | 477 | { |
478 | pvDebug(2,"creating links..."); | 478 | pvDebug(2,"creating links..."); |
479 | ipkg->createLinks( settings->destinationurl->text() ); | 479 | ipkg->createLinks( settings->destinationurl->text() ); |
480 | } | 480 | } |
481 | 481 | ||
482 | void MainWindow::removeLinks() | 482 | void MainWindow::removeLinks() |
483 | { | 483 | { |
484 | pvDebug(2,"removing links..."); | 484 | pvDebug(2,"removing links..."); |
485 | ipkg->removeLinks( settings->destinationurl->text() ); | 485 | ipkg->removeLinks( settings->destinationurl->text() ); |
486 | } | 486 | } |
487 | 487 | ||
488 | void MainWindow::remotePackageQuery() | 488 | void MainWindow::remotePackageQuery() |
489 | { | 489 | { |
490 | packageListSearch.query( searchEdit->text() ); | 490 | packageListSearch.query( searchEdit->text() ); |
491 | packageListSearch.update(); | 491 | packageListSearch.update(); |
492 | displayList(); | 492 | displayList(); |
493 | } | 493 | } |
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index c947c64..4542e42 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp | |||
@@ -1,428 +1,434 @@ | |||
1 | #include "package.h" | 1 | #include "package.h" |
2 | 2 | ||
3 | #include <qpe/process.h> | 3 | #include <qpe/process.h> |
4 | #include <qpe/stringutil.h> | 4 | #include <qpe/stringutil.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | #include "debug.h" | 10 | #include "debug.h" |
11 | 11 | ||
12 | //Package::~Package() | 12 | //Package::~Package() |
13 | //{ | 13 | //{ |
14 | //} | 14 | //} |
15 | 15 | ||
16 | Package::Package( PackageManagerSettings *s ) | 16 | Package::Package( PackageManagerSettings *s ) |
17 | { | 17 | { |
18 | init(s); | 18 | init(s); |
19 | } | 19 | } |
20 | 20 | ||
21 | void Package::init( PackageManagerSettings *s ) | 21 | void Package::init( PackageManagerSettings *s ) |
22 | { | 22 | { |
23 | settings = s; | 23 | settings = s; |
24 | _size = ""; | 24 | _size = ""; |
25 | _section = ""; | 25 | _section = ""; |
26 | _subsection = ""; | 26 | _subsection = ""; |
27 | _shortDesc = ""; | 27 | _shortDesc = ""; |
28 | _desc = ""; | 28 | _desc = ""; |
29 | _name = ""; | 29 | _name = ""; |
30 | _toProcess = false; | 30 | _toProcess = false; |
31 | _useFileName = false; | 31 | _useFileName = false; |
32 | _old = false; | 32 | _old = false; |
33 | _status = ""; | 33 | _status = ""; |
34 | _dest = settings->getDestinationName(); | 34 | _dest = settings->getDestinationName(); |
35 | _link = settings->createLinks(); | 35 | _link = settings->createLinks(); |
36 | _versions=0; | 36 | _versions=0; |
37 | _version=""; | ||
37 | } | 38 | } |
38 | 39 | ||
39 | Package::Package( QStringList pack, PackageManagerSettings *s ) | 40 | Package::Package( QStringList pack, PackageManagerSettings *s ) |
40 | { | 41 | { |
41 | init(s); | 42 | init(s); |
42 | parsePackage( pack ); | 43 | parsePackage( pack ); |
43 | } | 44 | } |
44 | 45 | ||
45 | Package::Package( QString n, PackageManagerSettings *s ) | 46 | Package::Package( QString n, PackageManagerSettings *s ) |
46 | { | 47 | { |
47 | init(s); | 48 | init(s); |
48 | if ( !QFile::exists( n ) ) | 49 | if ( !QFile::exists( n ) ) |
49 | { | 50 | { |
50 | _name = QString( n ); | 51 | _name = QString( n ); |
51 | }else{ | 52 | }else{ |
52 | parseIpkgFile( n ); | 53 | parseIpkgFile( n ); |
53 | _useFileName = true; | 54 | _useFileName = true; |
54 | _fileName = QString( n ); | 55 | _fileName = QString( n ); |
55 | } | 56 | } |
56 | } | 57 | } |
57 | 58 | ||
58 | Package::Package( Package *pi ) | 59 | Package::Package( Package *pi ) |
59 | { | 60 | { |
60 | init(pi->settings); | 61 | init(pi->settings); |
61 | copyValues( pi ); | 62 | copyValues( pi ); |
62 | } | 63 | } |
63 | 64 | ||
64 | 65 | ||
65 | void Package::setValue( QString n, QString t ) | 66 | void Package::setValue( QString n, QString t ) |
66 | { | 67 | { |
67 | if ( n == "Package" ) | 68 | if ( n == "Package" ) |
68 | { | 69 | { |
69 | _name = QString( t ); | 70 | _name = QString( t ); |
70 | }else if ( n == "Installed-Size" ) | 71 | }else if ( n == "Installed-Size" ) |
71 | { | 72 | { |
72 | _size = t; | 73 | _size = t; |
73 | // }else if ( n == "Priority") | 74 | // }else if ( n == "Priority") |
74 | // { | 75 | // { |
75 | 76 | ||
76 | }else if ( n == "Section") | 77 | }else if ( n == "Section") |
77 | { | 78 | { |
78 | setSection( t ); | 79 | setSection( t ); |
79 | // }else if ( n == "Maintainer") | 80 | // }else if ( n == "Maintainer") |
80 | // { | 81 | // { |
81 | // | 82 | // |
82 | // }else if ( n == "Architecture") | 83 | // }else if ( n == "Architecture") |
83 | // { | 84 | // { |
84 | 85 | ||
85 | }else if ( n == "Version") | 86 | }else if ( n == "Version") |
86 | { | 87 | { |
87 | _version = t; | 88 | _version = t; |
88 | // }else if ( n == "Pre-Depends") | 89 | // }else if ( n == "Pre-Depends") |
89 | // { | 90 | // { |
90 | // | 91 | // |
91 | // }else if ( n == "Depends") | 92 | // }else if ( n == "Depends") |
92 | // { | 93 | // { |
93 | 94 | ||
94 | }else if ( n == "Filename") | 95 | }else if ( n == "Filename") |
95 | { | 96 | { |
96 | _fileName = t; | 97 | _fileName = t; |
97 | // }else if ( n == "Size") | 98 | // }else if ( n == "Size") |
98 | // { | 99 | // { |
99 | // | 100 | // |
100 | //}else if ( n == "MD5Sum") | 101 | //}else if ( n == "MD5Sum") |
101 | //{ | 102 | //{ |
102 | 103 | ||
103 | }else if ( n == "Description") | 104 | }else if ( n == "Description") |
104 | { | 105 | { |
105 | setDesc( t ); | 106 | setDesc( t ); |
106 | }else if ( n == "Status") | 107 | }else if ( n == "Status") |
107 | { | 108 | { |
108 | if ( installed() ) return; | 109 | if ( installed() ) return; |
109 | _status = t; | 110 | _status = t; |
110 | // }else if ( n == "Essential") | 111 | // }else if ( n == "Essential") |
111 | // { | 112 | // { |
112 | 113 | ||
113 | }else{ | 114 | }else{ |
114 | _values.insert(n,new QString(t)); | 115 | _values.insert(n,new QString(t)); |
115 | } | 116 | } |
116 | } | 117 | } |
117 | 118 | ||
118 | QString Package::name() | 119 | QString Package::name() |
119 | { | 120 | { |
120 | if (_displayName.isEmpty() ) return _name; | 121 | if (_displayName.isEmpty() ) return _name; |
121 | else return _displayName; | 122 | else return _displayName; |
122 | } | 123 | } |
123 | 124 | ||
124 | 125 | ||
125 | QString Package::installName() | 126 | QString Package::installName() |
126 | { | 127 | { |
127 | if (_useFileName) return _fileName; | 128 | if (_useFileName) return _fileName; |
128 | else return _name; | 129 | else return _name; |
129 | } | 130 | } |
130 | 131 | ||
131 | bool Package::installed() | 132 | bool Package::installed() |
132 | { | 133 | { |
133 | if (_status.contains("installed")) return true; | 134 | if (_status.contains("installed")) return true; |
134 | else | 135 | else |
135 | if (_versions) | 136 | if (_versions) |
136 | { | 137 | { |
137 | QDictIterator<Package> other( *_versions ); | 138 | QDictIterator<Package> other( *_versions ); |
138 | while ( other.current() ) | 139 | while ( other.current() ) |
139 | { | 140 | { |
140 | if (other.current()->status().contains("installed") | 141 | if (other.current()->status().contains("installed") |
141 | && other.current()->version() == version()) | 142 | && other.current()->version() == version()) |
142 | return true; | 143 | return true; |
143 | ++other; | 144 | ++other; |
144 | } | 145 | } |
145 | } | 146 | } |
146 | return false; | 147 | return false; |
147 | } | 148 | } |
148 | 149 | ||
149 | bool Package::otherInstalled() | 150 | bool Package::otherInstalled() |
150 | { | 151 | { |
151 | if (_versions) | 152 | if (_versions) |
152 | { | 153 | { |
153 | QDictIterator<Package> other( *_versions ); | 154 | QDictIterator<Package> other( *_versions ); |
154 | while ( other.current() ) | 155 | while ( other.current() ) |
155 | { | 156 | { |
156 | if (other.current()->installed()) return true; | 157 | if (other.current()->installed()) return true; |
157 | ++other; | 158 | ++other; |
158 | } | 159 | } |
159 | } | 160 | } |
160 | return false; | 161 | return false; |
161 | } | 162 | } |
162 | 163 | ||
163 | void Package::setDesc( QString s ) | 164 | void Package::setDesc( QString s ) |
164 | { | 165 | { |
165 | _desc = s; | 166 | _desc = s; |
166 | _shortDesc = s.left( s.find("\n") ); | 167 | _shortDesc = s.left( s.find("\n") ); |
167 | } | 168 | } |
168 | 169 | ||
169 | QString Package::desc() | 170 | QString Package::desc() |
170 | { | 171 | { |
171 | return _desc; | 172 | return _desc; |
172 | } | 173 | } |
173 | 174 | ||
174 | QString Package::shortDesc() | 175 | QString Package::shortDesc() |
175 | { | 176 | { |
176 | return _shortDesc; | 177 | return _shortDesc; |
177 | } | 178 | } |
178 | 179 | ||
179 | QString Package::size() | 180 | QString Package::size() |
180 | { | 181 | { |
181 | return _size; | 182 | return _size; |
182 | } | 183 | } |
183 | 184 | ||
184 | 185 | ||
185 | QString Package::version() | 186 | QString Package::version() |
186 | { | 187 | { |
187 | return _version; | 188 | return _version; |
188 | } | 189 | } |
189 | 190 | ||
190 | QString Package::sizeUnits() | 191 | QString Package::sizeUnits() |
191 | { | 192 | { |
192 | int i = _size.toInt(); | 193 | int i = _size.toInt(); |
193 | int c = 0; | 194 | int c = 0; |
194 | QString ret; | 195 | QString ret; |
195 | QStringList unit; | 196 | QStringList unit; |
196 | unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) | 197 | unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) |
197 | while (i > 1) | 198 | while (i > 1) |
198 | { | 199 | { |
199 | ret=QString::number(i)+" "+unit[c]; | 200 | ret=QString::number(i)+" "+unit[c]; |
200 | c++; | 201 | c++; |
201 | i /= 1024; | 202 | i /= 1024; |
202 | } | 203 | } |
203 | return ret; | 204 | return ret; |
204 | } | 205 | } |
205 | 206 | ||
206 | bool Package::toProcess() | 207 | bool Package::toProcess() |
207 | { | 208 | { |
208 | return _toProcess; | 209 | return _toProcess; |
209 | } | 210 | } |
210 | 211 | ||
211 | bool Package::toRemove() | 212 | bool Package::toRemove() |
212 | { | 213 | { |
213 | if ( _toProcess && installed() ) return true; | 214 | if ( _toProcess && installed() ) return true; |
214 | else return false; | 215 | else return false; |
215 | } | 216 | } |
216 | 217 | ||
217 | bool Package::toInstall() | 218 | bool Package::toInstall() |
218 | { | 219 | { |
219 | if ( _toProcess && !installed() ) return true; | 220 | if ( _toProcess && !installed() ) return true; |
220 | else return false; | 221 | else return false; |
221 | } | 222 | } |
222 | 223 | ||
223 | void Package::toggleProcess() | 224 | void Package::toggleProcess() |
224 | { | 225 | { |
225 | _toProcess = ! _toProcess; | 226 | _toProcess = ! _toProcess; |
226 | } | 227 | } |
227 | 228 | ||
228 | 229 | ||
229 | 230 | ||
230 | void Package::copyValues( Package* pack ) | 231 | void Package::copyValues( Package* pack ) |
231 | { | 232 | { |
232 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); | 233 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); |
233 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); | 234 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); |
234 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); | 235 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); |
235 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); | 236 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); |
236 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); | 237 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); |
237 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); | 238 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); |
238 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); | 239 | if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); |
240 | if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); | ||
241 | if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); | ||
242 | if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); | ||
243 | if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); | ||
244 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); | ||
239 | } | 245 | } |
240 | 246 | ||
241 | QString Package::section() | 247 | QString Package::section() |
242 | { | 248 | { |
243 | return _section; | 249 | return _section; |
244 | } | 250 | } |
245 | 251 | ||
246 | void Package::setSection( QString s) | 252 | void Package::setSection( QString s) |
247 | { | 253 | { |
248 | int i = s.find("/"); | 254 | int i = s.find("/"); |
249 | if ( i > 0 ) | 255 | if ( i > 0 ) |
250 | { | 256 | { |
251 | _section = s.left(i); | 257 | _section = s.left(i); |
252 | _subsection = s.mid(i+1); | 258 | _subsection = s.mid(i+1); |
253 | }else{ | 259 | }else{ |
254 | _section = s; | 260 | _section = s; |
255 | _subsection = ""; | 261 | _subsection = ""; |
256 | } | 262 | } |
257 | } | 263 | } |
258 | 264 | ||
259 | QString Package::subSection() | 265 | QString Package::subSection() |
260 | { | 266 | { |
261 | return _subsection; | 267 | return _subsection; |
262 | } | 268 | } |
263 | 269 | ||
264 | void Package::parsePackage( QStringList pack ) | 270 | void Package::parsePackage( QStringList pack ) |
265 | { | 271 | { |
266 | if ( pack.isEmpty() ) return; | 272 | if ( pack.isEmpty() ) return; |
267 | int count = pack.count(); | 273 | int count = pack.count(); |
268 | for( int i = 0; i < count; i++ ) | 274 | for( int i = 0; i < count; i++ ) |
269 | { | 275 | { |
270 | QString line = pack[i]; | 276 | QString line = pack[i]; |
271 | int sep = line.find( QRegExp(":[\t ]+") ); | 277 | int sep = line.find( QRegExp(":[\t ]+") ); |
272 | if ( sep >= 0 ) | 278 | if ( sep >= 0 ) |
273 | { | 279 | { |
274 | QString tag = line.left(sep); | 280 | QString tag = line.left(sep); |
275 | QString value = line.mid(sep+2).simplifyWhiteSpace(); | 281 | QString value = line.mid(sep+2).simplifyWhiteSpace(); |
276 | setValue( tag, value ); | 282 | setValue( tag, value ); |
277 | }else{ | 283 | }else{ |
278 | } | 284 | } |
279 | } | 285 | } |
280 | return; | 286 | return; |
281 | } | 287 | } |
282 | 288 | ||
283 | QString Package::details() | 289 | QString Package::details() |
284 | { | 290 | { |
285 | QString status; | 291 | QString status; |
286 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); | 292 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); |
287 | QString description; | 293 | QString description; |
288 | if ( ipkg_status.exec("",status) ) | 294 | if ( ipkg_status.exec("",status) ) |
289 | { | 295 | { |
290 | QStringList lines = QStringList::split('\n',status,TRUE); | 296 | QStringList lines = QStringList::split('\n',status,TRUE); |
291 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { | 297 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { |
292 | QString line = *it; | 298 | QString line = *it; |
293 | if ( line == " ." ) | 299 | if ( line == " ." ) |
294 | { | 300 | { |
295 | description.append("<p>"); | 301 | description.append("<p>"); |
296 | } else | 302 | } else |
297 | if ( line[0] == ' ' || line[0] == '\t' ) | 303 | if ( line[0] == ' ' || line[0] == '\t' ) |
298 | { | 304 | { |
299 | // continuation | 305 | // continuation |
300 | description.append(" "); | 306 | description.append(" "); |
301 | description.append(Qtopia::escapeString(line)); | 307 | description.append(Qtopia::escapeString(line)); |
302 | } else { | 308 | } else { |
303 | int sep = line.find(QRegExp(":[\t ]+")); | 309 | int sep = line.find(QRegExp(":[\t ]+")); |
304 | if ( sep >= 0 ) | 310 | if ( sep >= 0 ) |
305 | { | 311 | { |
306 | QString tag = line.left(sep); | 312 | QString tag = line.left(sep); |
307 | description.append("<br>"); | 313 | description.append("<br>"); |
308 | description.append("<b>"); | 314 | description.append("<b>"); |
309 | description.append(Qtopia::escapeString(tag)); | 315 | description.append(Qtopia::escapeString(tag)); |
310 | description.append(":</b> "); | 316 | description.append(":</b> "); |
311 | description.append(Qtopia::escapeString(line.mid(sep+2))); | 317 | description.append(Qtopia::escapeString(line.mid(sep+2))); |
312 | } else { | 318 | } else { |
313 | description.append(" "); | 319 | description.append(" "); |
314 | description.append(Qtopia::escapeString(line)); | 320 | description.append(Qtopia::escapeString(line)); |
315 | } | 321 | } |
316 | } | 322 | } |
317 | } | 323 | } |
318 | } | 324 | } |
319 | return description; | 325 | return description; |
320 | } | 326 | } |
321 | 327 | ||
322 | void Package::processed() | 328 | void Package::processed() |
323 | { | 329 | { |
324 | _toProcess = false; | 330 | _toProcess = false; |
325 | //hack, but we're not writing status anyway... | 331 | //hack, but we're not writing status anyway... |
326 | if ( installed() ) _status = "install"; | 332 | if ( installed() ) _status = "install"; |
327 | else _status = "installed"; | 333 | else _status = "installed"; |
328 | } | 334 | } |
329 | 335 | ||
330 | QString Package::dest() | 336 | QString Package::dest() |
331 | { | 337 | { |
332 | if ( installed()||(!installed() && _toProcess) ) | 338 | if ( installed()||(!installed() && _toProcess) ) |
333 | return _dest!=""?_dest:settings->getDestinationName(); | 339 | return _dest!=""?_dest:settings->getDestinationName(); |
334 | else return ""; | 340 | else return ""; |
335 | } | 341 | } |
336 | 342 | ||
337 | void Package::setDest( QString d ) | 343 | void Package::setDest( QString d ) |
338 | { | 344 | { |
339 | _dest = d; | 345 | _dest = d; |
340 | } | 346 | } |
341 | 347 | ||
342 | void Package::setOn() | 348 | void Package::setOn() |
343 | { | 349 | { |
344 | _toProcess = true; | 350 | _toProcess = true; |
345 | } | 351 | } |
346 | 352 | ||
347 | bool Package::link() | 353 | bool Package::link() |
348 | { | 354 | { |
349 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; | 355 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; |
350 | return _link; | 356 | return _link; |
351 | } | 357 | } |
352 | 358 | ||
353 | void Package::setLink(bool b) | 359 | void Package::setLink(bool b) |
354 | { | 360 | { |
355 | _link = b; | 361 | _link = b; |
356 | } | 362 | } |
357 | 363 | ||
358 | void Package::parseIpkgFile( QString file) | 364 | void Package::parseIpkgFile( QString file) |
359 | { | 365 | { |
360 | system("tar xzf "+file+" -C /tmp"); | 366 | system("tar xzf "+file+" -C /tmp"); |
361 | system("tar xzf /tmp/control.tar.gz -C /tmp"); | 367 | system("tar xzf /tmp/control.tar.gz -C /tmp"); |
362 | QFile f("/tmp/control"); | 368 | QFile f("/tmp/control"); |
363 | if ( f.open(IO_ReadOnly) ) | 369 | if ( f.open(IO_ReadOnly) ) |
364 | { | 370 | { |
365 | QTextStream t( &f ); | 371 | QTextStream t( &f ); |
366 | QStringList pack; | 372 | QStringList pack; |
367 | while ( !t.eof() ) | 373 | while ( !t.eof() ) |
368 | { | 374 | { |
369 | pack << t.readLine(); | 375 | pack << t.readLine(); |
370 | } | 376 | } |
371 | f.close(); | 377 | f.close(); |
372 | parsePackage( pack ); | 378 | parsePackage( pack ); |
373 | } | 379 | } |
374 | 380 | ||
375 | } | 381 | } |
376 | 382 | ||
377 | //QString Package::getPackageName() | 383 | //QString Package::getPackageName() |
378 | //{ | 384 | //{ |
379 | //if ( _packageName.isEmpty() ) return _name; | 385 | //if ( _packageName.isEmpty() ) return _name; |
380 | //else return _packageName; | 386 | //else return _packageName; |
381 | //} | 387 | //} |
382 | 388 | ||
383 | void Package::instalFromFile(bool iff) | 389 | void Package::instalFromFile(bool iff) |
384 | { | 390 | { |
385 | _useFileName = iff; | 391 | _useFileName = iff; |
386 | } | 392 | } |
387 | 393 | ||
388 | void Package::setName(QString n) | 394 | void Package::setName(QString n) |
389 | { | 395 | { |
390 | _displayName = n; | 396 | _displayName = n; |
391 | } | 397 | } |
392 | 398 | ||
393 | QDict<QString>* Package::getFields() | 399 | QDict<QString>* Package::getFields() |
394 | { | 400 | { |
395 | return &_values; | 401 | return &_values; |
396 | } | 402 | } |
397 | 403 | ||
398 | QString Package::status() | 404 | QString Package::status() |
399 | { | 405 | { |
400 | return _status; | 406 | return _status; |
401 | } | 407 | } |
402 | 408 | ||
403 | bool Package::isOld() | 409 | bool Package::isOld() |
404 | { | 410 | { |
405 | if (!_versions) return false; | 411 | if (!_versions) return false; |
406 | QDictIterator<Package> other( *_versions ); | 412 | QDictIterator<Package> other( *_versions ); |
407 | while ( other.current() ) { | 413 | while ( other.current() ) { |
408 | if (other.current()->version() > version() ) return true; | 414 | if (other.current()->version() > version() ) return true; |
409 | ++other; | 415 | ++other; |
410 | } | 416 | } |
411 | return false; | 417 | return false; |
412 | } | 418 | } |
413 | 419 | ||
414 | bool Package::hasVersions() | 420 | bool Package::hasVersions() |
415 | { | 421 | { |
416 | if (!_versions) return false; | 422 | if (!_versions) return false; |
417 | else return true; | 423 | else return true; |
418 | } | 424 | } |
419 | 425 | ||
420 | QDict<Package>* Package::getOtherVersions() | 426 | QDict<Package>* Package::getOtherVersions() |
421 | { | 427 | { |
422 | return _versions; | 428 | return _versions; |
423 | } | 429 | } |
424 | 430 | ||
425 | void Package::setOtherVersions(QDict<Package> *v) | 431 | void Package::setOtherVersions(QDict<Package> *v) |
426 | { | 432 | { |
427 | _versions=v; | 433 | _versions=v; |
428 | } | 434 | } |
diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp index 24c7beb..09975b0 100644 --- a/noncore/unsupported/oipkg/pksettings.cpp +++ b/noncore/unsupported/oipkg/pksettings.cpp | |||
@@ -1,567 +1,569 @@ | |||
1 | #include "pksettings.h" | 1 | #include "pksettings.h" |
2 | 2 | ||
3 | #include <qpe/process.h> | 3 | #include <qpe/process.h> |
4 | #include <qpe/resource.h> | 4 | #include <qpe/resource.h> |
5 | #include <qpe/stringutil.h> | 5 | #include <qpe/stringutil.h> |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
8 | #include <qpe/applnk.h> | 8 | #include <qpe/applnk.h> |
9 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
10 | 10 | ||
11 | #include <qprogressbar.h> | 11 | #include <qprogressbar.h> |
12 | #include <qcombobox.h> | 12 | #include <qcombobox.h> |
13 | #include <qdict.h> | 13 | #include <qdict.h> |
14 | #include <qfile.h> | 14 | #include <qfile.h> |
15 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
16 | #include <qpushbutton.h> | 16 | #include <qpushbutton.h> |
17 | #include <qlistview.h> | 17 | #include <qlistview.h> |
18 | #include <qlistbox.h> | 18 | #include <qlistbox.h> |
19 | #include <qcheckbox.h> | 19 | #include <qcheckbox.h> |
20 | #include <qmessagebox.h> | 20 | #include <qmessagebox.h> |
21 | #include <qpainter.h> | 21 | #include <qpainter.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | #include <qregexp.h> | 23 | #include <qregexp.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qtextstream.h> | 26 | #include <qtextstream.h> |
27 | #include <qtextview.h> | 27 | #include <qtextview.h> |
28 | #include <qtoolbutton.h> | 28 | #include <qtoolbutton.h> |
29 | #include <qtabwidget.h> | 29 | #include <qtabwidget.h> |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include "debug.h" | 33 | #include "debug.h" |
34 | //#include "utils.h" | 34 | //#include "utils.h" |
35 | 35 | ||
36 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) | 36 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) |
37 | : PackageManagerSettingsBase( parent, name, fl ) | 37 | : PackageManagerSettingsBase( parent, name, fl ) |
38 | { | 38 | { |
39 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); | 39 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); |
40 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); | 40 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); |
41 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 41 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
42 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); | 42 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); |
43 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); | 43 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); |
44 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 44 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
45 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), | 45 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), |
46 | // activeLinkDestination, SLOT(setEnabled(bool)) ); | 46 | // activeLinkDestination, SLOT(setEnabled(bool)) ); |
47 | 47 | ||
48 | connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); | 48 | connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); |
49 | connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); | 49 | connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); |
50 | connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); | 50 | connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); |
51 | connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); | 51 | connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); |
52 | connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); | 52 | connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); |
53 | servername->setEnabled(FALSE); | 53 | servername->setEnabled(FALSE); |
54 | serverurl->setEnabled(FALSE); | 54 | serverurl->setEnabled(FALSE); |
55 | serverurlDic.setAutoDelete(TRUE); | 55 | serverurlDic.setAutoDelete(TRUE); |
56 | destinationname->setEnabled(FALSE); | 56 | destinationname->setEnabled(FALSE); |
57 | destinationurl->setEnabled(FALSE); | 57 | destinationurl->setEnabled(FALSE); |
58 | destinationurlDic.setAutoDelete(TRUE); | 58 | destinationurlDic.setAutoDelete(TRUE); |
59 | readSettings(); | 59 | readSettings(); |
60 | activeLinkDestination->hide(); | 60 | activeLinkDestination->hide(); |
61 | serverChanged = false; | 61 | serverChanged = false; |
62 | } | 62 | } |
63 | 63 | ||
64 | PackageManagerSettings::~PackageManagerSettings() | 64 | PackageManagerSettings::~PackageManagerSettings() |
65 | { | 65 | { |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | void PackageManagerSettings::newServer() | 69 | void PackageManagerSettings::newServer() |
70 | { | 70 | { |
71 | int i = servers->count(); | 71 | int i = servers->count(); |
72 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { | 72 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { |
73 | serverurlDic.insert(i,new QString("http://")); | 73 | serverurlDic.insert(i,new QString("http://")); |
74 | servers->insertItem(tr("New")); | 74 | servers->insertItem(tr("New")); |
75 | activeServers->insertItem(tr("New")); | 75 | activeServers->insertItem(tr("New")); |
76 | } else { | 76 | } else { |
77 | // allows one-level undo | 77 | // allows one-level undo |
78 | serverurlDic.insert(i,new QString(serverurl->text())); | 78 | serverurlDic.insert(i,new QString(serverurl->text())); |
79 | servers->insertItem(servername->text()); | 79 | servers->insertItem(servername->text()); |
80 | activeServers->insertItem(servername->text()); | 80 | activeServers->insertItem(servername->text()); |
81 | } | 81 | } |
82 | changed = true; | 82 | changed = true; |
83 | servers->setSelected(i,TRUE); | 83 | servers->setSelected(i,TRUE); |
84 | editServer(i); | 84 | editServer(i); |
85 | changed = true; | 85 | changed = true; |
86 | } | 86 | } |
87 | 87 | ||
88 | void PackageManagerSettings::newDestination() | 88 | void PackageManagerSettings::newDestination() |
89 | { | 89 | { |
90 | int i = destinations->count(); | 90 | int i = destinations->count(); |
91 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { | 91 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { |
92 | destinationurlDic.insert(i,new QString("/")); | 92 | destinationurlDic.insert(i,new QString("/")); |
93 | destinations->insertItem(tr("New")); | 93 | destinations->insertItem(tr("New")); |
94 | activeDestination->insertItem(tr("New")); | 94 | activeDestination->insertItem(tr("New")); |
95 | activeLinkDestination->insertItem(tr("New")); | 95 | activeLinkDestination->insertItem(tr("New")); |
96 | } else { | 96 | } else { |
97 | // allows one-level undo | 97 | // allows one-level undo |
98 | destinationurlDic.insert(i,new QString(destinationurl->text())); | 98 | destinationurlDic.insert(i,new QString(destinationurl->text())); |
99 | destinations->insertItem(destinationname->text()); | 99 | destinations->insertItem(destinationname->text()); |
100 | activeDestination->insertItem(destinationname->text()); | 100 | activeDestination->insertItem(destinationname->text()); |
101 | activeLinkDestination->insertItem(destinationname->text()); | 101 | activeLinkDestination->insertItem(destinationname->text()); |
102 | } | 102 | } |
103 | destinations->setSelected(i,TRUE); | 103 | destinations->setSelected(i,TRUE); |
104 | editDestination(i); | 104 | editDestination(i); |
105 | changed = true; | 105 | changed = true; |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | void PackageManagerSettings::editServer(int i) | 109 | void PackageManagerSettings::editServer(int i) |
110 | { | 110 | { |
111 | if ( servername->isEnabled() ) { | 111 | if ( servername->isEnabled() ) { |
112 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 112 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
113 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 113 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
114 | } else { | 114 | } else { |
115 | servername->setEnabled(TRUE); | 115 | servername->setEnabled(TRUE); |
116 | serverurl->setEnabled(TRUE); | 116 | serverurl->setEnabled(TRUE); |
117 | } | 117 | } |
118 | 118 | ||
119 | servername->setText( servers->text(i) ); | 119 | servername->setText( servers->text(i) ); |
120 | serverurl->setText( *serverurlDic[i] ); | 120 | serverurl->setText( *serverurlDic[i] ); |
121 | 121 | ||
122 | editedserver = i; | 122 | editedserver = i; |
123 | serverChanged = true; | 123 | serverChanged = true; |
124 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 124 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
125 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 125 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
126 | changed = true; | 126 | changed = true; |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | void PackageManagerSettings::editDestination(int i) | 130 | void PackageManagerSettings::editDestination(int i) |
131 | { | 131 | { |
132 | if ( destinationname->isEnabled() ) { | 132 | if ( destinationname->isEnabled() ) { |
133 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 133 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
134 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 134 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
135 | } else { | 135 | } else { |
136 | destinationname->setEnabled(TRUE); | 136 | destinationname->setEnabled(TRUE); |
137 | destinationurl->setEnabled(TRUE); | 137 | destinationurl->setEnabled(TRUE); |
138 | //since it does not work anyway | 138 | //since it does not work anyway |
139 | // createLinksButton->setEnabled(TRUE); | 139 | // createLinksButton->setEnabled(TRUE); |
140 | // removeLinksButton->setEnabled(TRUE); | 140 | // removeLinksButton->setEnabled(TRUE); |
141 | } | 141 | } |
142 | 142 | ||
143 | destinationname->setText( destinations->text(i) ); | 143 | destinationname->setText( destinations->text(i) ); |
144 | destinationurl->setText( *destinationurlDic[i] ); | 144 | destinationurl->setText( *destinationurlDic[i] ); |
145 | 145 | ||
146 | editeddestination = i; | 146 | editeddestination = i; |
147 | 147 | ||
148 | connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 148 | connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
149 | connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 149 | connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
150 | changed = true; | 150 | changed = true; |
151 | } | 151 | } |
152 | 152 | ||
153 | void PackageManagerSettings::removeServer() | 153 | void PackageManagerSettings::removeServer() |
154 | { | 154 | { |
155 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 155 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
156 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 156 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
157 | servername->setText(servers->text(editedserver)); | 157 | servername->setText(servers->text(editedserver)); |
158 | serverurl->setText(*serverurlDic[editedserver]); | 158 | serverurl->setText(*serverurlDic[editedserver]); |
159 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 159 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
160 | servers->removeItem(editedserver); | 160 | servers->removeItem(editedserver); |
161 | activeServers->removeItem(editedserver); | 161 | activeServers->removeItem(editedserver); |
162 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 162 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
163 | servername->setEnabled(FALSE); | 163 | servername->setEnabled(FALSE); |
164 | serverurl->setEnabled(FALSE); | 164 | serverurl->setEnabled(FALSE); |
165 | changed = true; | 165 | changed = true; |
166 | } | 166 | } |
167 | 167 | ||
168 | void PackageManagerSettings::removeDestination() | 168 | void PackageManagerSettings::removeDestination() |
169 | { | 169 | { |
170 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 170 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
171 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 171 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
172 | destinationname->setText(destinations->text(editedserver)); | 172 | destinationname->setText(""); |
173 | destinationurl->setText(*destinationurlDic[editedserver]); | 173 | destinationurl->setText(""); |
174 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 174 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
175 | destinations->removeItem(editeddestination); | 175 | destinations->removeItem(editeddestination); |
176 | activeDestination->removeItem(editeddestination); | 176 | activeDestination->removeItem(editeddestination); |
177 | activeLinkDestination->removeItem(editeddestination); | 177 | activeLinkDestination->removeItem(editeddestination); |
178 | editeddestination=0; | ||
178 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 179 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
179 | destinationname->setEnabled(FALSE); | 180 | destinationname->setEnabled(FALSE); |
180 | destinationurl->setEnabled(FALSE); | 181 | destinationurl->setEnabled(FALSE); |
181 | changed = true; | 182 | changed = true; |
182 | } | 183 | } |
183 | 184 | ||
184 | void PackageManagerSettings::serverNameChanged(const QString& t) | 185 | void PackageManagerSettings::serverNameChanged(const QString& t) |
185 | { | 186 | { |
186 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 187 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
187 | servers->changeItem( t, editedserver ); | 188 | servers->changeItem( t, editedserver ); |
188 | activeServers->changeItem( t, editedserver ); | 189 | activeServers->changeItem( t, editedserver ); |
189 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 190 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
190 | changed = true; | 191 | changed = true; |
191 | serverChanged = true; | 192 | serverChanged = true; |
192 | } | 193 | } |
193 | 194 | ||
194 | void PackageManagerSettings::destNameChanged(const QString& t) | 195 | void PackageManagerSettings::destNameChanged(const QString& t) |
195 | { | 196 | { |
196 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 197 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
197 | destinations->changeItem( t, editeddestination ); | 198 | destinations->changeItem( t, editeddestination ); |
198 | activeDestination->changeItem( t, editeddestination ); | 199 | activeDestination->changeItem( t, editeddestination ); |
199 | activeLinkDestination->changeItem( t, editeddestination ); | 200 | activeLinkDestination->changeItem( t, editeddestination ); |
200 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 201 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
201 | changed = true; | 202 | changed = true; |
202 | } | 203 | } |
203 | 204 | ||
204 | void PackageManagerSettings::serverUrlChanged(const QString& t) | 205 | void PackageManagerSettings::serverUrlChanged(const QString& t) |
205 | { | 206 | { |
206 | serverurlDic.replace(editedserver, new QString(t)); | 207 | serverurlDic.replace(editedserver, new QString(t)); |
207 | changed = true; | 208 | changed = true; |
208 | serverChanged = true; | 209 | serverChanged = true; |
209 | } | 210 | } |
210 | 211 | ||
211 | void PackageManagerSettings::destUrlChanged(const QString& t) | 212 | void PackageManagerSettings::destUrlChanged(const QString& t) |
212 | { | 213 | { |
213 | destinationurlDic.replace(editeddestination, new QString(t)); | 214 | destinationurlDic.replace(editeddestination, new QString(t)); |
214 | changed = true; | 215 | changed = true; |
215 | } | 216 | } |
216 | 217 | ||
217 | void PackageManagerSettings::writeIpkgConfig(const QString& conffile) | 218 | void PackageManagerSettings::writeIpkgConfig(const QString& conffile) |
218 | { | 219 | { |
219 | QFile conf(conffile); | 220 | QFile conf(conffile); |
220 | if ( ! conf.open(IO_WriteOnly) ) return; | 221 | if ( ! conf.open(IO_WriteOnly) ) return; |
221 | QTextStream s(&conf); | 222 | QTextStream s(&conf); |
222 | s << "# Written by qpie Package Manager\n"; | 223 | s << "# Written by qpie Package Manager\n"; |
223 | for (int i=0; i<(int)activeServers->count(); i++) | 224 | for (int i=0; i<(int)activeServers->count(); i++) |
224 | { | 225 | { |
225 | QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); | 226 | QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); |
226 | if ( !activeServers->isSelected(i) ) | 227 | if ( !activeServers->isSelected(i) ) |
227 | s << "#"; | 228 | s << "#"; |
228 | s << "src " << activeServers->text(i) << " " << url << "\n"; | 229 | s << "src " << activeServers->text(i) << " " << url << "\n"; |
229 | } | 230 | } |
230 | for (int i=0; i<(int)destinations->count(); i++) | 231 | for (int i=0; i<(int)destinations->count(); i++) |
231 | { | 232 | { |
232 | QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???"); | 233 | QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???"); |
233 | s << "dest " << destinations->text(i) << " " << url << "\n"; | 234 | s << "dest " << destinations->text(i) << " " << url << "\n"; |
234 | } | 235 | } |
235 | conf.close(); | 236 | conf.close(); |
236 | } | 237 | } |
237 | 238 | ||
238 | 239 | ||
239 | void PackageManagerSettings::readInstallationSettings() | 240 | void PackageManagerSettings::readInstallationSettings() |
240 | { | 241 | { |
241 | Config cfg( "oipkg", Config::User ); | 242 | Config cfg( "oipkg", Config::User ); |
242 | cfg.setGroup( "Settings" ); | 243 | cfg.setGroup( "Settings" ); |
243 | installationSettingsCount = cfg.readNumEntry( "count", -1 ); | 244 | installationSettingsCount = cfg.readNumEntry( "count", -1 ); |
244 | currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1 | 245 | currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1 |
245 | 246 | ||
246 | for (int i = 0; i < installationSettingsCount; i++) | 247 | for (int i = 0; i < installationSettingsCount; i++) |
247 | { | 248 | { |
248 | cfg.setGroup( "Setting_" + QString::number(i) ); | 249 | cfg.setGroup( "Setting_" + QString::number(i) ); |
249 | settingName->insertItem( cfg.readEntry( "name", "???" ), i ); | 250 | settingName->insertItem( cfg.readEntry( "name", "???" ), i ); |
250 | }; | 251 | }; |
251 | readInstallationSetting( currentSetting ); | 252 | readInstallationSetting( currentSetting ); |
252 | } | 253 | } |
253 | 254 | ||
254 | 255 | ||
255 | 256 | ||
256 | /** | 257 | /** |
257 | * remove from conf file | 258 | * remove from conf file |
258 | */ | 259 | */ |
259 | void PackageManagerSettings::removeInstallationSetting() | 260 | void PackageManagerSettings::removeInstallationSetting() |
260 | { | 261 | { |
261 | settingName->removeItem( settingName->currentItem() ); | 262 | settingName->removeItem( settingName->currentItem() ); |
262 | Config cfg( "oipkg", Config::User ); | 263 | Config cfg( "oipkg", Config::User ); |
263 | cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); | 264 | cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); |
264 | cfg.clearGroup(); | 265 | cfg.clearGroup(); |
265 | installationSettingsCount--; | 266 | installationSettingsCount--; |
266 | changed = true; | 267 | changed = true; |
267 | settingName->setEditable( false ); | 268 | settingName->setEditable( false ); |
268 | } | 269 | } |
269 | 270 | ||
270 | /** | 271 | /** |
271 | * write to confgile | 272 | * write to confgile |
272 | */ | 273 | */ |
273 | void PackageManagerSettings::newInstallationSetting() | 274 | void PackageManagerSettings::newInstallationSetting() |
274 | { | 275 | { |
275 | installationSettingsCount++; | 276 | installationSettingsCount++; |
276 | settingName->insertItem( "New", installationSettingsCount ); | 277 | settingName->insertItem( "New", installationSettingsCount ); |
277 | settingName->setCurrentItem( installationSettingsCount ); | 278 | settingName->setCurrentItem( installationSettingsCount ); |
278 | settingName->setEditable( true ); | 279 | settingName->setEditable( true ); |
279 | changed = true; | 280 | changed = true; |
280 | } | 281 | } |
281 | 282 | ||
282 | void PackageManagerSettings::installationSettingChange(int cs) | 283 | void PackageManagerSettings::installationSettingChange(int cs) |
283 | { | 284 | { |
284 | writeCurrentInstallationSetting(); | 285 | writeCurrentInstallationSetting(); |
285 | currentSetting = cs; | 286 | currentSetting = cs; |
286 | readInstallationSetting( cs ); | 287 | readInstallationSetting( cs ); |
287 | changed = true; | 288 | changed = true; |
288 | } | 289 | } |
289 | 290 | ||
290 | void PackageManagerSettings::writeInstallationSettings() | 291 | void PackageManagerSettings::writeInstallationSettings() |
291 | { | 292 | { |
292 | { | 293 | { |
293 | Config cfg( "oipkg", Config::User ); | 294 | Config cfg( "oipkg", Config::User ); |
294 | cfg.setGroup( "Settings" ); | 295 | cfg.setGroup( "Settings" ); |
295 | cfg.writeEntry( "count", installationSettingsCount ); | 296 | cfg.writeEntry( "count", installationSettingsCount ); |
296 | cfg.writeEntry( "current", currentSetting ); | 297 | cfg.writeEntry( "current", currentSetting ); |
297 | } | 298 | } |
298 | writeCurrentInstallationSetting(); | 299 | writeCurrentInstallationSetting(); |
299 | } | 300 | } |
300 | 301 | ||
301 | 302 | ||
302 | void PackageManagerSettings::readInstallationSetting(int setting) | 303 | void PackageManagerSettings::readInstallationSetting(int setting) |
303 | { | 304 | { |
304 | if ( setting < 0 ) return; | 305 | if ( setting < 0 ) return; |
305 | Config cfg( "oipkg", Config::User ); | 306 | Config cfg( "oipkg", Config::User ); |
306 | cfg.setGroup( "Setting_" + QString::number( setting ) ); | 307 | cfg.setGroup( "Setting_" + QString::number( setting ) ); |
307 | CheckBoxLink->setChecked( cfg.readBoolEntry( "link", true ) ); | 308 | CheckBoxLink->setChecked( cfg.readBoolEntry( "link", true ) ); |
308 | QString dest = cfg.readEntry( "dest" ); | 309 | QString dest = cfg.readEntry( "dest" ); |
309 | QString linkdest = cfg.readEntry( "linkdest" ); | 310 | QString linkdest = cfg.readEntry( "linkdest" ); |
310 | pvDebug(3, "dest="+dest); | 311 | pvDebug(3, "dest="+dest); |
311 | pvDebug(3, "linkdest="+linkdest); | 312 | pvDebug(3, "linkdest="+linkdest); |
312 | for ( int i = 0; i < activeDestination->count(); i++) | 313 | for ( int i = 0; i < activeDestination->count(); i++) |
313 | { | 314 | { |
314 | if ( activeDestination->text( i ) == dest ) | 315 | if ( activeDestination->text( i ) == dest ) |
315 | activeDestination->setCurrentItem( i ); | 316 | activeDestination->setCurrentItem( i ); |
316 | if ( activeLinkDestination->text( i ) == linkdest ) | 317 | if ( activeLinkDestination->text( i ) == linkdest ) |
317 | activeLinkDestination->setCurrentItem( i ); | 318 | activeLinkDestination->setCurrentItem( i ); |
318 | } | 319 | } |
319 | } | 320 | } |
320 | 321 | ||
321 | void PackageManagerSettings::writeCurrentInstallationSetting() | 322 | void PackageManagerSettings::writeCurrentInstallationSetting() |
322 | { | 323 | { |
323 | Config cfg( "oipkg", Config::User ); | 324 | Config cfg( "oipkg", Config::User ); |
324 | cfg.setGroup( "Setting_" + QString::number(currentSetting) ); | 325 | cfg.setGroup( "Setting_" + QString::number(currentSetting) ); |
325 | cfg.writeEntry( "link", CheckBoxLink->isChecked() ); | 326 | cfg.writeEntry( "link", CheckBoxLink->isChecked() ); |
326 | cfg.writeEntry( "dest", getDestinationName() ); | 327 | cfg.writeEntry( "dest", getDestinationName() ); |
327 | cfg.writeEntry( "linkdest" , getLinkDestinationName() ); | 328 | cfg.writeEntry( "linkdest" , getLinkDestinationName() ); |
328 | QStringList sers = getActiveServers(); | 329 | QStringList sers = getActiveServers(); |
329 | int srvc = 0; | 330 | int srvc = 0; |
330 | for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { | 331 | for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { |
331 | cfg.writeEntry( "server_" + QString::number(srvc++), *it ); | 332 | cfg.writeEntry( "server_" + QString::number(srvc++), *it ); |
332 | } | 333 | } |
333 | cfg.writeEntry( "server_count", srvc ); | 334 | cfg.writeEntry( "server_count", srvc ); |
334 | } | 335 | } |
335 | 336 | ||
336 | void PackageManagerSettings::renameInstallationSetting() | 337 | void PackageManagerSettings::renameInstallationSetting() |
337 | { | 338 | { |
338 | settingName->setEditable( true ); | 339 | settingName->setEditable( true ); |
339 | changed = true; | 340 | changed = true; |
340 | } | 341 | } |
341 | 342 | ||
342 | void PackageManagerSettings::installationSettingSetName(const QString &name) | 343 | void PackageManagerSettings::installationSettingSetName(const QString &name) |
343 | { | 344 | { |
344 | settingName->changeItem( name, settingName->currentItem() ); | 345 | settingName->changeItem( name, settingName->currentItem() ); |
345 | changed = true; | 346 | changed = true; |
346 | } | 347 | } |
347 | 348 | ||
348 | 349 | ||
349 | bool PackageManagerSettings::readIpkgConfig(const QString& conffile) | 350 | bool PackageManagerSettings::readIpkgConfig(const QString& conffile) |
350 | { | 351 | { |
351 | QFile conf(conffile); | 352 | QFile conf(conffile); |
352 | changed = false; | 353 | changed = false; |
353 | if ( conf.open(IO_ReadOnly) ) { | 354 | if ( conf.open(IO_ReadOnly) ) { |
354 | QTextStream s(&conf); | 355 | QTextStream s(&conf); |
355 | servers->clear(); | 356 | servers->clear(); |
356 | activeServers->clear(); | 357 | activeServers->clear(); |
358 | destinations->clear(); | ||
357 | activeDestination->clear(); | 359 | activeDestination->clear(); |
358 | activeLinkDestination->clear(); | 360 | activeLinkDestination->clear(); |
359 | serverurlDic.clear(); | 361 | serverurlDic.clear(); |
360 | destinationurlDic.clear(); | 362 | destinationurlDic.clear(); |
361 | ipkg_old=0; | 363 | ipkg_old=0; |
362 | int currentserver=0; | 364 | int currentserver=0; |
363 | while ( !s.atEnd() ) { | 365 | while ( !s.atEnd() ) { |
364 | QString l = s.readLine(); | 366 | QString l = s.readLine(); |
365 | QStringList token = QStringList::split(' ', l); | 367 | QStringList token = QStringList::split(' ', l); |
366 | if ( token[0] == "src" || token[0] == "#src" ) { | 368 | if ( token[0] == "src" || token[0] == "#src" ) { |
367 | currentserver=servers->count(); | 369 | currentserver=servers->count(); |
368 | serverurlDic.insert(servers->count(),new QString(token[2])); | 370 | serverurlDic.insert(servers->count(),new QString(token[2])); |
369 | int a = token[0] == "src" ? 1 : 0; | 371 | int a = token[0] == "src" ? 1 : 0; |
370 | int i = servers->count(); | 372 | int i = servers->count(); |
371 | servers->insertItem(token[1]); | 373 | servers->insertItem(token[1]); |
372 | activeServers->insertItem( token[1] ); | 374 | activeServers->insertItem( token[1] ); |
373 | activeServers->setSelected(i,a); | 375 | activeServers->setSelected(i,a); |
374 | } else if ( token[0] == "dest" ) { | 376 | } else if ( token[0] == "dest" ) { |
375 | currentserver=destinations->count(); | 377 | currentserver=destinations->count(); |
376 | destinationurlDic.insert(destinations->count(),new QString(token[2])); | 378 | destinationurlDic.insert(destinations->count(),new QString(token[2])); |
377 | destinations->insertItem(token[1]); | 379 | destinations->insertItem(token[1]); |
378 | activeDestination->insertItem( token[1] ); | 380 | activeDestination->insertItem( token[1] ); |
379 | activeLinkDestination->insertItem( token[1] ); | 381 | activeLinkDestination->insertItem( token[1] ); |
380 | 382 | ||
381 | } else if ( token[0] == "option" ) { | 383 | } else if ( token[0] == "option" ) { |
382 | // ### somehow need to use the settings from netsetup | 384 | // ### somehow need to use the settings from netsetup |
383 | // if ( token[1] == "http_proxy" ) | 385 | // if ( token[1] == "http_proxy" ) |
384 | // http->setText(token[2]); | 386 | // http->setText(token[2]); |
385 | // else if ( token[1] == "ftp_proxy" ) | 387 | // else if ( token[1] == "ftp_proxy" ) |
386 | // ftp->setText(token[2]); | 388 | // ftp->setText(token[2]); |
387 | // else if ( token[1] == "proxy_username" ) | 389 | // else if ( token[1] == "proxy_username" ) |
388 | // username->setText(token[2]); | 390 | // username->setText(token[2]); |
389 | // else if ( token[1] == "proxy_password" ) | 391 | // else if ( token[1] == "proxy_password" ) |
390 | // password->setText(token[2]); | 392 | // password->setText(token[2]); |
391 | } else { | 393 | } else { |
392 | // Old style? | 394 | // Old style? |
393 | int eq = l.find('='); | 395 | int eq = l.find('='); |
394 | if ( eq >= 0 ) { | 396 | if ( eq >= 0 ) { |
395 | QString v = l.mid(eq+1).stripWhiteSpace(); | 397 | QString v = l.mid(eq+1).stripWhiteSpace(); |
396 | if ( v[0] == '"' || v[0] == '\'' ) { | 398 | if ( v[0] == '"' || v[0] == '\'' ) { |
397 | int cl=v.find(v[0],1); | 399 | int cl=v.find(v[0],1); |
398 | if ( cl >= 0 ) | 400 | if ( cl >= 0 ) |
399 | v = v.mid(1,cl-1); | 401 | v = v.mid(1,cl-1); |
400 | } | 402 | } |
401 | if ( l.left(12) == "IPKG_SOURCE=" ) { | 403 | if ( l.left(12) == "IPKG_SOURCE=" ) { |
402 | ipkg_old=1; | 404 | ipkg_old=1; |
403 | currentserver=servers->count(); | 405 | currentserver=servers->count(); |
404 | serverurlDic.insert(servers->count(),new QString(v)); | 406 | serverurlDic.insert(servers->count(),new QString(v)); |
405 | servers->insertItem(v); | 407 | servers->insertItem(v); |
406 | } else if ( l.left(13) == "#IPKG_SOURCE=" ) { | 408 | } else if ( l.left(13) == "#IPKG_SOURCE=" ) { |
407 | serverurlDic.insert(servers->count(),new QString(v)); | 409 | serverurlDic.insert(servers->count(),new QString(v)); |
408 | servers->insertItem(v); | 410 | servers->insertItem(v); |
409 | } else if ( l.left(10) == "IPKG_ROOT=" ) { | 411 | } else if ( l.left(10) == "IPKG_ROOT=" ) { |
410 | // ### no UI | 412 | // ### no UI |
411 | // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) { | 413 | // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) { |
412 | // username->setText(v); | 414 | // username->setText(v); |
413 | // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) { | 415 | // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) { |
414 | // password->setText(v); | 416 | // password->setText(v); |
415 | // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) { | 417 | // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) { |
416 | // http->setText(v); | 418 | // http->setText(v); |
417 | // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) { | 419 | // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) { |
418 | // ftp->setText(v); | 420 | // ftp->setText(v); |
419 | } | 421 | } |
420 | } | 422 | } |
421 | } | 423 | } |
422 | } | 424 | } |
423 | if ( ipkg_old ) { | 425 | if ( ipkg_old ) { |
424 | servers->setSelectionMode(QListBox::Single); | 426 | servers->setSelectionMode(QListBox::Single); |
425 | servers->setSelected(currentserver,TRUE); | 427 | servers->setSelected(currentserver,TRUE); |
426 | } | 428 | } |
427 | return TRUE; | 429 | return TRUE; |
428 | } else { | 430 | } else { |
429 | return FALSE; | 431 | return FALSE; |
430 | } | 432 | } |
431 | } | 433 | } |
432 | 434 | ||
433 | 435 | ||
434 | /** | 436 | /** |
435 | * read from config file(s) | 437 | * read from config file(s) |
436 | */ | 438 | */ |
437 | void PackageManagerSettings::readSettings() | 439 | void PackageManagerSettings::readSettings() |
438 | { | 440 | { |
439 | readIpkgConfig("/etc/ipkg.conf"); | 441 | readIpkgConfig("/etc/ipkg.conf"); |
440 | readInstallationSettings(); | 442 | readInstallationSettings(); |
441 | } | 443 | } |
442 | 444 | ||
443 | void PackageManagerSettings::writeSettings() | 445 | void PackageManagerSettings::writeSettings() |
444 | { | 446 | { |
445 | if ( changed ) writeIpkgConfig("/etc/ipkg.conf"); | 447 | if ( changed ) writeIpkgConfig("/etc/ipkg.conf"); |
446 | writeInstallationSettings(); | 448 | writeInstallationSettings(); |
447 | } | 449 | } |
448 | /** shows the setting dialog */ | 450 | /** shows the setting dialog */ |
449 | bool PackageManagerSettings::showDialog( int i ) | 451 | bool PackageManagerSettings::showDialog( int i ) |
450 | { | 452 | { |
451 | TabWidget->setCurrentPage( i ); | 453 | TabWidget->setCurrentPage( i ); |
452 | showMaximized(); | 454 | showMaximized(); |
453 | bool ret = exec(); | 455 | bool ret = exec(); |
454 | if ( ret ) writeSettings(); | 456 | if ( ret ) writeSettings(); |
455 | else readSettings(); | 457 | else readSettings(); |
456 | return (changed && ret); | 458 | return (changed && ret); |
457 | } | 459 | } |
458 | /** Returns the installation destination */ | 460 | /** Returns the installation destination */ |
459 | QString PackageManagerSettings::getDestinationName() | 461 | QString PackageManagerSettings::getDestinationName() |
460 | { | 462 | { |
461 | return activeDestination->currentText(); | 463 | return activeDestination->currentText(); |
462 | } | 464 | } |
463 | /** Returns the link destination */ | 465 | /** Returns the link destination */ |
464 | QString PackageManagerSettings::getLinkDestinationName() | 466 | QString PackageManagerSettings::getLinkDestinationName() |
465 | { | 467 | { |
466 | return activeLinkDestination->currentText(); | 468 | return activeLinkDestination->currentText(); |
467 | } | 469 | } |
468 | /** Returns the URL of the active destination */ | 470 | /** Returns the URL of the active destination */ |
469 | QString PackageManagerSettings::getDestinationUrl() | 471 | QString PackageManagerSettings::getDestinationUrl() |
470 | { | 472 | { |
471 | int dnr = activeDestination->currentItem(); | 473 | int dnr = activeDestination->currentItem(); |
472 | return *destinationurlDic.find(dnr); | 474 | return *destinationurlDic.find(dnr); |
473 | } | 475 | } |
474 | /** Should oipkg create links form install destination to link destination */ | 476 | /** Should oipkg create links form install destination to link destination */ |
475 | bool PackageManagerSettings::createLinks() | 477 | bool PackageManagerSettings::createLinks() |
476 | { | 478 | { |
477 | return CheckBoxLink->isChecked(); | 479 | return CheckBoxLink->isChecked(); |
478 | } | 480 | } |
479 | /** get the servers that are active */ | 481 | /** get the servers that are active */ |
480 | QStringList PackageManagerSettings::getActiveServers() | 482 | QStringList PackageManagerSettings::getActiveServers() |
481 | { | 483 | { |
482 | QStringList sl; | 484 | QStringList sl; |
483 | for (int i=0; i<(int)activeServers->count(); i++) | 485 | for (int i=0; i<(int)activeServers->count(); i++) |
484 | { | 486 | { |
485 | if ( activeServers->isSelected(i) ) | 487 | if ( activeServers->isSelected(i) ) |
486 | sl += activeServers->text(i); | 488 | sl += activeServers->text(i); |
487 | } | 489 | } |
488 | return sl; | 490 | return sl; |
489 | } | 491 | } |
490 | QStringList PackageManagerSettings::getServers() | 492 | QStringList PackageManagerSettings::getServers() |
491 | { | 493 | { |
492 | QStringList sl; | 494 | QStringList sl; |
493 | for (int i=0; i<(int)activeServers->count(); i++) | 495 | for (int i=0; i<(int)activeServers->count(); i++) |
494 | { | 496 | { |
495 | sl += activeServers->text(i); | 497 | sl += activeServers->text(i); |
496 | } | 498 | } |
497 | return sl; | 499 | return sl; |
498 | } | 500 | } |
499 | 501 | ||
500 | /** returns the destination listed in ipkg.conf */ | 502 | /** returns the destination listed in ipkg.conf */ |
501 | QStringList PackageManagerSettings::getDestinationUrls() | 503 | QStringList PackageManagerSettings::getDestinationUrls() |
502 | { | 504 | { |
503 | QStringList sl; | 505 | QStringList sl; |
504 | for (int i=0; i<(int)destinations->count(); i++) | 506 | for (int i=0; i<(int)destinations->count(); i++) |
505 | { | 507 | { |
506 | sl += *destinationurlDic[i]; | 508 | sl += *destinationurlDic[i]; |
507 | } | 509 | } |
508 | return sl; | 510 | return sl; |
509 | } | 511 | } |
510 | 512 | ||
511 | /** returns the destination listed in ipkg.conf */ | 513 | /** returns the destination listed in ipkg.conf */ |
512 | QString PackageManagerSettings::getDestinationUrlByName(QString n) | 514 | QString PackageManagerSettings::getDestinationUrlByName(QString n) |
513 | { | 515 | { |
514 | QStringList sl; | 516 | QStringList sl; |
515 | for (int i=0; i<(int)destinations->count(); i++) | 517 | for (int i=0; i<(int)destinations->count(); i++) |
516 | { | 518 | { |
517 | if ( n == destinations->text(i)) return*destinationurlDic[i]; | 519 | if ( n == destinations->text(i)) return*destinationurlDic[i]; |
518 | } | 520 | } |
519 | return ""; | 521 | return ""; |
520 | } | 522 | } |
521 | 523 | ||
522 | /** returns the destination listed in ipkg.conf */ | 524 | /** returns the destination listed in ipkg.conf */ |
523 | QStringList PackageManagerSettings::getDestinationNames() | 525 | QStringList PackageManagerSettings::getDestinationNames() |
524 | { | 526 | { |
525 | QStringList sl; | 527 | QStringList sl; |
526 | for (int i=0; i<(int)destinations->count(); i++) | 528 | for (int i=0; i<(int)destinations->count(); i++) |
527 | { | 529 | { |
528 | sl += destinations->text(i); | 530 | sl += destinations->text(i); |
529 | } | 531 | } |
530 | return sl; | 532 | return sl; |
531 | } | 533 | } |
532 | 534 | ||
533 | 535 | ||
534 | void PackageManagerSettings::linkEnabled( bool b ) | 536 | void PackageManagerSettings::linkEnabled( bool b ) |
535 | { | 537 | { |
536 | pvDebug(2,"PackageManagerSettings::linkEnabled "+QString(b?"yes":"no")); | 538 | pvDebug(2,"PackageManagerSettings::linkEnabled "+QString(b?"yes":"no")); |
537 | activeLinkDestination->setEnabled( b ); | 539 | activeLinkDestination->setEnabled( b ); |
538 | } | 540 | } |
539 | 541 | ||
540 | void PackageManagerSettings::activeServerChanged() | 542 | void PackageManagerSettings::activeServerChanged() |
541 | { | 543 | { |
542 | changed = true; | 544 | changed = true; |
543 | } | 545 | } |
544 | 546 | ||
545 | QComboBox* PackageManagerSettings::getDestCombo() | 547 | QComboBox* PackageManagerSettings::getDestCombo() |
546 | { | 548 | { |
547 | return new QComboBox(activeDestination); | 549 | return new QComboBox(activeDestination); |
548 | } | 550 | } |
549 | 551 | ||
550 | void PackageManagerSettings::createLinksToDest() | 552 | void PackageManagerSettings::createLinksToDest() |
551 | { | 553 | { |
552 | pvDebug(2,"creating links..."); | 554 | pvDebug(2,"creating links..."); |
553 | // emit doCreateLinks( destinationurl->text() ); | 555 | // emit doCreateLinks( destinationurl->text() ); |
554 | //ipkg->createLinks( destinationurl ); | 556 | //ipkg->createLinks( destinationurl ); |
555 | } | 557 | } |
556 | 558 | ||
557 | void PackageManagerSettings::removeLinksToDest() | 559 | void PackageManagerSettings::removeLinksToDest() |
558 | { | 560 | { |
559 | pvDebug(2,"removing links..."); | 561 | pvDebug(2,"removing links..."); |
560 | // emit doRemoveLinks( destinationurl->text() ); | 562 | // emit doRemoveLinks( destinationurl->text() ); |
561 | //ipkg->removeLinks( destinationurl ); | 563 | //ipkg->removeLinks( destinationurl ); |
562 | } | 564 | } |
563 | 565 | ||
564 | //void PackageManagerSettings::setIpkg( PmIpkg* i ) | 566 | //void PackageManagerSettings::setIpkg( PmIpkg* i ) |
565 | //{ | 567 | //{ |
566 | //ipkg = i; | 568 | //ipkg = i; |
567 | //} | 569 | //} |
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 6ef6d19..0401a5b 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp | |||
@@ -1,393 +1,395 @@ | |||
1 | #include "pmipkg.h" | 1 | #include "pmipkg.h" |
2 | #include "pksettings.h" | 2 | #include "pksettings.h" |
3 | #include "package.h" | 3 | #include "package.h" |
4 | #include "packagelistitem.h" | 4 | #include "packagelistitem.h" |
5 | 5 | ||
6 | #include <qpe/process.h> | 6 | #include <qpe/process.h> |
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | #include <qpe/config.h> | 8 | #include <qpe/config.h> |
9 | #include <qpe/stringutil.h> | 9 | #include <qpe/stringutil.h> |
10 | #include <qpe/qpeapplication.h> | 10 | #include <qpe/qpeapplication.h> |
11 | #include <qdir.h> | 11 | #include <qdir.h> |
12 | #include <qfile.h> | 12 | #include <qfile.h> |
13 | #include <qgroupbox.h> | 13 | #include <qgroupbox.h> |
14 | #include <qmultilineedit.h> | 14 | #include <qmultilineedit.h> |
15 | #include <qstring.h> | 15 | #include <qstring.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qtextstream.h> | 17 | #include <qtextstream.h> |
18 | #include <qtextview.h> | 18 | #include <qtextview.h> |
19 | 19 | ||
20 | #include <qprogressbar.h> | 20 | #include <qprogressbar.h> |
21 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
22 | #include <qlayout.h> | 22 | #include <qlayout.h> |
23 | 23 | ||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <unistd.h> | 25 | #include <unistd.h> |
26 | 26 | ||
27 | #include "mainwindow.h" | 27 | #include "mainwindow.h" |
28 | 28 | ||
29 | 29 | ||
30 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) | 30 | PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) |
31 | : QObject ( p ) | 31 | : QObject ( p ) |
32 | { | 32 | { |
33 | settings = s; | 33 | settings = s; |
34 | runwindow = new RunWindow( p, name, true, f ); | 34 | runwindow = new RunWindow( p, name, true, f ); |
35 | } | 35 | } |
36 | 36 | ||
37 | PmIpkg::~PmIpkg() | 37 | PmIpkg::~PmIpkg() |
38 | { | 38 | { |
39 | } | 39 | } |
40 | 40 | ||
41 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) | 41 | bool PmIpkg::runIpkg(const QString& args, const QString& dest ) |
42 | { | 42 | { |
43 | bool ret=false; | 43 | bool ret=false; |
44 | QDir::setCurrent("/tmp"); | 44 | QDir::setCurrent("/tmp"); |
45 | QString cmd = "/usr/bin/ipkg "; | 45 | QString cmd = "/usr/bin/ipkg "; |
46 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); | 46 | pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); |
47 | if ( dest == "" ) | 47 | if ( dest == "" ) |
48 | cmd += " -dest "+settings->getDestinationName(); | 48 | cmd += " -dest "+settings->getDestinationName(); |
49 | else | 49 | else |
50 | cmd += " -dest "+ dest; | 50 | cmd += " -dest "+ dest; |
51 | 51 | ||
52 | cmd += " -force-defaults "; | 52 | cmd += " -force-defaults "; |
53 | 53 | ||
54 | if (installDialog && installDialog->_force_depends) | 54 | if (installDialog && installDialog->_force_depends) |
55 | { | 55 | { |
56 | if (installDialog->_force_depends->isChecked()) | 56 | if (installDialog->_force_depends->isChecked()) |
57 | cmd += " -force-depends "; | 57 | cmd += " -force-depends "; |
58 | if (installDialog->_force_reinstall->isChecked()) | 58 | if (installDialog->_force_reinstall->isChecked()) |
59 | cmd += " -force-reinstall "; | 59 | cmd += " -force-reinstall "; |
60 | if (installDialog->_force_remove->isChecked()) | 60 | if (installDialog->_force_remove->isChecked()) |
61 | cmd += " -force-removal-of-essential-packages "; | 61 | cmd += " -force-removal-of-essential-packages "; |
62 | } | 62 | } |
63 | 63 | ||
64 | out( "Starting to "+ args+"\n"); | 64 | out( "Starting to "+ args+"\n"); |
65 | cmd += args; | 65 | cmd += args; |
66 | out( "running:\n"+cmd+"\n" ); | 66 | out( "running:\n"+cmd+"\n" ); |
67 | pvDebug(2,"running:"+cmd); | 67 | pvDebug(2,"running:"+cmd); |
68 | qApp->processEvents(); | 68 | qApp->processEvents(); |
69 | FILE *fp; | 69 | FILE *fp; |
70 | char line[130]; | 70 | char line[130]; |
71 | QString lineStr, lineStrOld; | 71 | QString lineStr, lineStrOld; |
72 | sleep(1); | 72 | sleep(1); |
73 | cmd +=" 2>&1"; | 73 | cmd +=" 2>&1"; |
74 | fp = popen( (const char *) cmd, "r"); | 74 | fp = popen( (const char *) cmd, "r"); |
75 | if ( !fp ) { | 75 | if ( !fp ) { |
76 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); | 76 | qDebug("Could not execute '" + cmd + "'! err=%d", fp); |
77 | pclose(fp); | 77 | pclose(fp); |
78 | out("\nError while executing "+ cmd+"\n\n"); | 78 | out("\nError while executing "+ cmd+"\n\n"); |
79 | return false; | 79 | return false; |
80 | } else { | 80 | } else { |
81 | while ( fgets( line, sizeof line, fp)) { | 81 | while ( fgets( line, sizeof line, fp)) { |
82 | lineStr = line; | 82 | lineStr = line; |
83 | lineStr=lineStr.left(lineStr.length()-1); | 83 | lineStr=lineStr.left(lineStr.length()-1); |
84 | //Configuring opie-oipkg...Done | 84 | //Configuring opie-oipkg...Done |
85 | if (lineStr.contains("Done")) | 85 | if (lineStr.contains("Done")) |
86 | ret = true; | 86 | ret = true; |
87 | if (lineStr!=lineStrOld) | 87 | if (lineStr!=lineStrOld) |
88 | out(lineStr); | 88 | out(lineStr); |
89 | lineStrOld = lineStr; | 89 | lineStrOld = lineStr; |
90 | qApp->processEvents(); | 90 | qApp->processEvents(); |
91 | } | 91 | } |
92 | pclose(fp); | 92 | pclose(fp); |
93 | } | 93 | } |
94 | //out( "Finished!"); | 94 | //out( "Finished!"); |
95 | pvDebug(2,QString(ret?"success\n":"failure\n")); | 95 | pvDebug(2,QString(ret?"success\n":"failure\n")); |
96 | return ret; | 96 | return ret; |
97 | } | 97 | } |
98 | 98 | ||
99 | void PmIpkg::makeLinks(Package *pack) | 99 | void PmIpkg::makeLinks(Package *pack) |
100 | { | 100 | { |
101 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); | 101 | pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); |
102 | linkPackage( pack->name(), pack->dest() ); | 102 | linkPackage( pack->name(), pack->dest() ); |
103 | } | 103 | } |
104 | 104 | ||
105 | QStringList* PmIpkg::getList( QString packFileName, QString d ) | 105 | QStringList* PmIpkg::getList( QString packFileName, QString d ) |
106 | { | 106 | { |
107 | QString dest = settings->getDestinationUrlByName( d ); | 107 | QString dest = settings->getDestinationUrlByName( d ); |
108 | dest = dest==""?d:dest; | 108 | dest = dest==""?d:dest; |
109 | if (dest == "/" ) return 0; | 109 | if (dest == "/" ) return 0; |
110 | { | 110 | { |
111 | Config cfg( "oipkg", Config::User ); | 111 | Config cfg( "oipkg", Config::User ); |
112 | cfg.setGroup( "Common" ); | 112 | cfg.setGroup( "Common" ); |
113 | QString statusDir = cfg.readEntry( "statusDir", "" ); | 113 | QString statusDir = cfg.readEntry( "statusDir", "" ); |
114 | } | 114 | } |
115 | packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list"; | 115 | packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list"; |
116 | QFile f( packFileName ); | 116 | QFile f( packFileName ); |
117 | if ( ! f.open(IO_ReadOnly) ) | 117 | if ( ! f.open(IO_ReadOnly) ) |
118 | { | 118 | { |
119 | pvDebug(1," Panik! Could not open"); | 119 | pvDebug(1," Panik! Could not open"); |
120 | out( "Panik!\n Could not open:\n"+packFileName ); | 120 | out( "Panik!\n Could not open:\n"+packFileName ); |
121 | return (QStringList*)0; | 121 | return (QStringList*)0; |
122 | } | 122 | } |
123 | QStringList *fileList = new QStringList(); | 123 | QStringList *fileList = new QStringList(); |
124 | QTextStream t( &f ); | 124 | QTextStream t( &f ); |
125 | while ( !t.eof() ) | 125 | while ( !t.eof() ) |
126 | { | 126 | { |
127 | *fileList += t.readLine(); | 127 | *fileList += t.readLine(); |
128 | } | 128 | } |
129 | return fileList; | 129 | return fileList; |
130 | } | 130 | } |
131 | 131 | ||
132 | void PmIpkg::linkPackage( QString packFileName, QString dest ) | 132 | void PmIpkg::linkPackage( QString packFileName, QString dest ) |
133 | { | 133 | { |
134 | QStringList *fileList = getList( packFileName, dest ); | 134 | QStringList *fileList = getList( packFileName, dest ); |
135 | processFileList( fileList, dest ); | 135 | processFileList( fileList, dest ); |
136 | delete fileList; | 136 | delete fileList; |
137 | } | 137 | } |
138 | 138 | ||
139 | void PmIpkg::processFileList( QStringList *fileList, QString d ) | 139 | void PmIpkg::processFileList( QStringList *fileList, QString d ) |
140 | { | 140 | { |
141 | if (!fileList) return; | 141 | if (!fileList) return; |
142 | for (uint i=0; i < fileList->count(); i++) | 142 | for (uint i=0; i < fileList->count(); i++) |
143 | { | 143 | { |
144 | QString dest = settings->getDestinationUrlByName( d ); | 144 | QString dest = settings->getDestinationUrlByName( d ); |
145 | dest = dest==""?d:dest; | 145 | dest = dest==""?d:dest; |
146 | processLinkDir( (*fileList)[i], dest ); | 146 | processLinkDir( (*fileList)[i], dest ); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | 149 | ||
150 | 150 | ||
151 | void PmIpkg::processLinkDir( QString file, QString dest ) | 151 | void PmIpkg::processLinkDir( QString file, QString dest ) |
152 | { | 152 | { |
153 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); | 153 | pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); |
154 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); | 154 | if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); |
155 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); | 155 | if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); |
156 | if ( dest == "???" || dest == "" ) return; | 156 | if ( dest == "???" || dest == "" ) return; |
157 | QString destFile = file; | 157 | QString destFile = file; |
158 | file = dest+"/"+file; | 158 | file = dest+"/"+file; |
159 | if (file == dest) return; | 159 | if (file == dest) return; |
160 | // if (linkOpp==createLink) out( "\ncreating links\n" ); | 160 | // if (linkOpp==createLink) out( "\ncreating links\n" ); |
161 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); | 161 | // if (linkOpp==removeLink) out( "\nremoving links\n" ); |
162 | QFileInfo fileInfo( file ); | 162 | QFileInfo fileInfo( file ); |
163 | if ( fileInfo.isDir() ) | 163 | if ( fileInfo.isDir() ) |
164 | { | 164 | { |
165 | pvDebug(4, "process dir "+file); | 165 | pvDebug(4, "process dir "+file); |
166 | QDir destDir( destFile ); | 166 | QDir destDir( destFile ); |
167 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); | 167 | if (linkOpp==createLink) destDir.mkdir( destFile, true ); |
168 | QDir d( file ); | 168 | QDir d( file ); |
169 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); | 169 | // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); |
170 | const QFileInfoList *list = d.entryInfoList(); | 170 | const QFileInfoList *list = d.entryInfoList(); |
171 | QFileInfoListIterator it( *list ); | 171 | QFileInfoListIterator it( *list ); |
172 | QFileInfo *fi; | 172 | QFileInfo *fi; |
173 | while ( (fi=it.current()) ) | 173 | while ( (fi=it.current()) ) |
174 | { | 174 | { |
175 | pvDebug(4, "processLinkDir "+fi->absFilePath()); | 175 | pvDebug(4, "processLinkDir "+fi->absFilePath()); |
176 | processLinkDir( fi->absFilePath(), dest ); | 176 | processLinkDir( fi->absFilePath(), dest ); |
177 | ++it; | 177 | ++it; |
178 | } | 178 | } |
179 | } else | 179 | } else |
180 | if ( fileInfo.isFile() ) | 180 | if ( fileInfo.isFile() ) |
181 | { | 181 | { |
182 | const char *instFile = strdup( (file).ascii() ); | 182 | const char *instFile = strdup( (file).ascii() ); |
183 | const char *linkFile = strdup( (destFile).ascii()); | 183 | const char *linkFile = strdup( (destFile).ascii()); |
184 | if( linkOpp==createLink ) | 184 | if( linkOpp==createLink ) |
185 | { | 185 | { |
186 | pvDebug(4, "linking: "+file+" -> "+destFile ); | 186 | pvDebug(4, "linking: "+file+" -> "+destFile ); |
187 | symlink( instFile, linkFile ); | 187 | symlink( instFile, linkFile ); |
188 | } | 188 | } |
189 | } else { | 189 | } else { |
190 | const char *linkFile = strdup( (destFile).ascii()); | 190 | const char *linkFile = strdup( (destFile).ascii()); |
191 | if( linkOpp==removeLink ) | 191 | if( linkOpp==removeLink ) |
192 | { | 192 | { |
193 | QFileInfo toRemoveLink( destFile ); | 193 | QFileInfo toRemoveLink( destFile ); |
194 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) | 194 | if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) |
195 | { | 195 | { |
196 | pvDebug(4,"removing "+destFile+" no "+file); | 196 | pvDebug(4,"removing "+destFile+" no "+file); |
197 | unlink( linkFile ); | 197 | unlink( linkFile ); |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
203 | void PmIpkg::loadList( PackageList *pl ) | 203 | void PmIpkg::loadList( PackageList *pl ) |
204 | { | 204 | { |
205 | for( Package *pack = pl->first();pack ; (pack = pl->next()) ) | 205 | for( Package *pack = pl->first();pack ; (pack = pl->next()) ) |
206 | { | 206 | { |
207 | if ( pack && (pack->name() != "") && pack) | 207 | if ( pack && (pack->name() != "") && pack) |
208 | { | 208 | { |
209 | if ( pack->toInstall() ) | 209 | if ( pack->toInstall() ) |
210 | to_install.append( pack ); | 210 | to_install.append( pack ); |
211 | if ( pack->toRemove() ) | 211 | if ( pack->toRemove() ) |
212 | to_remove.append( pack ); | 212 | to_remove.append( pack ); |
213 | } | 213 | } |
214 | } | 214 | } |
215 | } | 215 | } |
216 | 216 | ||
217 | void PmIpkg::commit() | 217 | void PmIpkg::commit() |
218 | { | 218 | { |
219 | int sizecount = 0; | 219 | int sizecount = 0; |
220 | installDialog = new InstallDialog(settings,0,0,true); | 220 | installDialog = new InstallDialog(settings,0,0,true); |
221 | installDialog->toRemoveItem->setOpen( true ); | 221 | installDialog->toRemoveItem->setOpen( true ); |
222 | installDialog->toInstallItem->setOpen( true ); | 222 | installDialog->toInstallItem->setOpen( true ); |
223 | for (uint i=0; i < to_remove.count(); i++) | 223 | for (uint i=0; i < to_remove.count(); i++) |
224 | { | 224 | { |
225 | sizecount += 1; | 225 | sizecount += 1; |
226 | installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); | 226 | installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); |
227 | } | 227 | } |
228 | for (uint i=0; i < to_install.count(); i++) | 228 | for (uint i=0; i < to_install.count(); i++) |
229 | { | 229 | { |
230 | sizecount += to_install.at(i)->size().toInt(); | 230 | sizecount += to_install.at(i)->size().toInt(); |
231 | installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); | 231 | installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); |
232 | } | 232 | } |
233 | runwindow->progress->setTotalSteps(sizecount); | 233 | runwindow->progress->setTotalSteps(sizecount); |
234 | qDebug("Install size %i",sizecount); | 234 | qDebug("Install size %i",sizecount); |
235 | installDialog->showMaximized(); | 235 | installDialog->showMaximized(); |
236 | installDialog->show(); | 236 | installDialog->show(); |
237 | if ( installDialog->exec() ) | 237 | if ( installDialog->exec() ) |
238 | { | 238 | { |
239 | doIt(); | 239 | doIt(); |
240 | runwindow->showMaximized(); | 240 | runwindow->showMaximized(); |
241 | runwindow->show(); | 241 | runwindow->show(); |
242 | } | 242 | } |
243 | installDialog->close(); | 243 | installDialog->close(); |
244 | out(tr("\nAll done.")); | 244 | out(tr("\nAll done.")); |
245 | } | 245 | } |
246 | 246 | ||
247 | void PmIpkg::doIt() | 247 | void PmIpkg::doIt() |
248 | { | 248 | { |
249 | runwindow->progress->setProgress(0); | 249 | runwindow->progress->setProgress(0); |
250 | show(); | 250 | show(); |
251 | remove(); | 251 | remove(); |
252 | install(); | 252 | install(); |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
256 | void PmIpkg::remove() | 256 | void PmIpkg::remove() |
257 | { | 257 | { |
258 | if ( to_remove.count() == 0 ) return; | 258 | if ( to_remove.count() == 0 ) return; |
259 | 259 | ||
260 | out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); | 260 | out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); |
261 | 261 | ||
262 | QStringList *fileList; | 262 | QStringList *fileList; |
263 | for (uint i=0; i < to_remove.count(); i++) | 263 | for (uint i=0; i < to_remove.count(); i++) |
264 | { | 264 | { |
265 | if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); | 265 | if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); |
266 | if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) | 266 | if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) |
267 | { | 267 | { |
268 | runwindow->progress->setProgress( 1 ); | 268 | runwindow->progress->setProgress( 1 ); |
269 | linkOpp = removeLink; | 269 | linkOpp = removeLink; |
270 | to_remove.at(i)->processed(); | 270 | to_remove.at(i)->processed(); |
271 | pvDebug(4,"link "+QString::number(i)); | ||
271 | if ( to_remove.at(i)->link() ) | 272 | if ( to_remove.at(i)->link() ) |
272 | processFileList( fileList, to_remove.at(i)->dest() ); | 273 | processFileList( fileList, to_remove.at(i)->dest() ); |
274 | pvDebug(4,"take "+QString::number(i)); | ||
273 | to_remove.take( i ); | 275 | to_remove.take( i ); |
274 | 276 | ||
275 | out("\n"); | 277 | out("\n"); |
276 | }else{ | 278 | }else{ |
277 | out(tr("Error while removing")+to_remove.at(i)->name()+"\n"); | 279 | out(tr("Error while removing")+to_remove.at(i)->name()+"\n"); |
278 | if ( to_remove.at(i)->link() ) | 280 | if ( to_remove.at(i)->link() ) |
279 | processFileList( fileList, to_remove.at(i)->dest() ); | 281 | processFileList( fileList, to_remove.at(i)->dest() ); |
280 | } | 282 | } |
281 | if ( to_remove.at(i)->link() ) | 283 | if ( to_remove.at(i)->link() ) |
282 | processFileList( fileList, to_remove.at(i)->dest() ); | 284 | processFileList( fileList, to_remove.at(i)->dest() ); |
283 | if ( to_remove.at(i)->link() )delete fileList; | 285 | if ( to_remove.at(i)->link() )delete fileList; |
284 | } | 286 | } |
285 | to_remove.clear(); | 287 | to_remove.clear(); |
286 | out("\n"); | 288 | out("\n"); |
287 | } | 289 | } |
288 | 290 | ||
289 | 291 | ||
290 | void PmIpkg::install() | 292 | void PmIpkg::install() |
291 | { | 293 | { |
292 | if ( to_install.count() == 0 ) return; | 294 | if ( to_install.count() == 0 ) return; |
293 | out(tr("Installing")+"\n"+tr("please wait")+"\n"); | 295 | out(tr("Installing")+"\n"+tr("please wait")+"\n"); |
294 | for (uint i=0; i < to_install.count(); i++) | 296 | for (uint i=0; i < to_install.count(); i++) |
295 | { | 297 | { |
296 | qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug | 298 | qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug |
297 | if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) | 299 | if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) |
298 | { | 300 | { |
299 | runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); | 301 | runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); |
300 | to_install.at(i)->processed(); | 302 | to_install.at(i)->processed(); |
301 | linkOpp = createLink; | 303 | linkOpp = createLink; |
302 | if ( to_install.at(i)->link() ) | 304 | if ( to_install.at(i)->link() ) |
303 | makeLinks( to_install.at(i) ); | 305 | makeLinks( to_install.at(i) ); |
304 | to_install.take( i ); | 306 | to_install.take( i ); |
305 | out("\n"); | 307 | out("\n"); |
306 | }else{ | 308 | }else{ |
307 | out(tr("Error while installing")+to_install.at(i)->name()+"\n"); | 309 | out(tr("Error while installing")+to_install.at(i)->name()+"\n"); |
308 | linkOpp = createLink; | 310 | linkOpp = createLink; |
309 | if ( to_install.at(i)->link() ) | 311 | if ( to_install.at(i)->link() ) |
310 | makeLinks( to_install.at(i) ); | 312 | makeLinks( to_install.at(i) ); |
311 | } | 313 | } |
312 | } | 314 | } |
313 | out("\n"); | 315 | out("\n"); |
314 | to_install.clear(); | 316 | to_install.clear(); |
315 | } | 317 | } |
316 | 318 | ||
317 | void PmIpkg::createLinks( const QString &dest ) | 319 | void PmIpkg::createLinks( const QString &dest ) |
318 | { | 320 | { |
319 | pvDebug(2,"PmIpkg::createLinks "+dest); | 321 | pvDebug(2,"PmIpkg::createLinks "+dest); |
320 | linkOpp=createLink; | 322 | linkOpp=createLink; |
321 | QString url = settings->getDestinationUrlByName( dest ); | 323 | QString url = settings->getDestinationUrlByName( dest ); |
322 | url = url==""?dest:url; | 324 | url = url==""?dest:url; |
323 | processLinkDir( "/opt", url ); | 325 | processLinkDir( "/opt", url ); |
324 | processLinkDir( "/usr", url ); | 326 | processLinkDir( "/usr", url ); |
325 | } | 327 | } |
326 | 328 | ||
327 | void PmIpkg::removeLinks( const QString &dest ) | 329 | void PmIpkg::removeLinks( const QString &dest ) |
328 | { | 330 | { |
329 | pvDebug(2,"PmIpkg::removeLinks "+dest); | 331 | pvDebug(2,"PmIpkg::removeLinks "+dest); |
330 | linkOpp=removeLink; | 332 | linkOpp=removeLink; |
331 | QString url = settings->getDestinationUrlByName( dest ); | 333 | QString url = settings->getDestinationUrlByName( dest ); |
332 | url = url==""?dest:url; | 334 | url = url==""?dest:url; |
333 | processLinkDir( "/opt", url ); | 335 | processLinkDir( "/opt", url ); |
334 | processLinkDir( "/usr", url ); | 336 | processLinkDir( "/usr", url ); |
335 | } | 337 | } |
336 | 338 | ||
337 | void PmIpkg::update() | 339 | void PmIpkg::update() |
338 | { | 340 | { |
339 | show(); | 341 | show(); |
340 | runIpkg( "update" ); | 342 | runIpkg( "update" ); |
341 | runwindow->close(); | 343 | runwindow->close(); |
342 | } | 344 | } |
343 | 345 | ||
344 | void PmIpkg::out( QString o ) | 346 | void PmIpkg::out( QString o ) |
345 | { | 347 | { |
346 | runwindow->outPut->append(o); | 348 | runwindow->outPut->append(o); |
347 | runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); | 349 | runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); |
348 | } | 350 | } |
349 | 351 | ||
350 | 352 | ||
351 | 353 | ||
352 | 354 | ||
353 | void PmIpkg::show() | 355 | void PmIpkg::show() |
354 | { | 356 | { |
355 | if (!runwindow->isVisible()) | 357 | if (!runwindow->isVisible()) |
356 | { | 358 | { |
357 | runwindow->showMaximized(); | 359 | runwindow->showMaximized(); |
358 | runwindow->show(); | 360 | runwindow->show(); |
359 | } | 361 | } |
360 | runwindow->outPut->setText(""); | 362 | runwindow->outPut->setText(""); |
361 | //showButtons(b); | 363 | //showButtons(b); |
362 | //if ( !b ) | 364 | //if ( !b ) |
363 | // runwindow->progress->hide(); | 365 | // runwindow->progress->hide(); |
364 | // else | 366 | // else |
365 | // runwindow->progress->show(); | 367 | // runwindow->progress->show(); |
366 | } | 368 | } |
367 | 369 | ||
368 | void PmIpkg::installFile(const QString &fileName, const QString &dest) | 370 | void PmIpkg::installFile(const QString &fileName, const QString &dest) |
369 | { | 371 | { |
370 | 372 | ||
371 | to_install.clear(); | 373 | to_install.clear(); |
372 | to_remove.clear(); | 374 | to_remove.clear(); |
373 | pvDebug( 2,"PmIpkg::installFile "+ fileName); | 375 | pvDebug( 2,"PmIpkg::installFile "+ fileName); |
374 | Package *p = new Package(fileName,settings); | 376 | Package *p = new Package(fileName,settings); |
375 | if ( dest!="") p->setDest( dest ); | 377 | if ( dest!="") p->setDest( dest ); |
376 | to_install.append( p ); | 378 | to_install.append( p ); |
377 | commit(); | 379 | commit(); |
378 | delete p; | 380 | delete p; |
379 | } | 381 | } |
380 | 382 | ||
381 | void PmIpkg::removeFile(const QString &fileName, const QString &dest) | 383 | void PmIpkg::removeFile(const QString &fileName, const QString &dest) |
382 | { | 384 | { |
383 | 385 | ||
384 | to_install.clear(); | 386 | to_install.clear(); |
385 | to_remove.clear(); | 387 | to_remove.clear(); |
386 | pvDebug( 2,"PmIpkg::removeFile "+ fileName); | 388 | pvDebug( 2,"PmIpkg::removeFile "+ fileName); |
387 | Package *p = new Package(fileName,settings); | 389 | Package *p = new Package(fileName,settings); |
388 | if ( dest!="") p->setDest( dest ); | 390 | if ( dest!="") p->setDest( dest ); |
389 | to_remove.append( p ); | 391 | to_remove.append( p ); |
390 | commit(); | 392 | commit(); |
391 | delete p; | 393 | delete p; |
392 | } | 394 | } |
393 | 395 | ||
diff --git a/noncore/unsupported/oipkg/settings.cpp b/noncore/unsupported/oipkg/settings.cpp index 8f91995..85daa98 100644 --- a/noncore/unsupported/oipkg/settings.cpp +++ b/noncore/unsupported/oipkg/settings.cpp | |||
@@ -1,441 +1,441 @@ | |||
1 | #include "pksettings.h" | 1 | #include "pksettings.h" |
2 | 2 | ||
3 | #include <qpe/config.h> | 3 | #include <qpe/config.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qlineedit.h> | 6 | #include <qlineedit.h> |
7 | #include <qpushbutton.h> | 7 | #include <qpushbutton.h> |
8 | #include <qlistbox.h> | 8 | #include <qlistbox.h> |
9 | #include <qcheckbox.h> | 9 | #include <qcheckbox.h> |
10 | #include <qstring.h> | 10 | #include <qstring.h> |
11 | #include <qobject.h> | 11 | #include <qobject.h> |
12 | #include <qtextstream.h> | 12 | #include <qtextstream.h> |
13 | #include <qtabwidget.h> | 13 | #include <qtabwidget.h> |
14 | 14 | ||
15 | 15 | ||
16 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) | 16 | PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl ) |
17 | : PackageManagerSettingsBase( parent, name, fl ) | 17 | : PackageManagerSettingsBase( parent, name, fl ) |
18 | { | 18 | { |
19 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); | 19 | connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) ); |
20 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); | 20 | connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) ); |
21 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 21 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
22 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); | 22 | connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) ); |
23 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); | 23 | connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) ); |
24 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 24 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
25 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), | 25 | // connect( CheckBoxLink, SIGNAL(toggled(bool)), |
26 | // activeLinkDestination, SLOT(setEnabled(bool)) ); | 26 | // activeLinkDestination, SLOT(setEnabled(bool)) ); |
27 | 27 | ||
28 | connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); | 28 | connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) ); |
29 | connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); | 29 | connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) ); |
30 | connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); | 30 | connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) ); |
31 | connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); | 31 | connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) ); |
32 | connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); | 32 | connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) ); |
33 | servername->setEnabled(FALSE); | 33 | servername->setEnabled(FALSE); |
34 | serverurl->setEnabled(FALSE); | 34 | serverurl->setEnabled(FALSE); |
35 | serverurlDic.setAutoDelete(TRUE); | 35 | serverurlDic.setAutoDelete(TRUE); |
36 | destinationname->setEnabled(FALSE); | 36 | destinationname->setEnabled(FALSE); |
37 | destinationurl->setEnabled(FALSE); | 37 | destinationurl->setEnabled(FALSE); |
38 | destinationurlDic.setAutoDelete(TRUE); | 38 | destinationurlDic.setAutoDelete(TRUE); |
39 | readSettings(); | 39 | readSettings(); |
40 | } | 40 | } |
41 | 41 | ||
42 | PackageManagerSettings::~PackageManagerSettings() | 42 | PackageManagerSettings::~PackageManagerSettings() |
43 | { | 43 | { |
44 | } | 44 | } |
45 | 45 | ||
46 | 46 | ||
47 | void PackageManagerSettings::newServer() | 47 | void PackageManagerSettings::newServer() |
48 | { | 48 | { |
49 | int i = servers->count(); | 49 | int i = servers->count(); |
50 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { | 50 | if ( servername->isEnabled() || serverurl->text().isEmpty() ) { |
51 | serverurlDic.insert(i,new QString("http://")); | 51 | serverurlDic.insert(i,new QString("http://")); |
52 | servers->insertItem(tr("New")); | 52 | servers->insertItem(tr("New")); |
53 | activeServers->insertItem(tr("New")); | 53 | activeServers->insertItem(tr("New")); |
54 | } else { | 54 | } else { |
55 | // allows one-level undo | 55 | // allows one-level undo |
56 | serverurlDic.insert(i,new QString(serverurl->text())); | 56 | serverurlDic.insert(i,new QString(serverurl->text())); |
57 | servers->insertItem(servername->text()); | 57 | servers->insertItem(servername->text()); |
58 | activeServers->insertItem(servername->text()); | 58 | activeServers->insertItem(servername->text()); |
59 | } | 59 | } |
60 | servers->setSelected(i,TRUE); | 60 | servers->setSelected(i,TRUE); |
61 | editServer(i); | 61 | editServer(i); |
62 | } | 62 | } |
63 | 63 | ||
64 | void PackageManagerSettings::newDestination() | 64 | void PackageManagerSettings::newDestination() |
65 | { | 65 | { |
66 | int i = destinations->count(); | 66 | int i = destinations->count(); |
67 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { | 67 | if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) { |
68 | destinationurlDic.insert(i,new QString("/")); | 68 | destinationurlDic.insert(i,new QString("/")); |
69 | destinations->insertItem(tr("New")); | 69 | destinations->insertItem(tr("New")); |
70 | activeDestination->insertItem(tr("New")); | 70 | activeDestination->insertItem(tr("New")); |
71 | activeLinkDestination->insertItem(tr("New")); | 71 | activeLinkDestination->insertItem(tr("New")); |
72 | } else { | 72 | } else { |
73 | // allows one-level undo | 73 | // allows one-level undo |
74 | destinationurlDic.insert(i,new QString(destinationurl->text())); | 74 | destinationurlDic.insert(i,new QString(destinationurl->text())); |
75 | destinations->insertItem(destinationname->text()); | 75 | destinations->insertItem(destinationname->text()); |
76 | activeDestination->insertItem(destinationname->text()); | 76 | activeDestination->insertItem(destinationname->text()); |
77 | activeLinkDestination->insertItem(destinationname->text()); | 77 | activeLinkDestination->insertItem(destinationname->text()); |
78 | } | 78 | } |
79 | destinations->setSelected(i,TRUE); | 79 | destinations->setSelected(i,TRUE); |
80 | editDestination(i); | 80 | editDestination(i); |
81 | } | 81 | } |
82 | 82 | ||
83 | 83 | ||
84 | void PackageManagerSettings::editServer(int i) | 84 | void PackageManagerSettings::editServer(int i) |
85 | { | 85 | { |
86 | if ( servername->isEnabled() ) { | 86 | if ( servername->isEnabled() ) { |
87 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 87 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
88 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 88 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
89 | } else { | 89 | } else { |
90 | servername->setEnabled(TRUE); | 90 | servername->setEnabled(TRUE); |
91 | serverurl->setEnabled(TRUE); | 91 | serverurl->setEnabled(TRUE); |
92 | } | 92 | } |
93 | 93 | ||
94 | servername->setText( servers->text(i) ); | 94 | servername->setText( servers->text(i) ); |
95 | serverurl->setText( *serverurlDic[i] ); | 95 | serverurl->setText( *serverurlDic[i] ); |
96 | 96 | ||
97 | editedserver = i; | 97 | editedserver = i; |
98 | 98 | ||
99 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 99 | connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
100 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 100 | connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void PackageManagerSettings::editDestination(int i) | 104 | void PackageManagerSettings::editDestination(int i) |
105 | { | 105 | { |
106 | if ( destinationname->isEnabled() ) { | 106 | if ( destinationname->isEnabled() ) { |
107 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 107 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
108 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 108 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
109 | } else { | 109 | } else { |
110 | destinationname->setEnabled(TRUE); | 110 | destinationname->setEnabled(TRUE); |
111 | destinationurl->setEnabled(TRUE); | 111 | destinationurl->setEnabled(TRUE); |
112 | } | 112 | } |
113 | 113 | ||
114 | destinationname->setText( destinations->text(i) ); | 114 | destinationname->setText( destinations->text(i) ); |
115 | destinationurl->setText( *destinationurlDic[i] ); | 115 | destinationurl->setText( *destinationurlDic[i] ); |
116 | 116 | ||
117 | editeddestination = i; | 117 | editeddestination = i; |
118 | 118 | ||
119 | connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 119 | connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
120 | connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 120 | connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
121 | } | 121 | } |
122 | 122 | ||
123 | void PackageManagerSettings::removeServer() | 123 | void PackageManagerSettings::removeServer() |
124 | { | 124 | { |
125 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); | 125 | disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) ); |
126 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); | 126 | disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) ); |
127 | servername->setText(servers->text(editedserver)); | 127 | servername->setText(servers->text(editedserver)); |
128 | serverurl->setText(*serverurlDic[editedserver]); | 128 | serverurl->setText(*serverurlDic[editedserver]); |
129 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 129 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
130 | servers->removeItem(editedserver); | 130 | servers->removeItem(editedserver); |
131 | activeServers->removeItem(editedserver); | 131 | activeServers->removeItem(editedserver); |
132 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 132 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
133 | servername->setEnabled(FALSE); | 133 | servername->setEnabled(FALSE); |
134 | serverurl->setEnabled(FALSE); | 134 | serverurl->setEnabled(FALSE); |
135 | } | 135 | } |
136 | 136 | ||
137 | void PackageManagerSettings::removeDestination() | 137 | void PackageManagerSettings::removeDestination() |
138 | { | 138 | { |
139 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); | 139 | disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) ); |
140 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); | 140 | disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) ); |
141 | destinationname->setText(destinations->text(editedserver)); | 141 | destinationname->setText(destinations->text(editedserver)); |
142 | destinationurl->setText(*destinationurlDic[editedserver]); | 142 | destinationurl->setText(*destinationurlDic[editedserver]); |
143 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 143 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
144 | destinations->removeItem(editeddestination); | 144 | destinations->removeItem(editeddestination); |
145 | activeDestination->removeItem(editeddestination); | 145 | activeDestination->removeItem(editeddestination); |
146 | activeLinkDestination->removeItem(editeddestination); | 146 | activeLinkDestination->removeItem(editeddestination); |
147 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 147 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
148 | destinationname->setEnabled(FALSE); | 148 | destinationname->setEnabled(FALSE); |
149 | destinationurl->setEnabled(FALSE); | 149 | destinationurl->setEnabled(FALSE); |
150 | } | 150 | } |
151 | 151 | ||
152 | void PackageManagerSettings::serverNameChanged(const QString& t) | 152 | void PackageManagerSettings::serverNameChanged(const QString& t) |
153 | { | 153 | { |
154 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 154 | disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
155 | servers->changeItem( t, editedserver ); | 155 | servers->changeItem( t, editedserver ); |
156 | activeServers->changeItem( t, editedserver ); | 156 | activeServers->changeItem( t, editedserver ); |
157 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); | 157 | connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); |
158 | } | 158 | } |
159 | 159 | ||
160 | void PackageManagerSettings::destNameChanged(const QString& t) | 160 | void PackageManagerSettings::destNameChanged(const QString& t) |
161 | { | 161 | { |
162 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 162 | disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
163 | destinations->changeItem( t, editeddestination ); | 163 | destinations->changeItem( t, editeddestination ); |
164 | activeDestination->changeItem( t, editeddestination ); | 164 | activeDestination->changeItem( t, editeddestination ); |
165 | activeLinkDestination->changeItem( t, editeddestination ); | 165 | activeLinkDestination->changeItem( t, editeddestination ); |
166 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); | 166 | connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) ); |
167 | } | 167 | } |
168 | 168 | ||
169 | void PackageManagerSettings::serverUrlChanged(const QString& t) | 169 | void PackageManagerSettings::serverUrlChanged(const QString& t) |
170 | { | 170 | { |
171 | serverurlDic.replace(editedserver, new QString(t)); | 171 | serverurlDic.replace(editedserver, new QString(t)); |
172 | } | 172 | } |
173 | 173 | ||
174 | void PackageManagerSettings::destUrlChanged(const QString& t) | 174 | void PackageManagerSettings::destUrlChanged(const QString& t) |
175 | { | 175 | { |
176 | destinationurlDic.replace(editeddestination, new QString(t)); | 176 | destinationurlDic.replace(editeddestination, new QString(t)); |
177 | } | 177 | } |
178 | 178 | ||
179 | void PackageManagerSettings::writeIpkgConfig(const QString& conffile) | 179 | void PackageManagerSettings::writeIpkgConfig(const QString& conffile) |
180 | { | 180 | { |
181 | QFile conf(conffile); | 181 | QFile conf(conffile); |
182 | if ( ! conf.open(IO_WriteOnly) ) return; | 182 | if ( ! conf.open(IO_WriteOnly) ) return; |
183 | QTextStream s(&conf); | 183 | QTextStream s(&conf); |
184 | s << "# Written by qpie Package Manager\n"; | 184 | s << "# "+tr("Written by Opie Package Manager")+"\n"; |
185 | for (int i=0; i<(int)activeServers->count(); i++) | 185 | for (int i=0; i<(int)activeServers->count(); i++) |
186 | { | 186 | { |
187 | QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); | 187 | QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); |
188 | if ( !activeServers->isSelected(i) ) | 188 | if ( !activeServers->isSelected(i) ) |
189 | s << "#"; | 189 | s << "#"; |
190 | s << "src " << activeServers->text(i) << " " << url << "\n"; | 190 | s << "src " << activeServers->text(i) << " " << url << "\n"; |
191 | } | 191 | } |
192 | for (int i=0; i<(int)destinations->count(); i++) | 192 | for (int i=0; i<(int)destinations->count(); i++) |
193 | { | 193 | { |
194 | QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???"); | 194 | QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???"); |
195 | s << "dest " << destinations->text(i) << " " << url << "\n"; | 195 | s << "dest " << destinations->text(i) << " " << url << "\n"; |
196 | } | 196 | } |
197 | conf.close(); | 197 | conf.close(); |
198 | } | 198 | } |
199 | 199 | ||
200 | 200 | ||
201 | void PackageManagerSettings::readInstallationSettings() | 201 | void PackageManagerSettings::readInstallationSettings() |
202 | { | 202 | { |
203 | Config cfg( "oipkg", Config::User ); | 203 | Config cfg( "oipkg", Config::User ); |
204 | cfg.setGroup( "Settings" ); | 204 | cfg.setGroup( "Settings" ); |
205 | installationSettingsCount = cfg.readNumEntry( "count", -1 ); | 205 | installationSettingsCount = cfg.readNumEntry( "count", -1 ); |
206 | currentSetting = cfg.readNumEntry( "current", 0 ); | 206 | currentSetting = cfg.readNumEntry( "current", 0 ); |
207 | 207 | ||
208 | for (int i = 0; i < installationSettingsCount; i++) | 208 | for (int i = 0; i < installationSettingsCount; i++) |
209 | { | 209 | { |
210 | cfg.setGroup( "Setting_" + QString::number(i) ); | 210 | cfg.setGroup( "Setting_" + QString::number(i) ); |
211 | settingName->insertItem( cfg.readEntry( "name", "???" ), i ); | 211 | settingName->insertItem( cfg.readEntry( "name", "???" ), i ); |
212 | }; | 212 | }; |
213 | readInstallationSetting( currentSetting ); | 213 | readInstallationSetting( currentSetting ); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | void PackageManagerSettings::removeInstallationSetting() | 217 | void PackageManagerSettings::removeInstallationSetting() |
218 | { | 218 | { |
219 | settingName->removeItem( settingName->currentItem() ); | 219 | settingName->removeItem( settingName->currentItem() ); |
220 | Config cfg( "oipkg", Config::User ); | 220 | Config cfg( "oipkg", Config::User ); |
221 | cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); | 221 | cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); |
222 | cfg.clearGroup(); | 222 | cfg.clearGroup(); |
223 | installationSettingsCount--; | 223 | installationSettingsCount--; |
224 | settingName->setEditable( false ); | 224 | settingName->setEditable( false ); |
225 | } | 225 | } |
226 | 226 | ||
227 | void PackageManagerSettings::newInstallationSetting() | 227 | void PackageManagerSettings::newInstallationSetting() |
228 | { | 228 | { |
229 | installationSettingsCount++; | 229 | installationSettingsCount++; |
230 | settingName->insertItem( "New", installationSettingsCount ); | 230 | settingName->insertItem( "New", installationSettingsCount ); |
231 | settingName->setCurrentItem( installationSettingsCount ); | 231 | settingName->setCurrentItem( installationSettingsCount ); |
232 | settingName->setEditable( true ); | 232 | settingName->setEditable( true ); |
233 | } | 233 | } |
234 | 234 | ||
235 | void PackageManagerSettings::installationSettingChange(int cs) | 235 | void PackageManagerSettings::installationSettingChange(int cs) |
236 | { | 236 | { |
237 | writeCurrentInstallationSetting(); | 237 | writeCurrentInstallationSetting(); |
238 | currentSetting = cs; | 238 | currentSetting = cs; |
239 | readInstallationSetting( cs ); | 239 | readInstallationSetting( cs ); |
240 | } | 240 | } |
241 | 241 | ||
242 | void PackageManagerSettings::writeInstallationSettings() | 242 | void PackageManagerSettings::writeInstallationSettings() |
243 | { | 243 | { |
244 | { | 244 | { |
245 | Config cfg( "oipkg", Config::User ); | 245 | Config cfg( "oipkg", Config::User ); |
246 | cfg.setGroup( "Settings" ); | 246 | cfg.setGroup( "Settings" ); |
247 | cfg.writeEntry( "count", installationSettingsCount ); | 247 | cfg.writeEntry( "count", installationSettingsCount ); |
248 | cfg.writeEntry( "current", currentSetting ); | 248 | cfg.writeEntry( "current", currentSetting ); |
249 | writeCurrentInstallationSetting(); | 249 | writeCurrentInstallationSetting(); |
250 | } | 250 | } |
251 | } | 251 | } |
252 | 252 | ||
253 | 253 | ||
254 | void PackageManagerSettings::readInstallationSetting(int setting) | 254 | void PackageManagerSettings::readInstallationSetting(int setting) |
255 | { | 255 | { |
256 | if ( setting < 0 ) return; | 256 | if ( setting < 0 ) return; |
257 | Config cfg( "oipkg", Config::User ); | 257 | Config cfg( "oipkg", Config::User ); |
258 | cfg.setGroup( "Setting_" + QString::number( setting ) ); | 258 | cfg.setGroup( "Setting_" + QString::number( setting ) ); |
259 | CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) ); | 259 | CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) ); |
260 | QString dest = cfg.readEntry( "dest" ); | 260 | QString dest = cfg.readEntry( "dest" ); |
261 | QString linkdest = cfg.readEntry( "linkdest" ); | 261 | QString linkdest = cfg.readEntry( "linkdest" ); |
262 | 262 | ||
263 | for ( int i = 0; i < activeDestination->count(); i++) | 263 | for ( int i = 0; i < activeDestination->count(); i++) |
264 | { | 264 | { |
265 | QString name = cfg.readEntry( "name" ); | 265 | QString name = cfg.readEntry( "name" ); |
266 | if ( activeDestination->text( i ) == name ) | 266 | if ( activeDestination->text( i ) == name ) |
267 | activeDestination->setCurrentItem( i ); | 267 | activeDestination->setCurrentItem( i ); |
268 | if ( activeLinkDestination->text( i ) == name ) | 268 | if ( activeLinkDestination->text( i ) == name ) |
269 | activeLinkDestination->setCurrentItem( i ); | 269 | activeLinkDestination->setCurrentItem( i ); |
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | void PackageManagerSettings::writeCurrentInstallationSetting() | 273 | void PackageManagerSettings::writeCurrentInstallationSetting() |
274 | { | 274 | { |
275 | Config cfg( "oipkg", Config::User ); | 275 | Config cfg( "oipkg", Config::User ); |
276 | cfg.setGroup( "Setting_" + QString::number(currentSetting) ); | 276 | cfg.setGroup( "Setting_" + QString::number(currentSetting) ); |
277 | cfg.writeEntry( "link", CheckBoxLink->isChecked() ); | 277 | cfg.writeEntry( "link", CheckBoxLink->isChecked() ); |
278 | cfg.writeEntry( "dest", getDestinationName() ); | 278 | cfg.writeEntry( "dest", getDestinationName() ); |
279 | cfg.writeEntry( "linkdest" , getLinkDestinationName() ); | 279 | cfg.writeEntry( "linkdest" , getLinkDestinationName() ); |
280 | QStringList sers = getActiveServers(); | 280 | QStringList sers = getActiveServers(); |
281 | int srvc = 0; | 281 | int srvc = 0; |
282 | for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { | 282 | for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) { |
283 | cfg.writeEntry( "server_" + QString::number(srvc++), *it ); | 283 | cfg.writeEntry( "server_" + QString::number(srvc++), *it ); |
284 | } | 284 | } |
285 | cfg.writeEntry( "server_count", srvc ); | 285 | cfg.writeEntry( "server_count", srvc ); |
286 | } | 286 | } |
287 | 287 | ||
288 | void PackageManagerSettings::renameInstallationSetting() | 288 | void PackageManagerSettings::renameInstallationSetting() |
289 | { | 289 | { |
290 | settingName->setEditable( true ); | 290 | settingName->setEditable( true ); |
291 | } | 291 | } |
292 | 292 | ||
293 | void PackageManagerSettings::installationSettingSetName(const QString &name) | 293 | void PackageManagerSettings::installationSettingSetName(const QString &name) |
294 | { | 294 | { |
295 | settingName->changeItem( name, settingName->currentItem() ); | 295 | settingName->changeItem( name, settingName->currentItem() ); |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | bool PackageManagerSettings::readIpkgConfig(const QString& conffile) | 299 | bool PackageManagerSettings::readIpkgConfig(const QString& conffile) |
300 | { | 300 | { |
301 | QFile conf(conffile); | 301 | QFile conf(conffile); |
302 | if ( conf.open(IO_ReadOnly) ) { | 302 | if ( conf.open(IO_ReadOnly) ) { |
303 | QTextStream s(&conf); | 303 | QTextStream s(&conf); |
304 | servers->clear(); | 304 | servers->clear(); |
305 | activeServers->clear(); | 305 | activeServers->clear(); |
306 | activeDestination->clear(); | 306 | activeDestination->clear(); |
307 | activeLinkDestination->clear(); | 307 | activeLinkDestination->clear(); |
308 | serverurlDic.clear(); | 308 | serverurlDic.clear(); |
309 | destinationurlDic.clear(); | 309 | destinationurlDic.clear(); |
310 | ipkg_old=0; | 310 | ipkg_old=0; |
311 | int currentserver=0; | 311 | int currentserver=0; |
312 | while ( !s.atEnd() ) { | 312 | while ( !s.atEnd() ) { |
313 | QString l = s.readLine(); | 313 | QString l = s.readLine(); |
314 | QStringList token = QStringList::split(' ', l); | 314 | QStringList token = QStringList::split(' ', l); |
315 | if ( token[0] == "src" || token[0] == "#src" ) { | 315 | if ( token[0] == "src" || token[0] == "#src" ) { |
316 | currentserver=servers->count(); | 316 | currentserver=servers->count(); |
317 | serverurlDic.insert(servers->count(),new QString(token[2])); | 317 | serverurlDic.insert(servers->count(),new QString(token[2])); |
318 | int a = token[0] == "src" ? 1 : 0; | 318 | int a = token[0] == "src" ? 1 : 0; |
319 | int i = servers->count(); | 319 | int i = servers->count(); |
320 | servers->insertItem(token[1]); | 320 | servers->insertItem(token[1]); |
321 | activeServers->insertItem( token[1] ); | 321 | activeServers->insertItem( token[1] ); |
322 | activeServers->setSelected(i,a); | 322 | activeServers->setSelected(i,a); |
323 | } else if ( token[0] == "dest" ) { | 323 | } else if ( token[0] == "dest" ) { |
324 | currentserver=destinations->count(); | 324 | currentserver=destinations->count(); |
325 | destinationurlDic.insert(destinations->count(),new QString(token[2])); | 325 | destinationurlDic.insert(destinations->count(),new QString(token[2])); |
326 | destinations->insertItem(token[1]); | 326 | destinations->insertItem(token[1]); |
327 | activeDestination->insertItem( token[1] ); | 327 | activeDestination->insertItem( token[1] ); |
328 | activeLinkDestination->insertItem( token[1] ); | 328 | activeLinkDestination->insertItem( token[1] ); |
329 | 329 | ||
330 | } else if ( token[0] == "option" ) { | 330 | } else if ( token[0] == "option" ) { |
331 | } else { | 331 | } else { |
332 | // Old style? | 332 | // Old style? |
333 | int eq = l.find('='); | 333 | int eq = l.find('='); |
334 | if ( eq >= 0 ) { | 334 | if ( eq >= 0 ) { |
335 | QString v = l.mid(eq+1).stripWhiteSpace(); | 335 | QString v = l.mid(eq+1).stripWhiteSpace(); |
336 | if ( v[0] == '"' || v[0] == '\'' ) { | 336 | if ( v[0] == '"' || v[0] == '\'' ) { |
337 | int cl=v.find(v[0],1); | 337 | int cl=v.find(v[0],1); |
338 | if ( cl >= 0 ) | 338 | if ( cl >= 0 ) |
339 | v = v.mid(1,cl-1); | 339 | v = v.mid(1,cl-1); |
340 | } | 340 | } |
341 | if ( l.left(12) == "IPKG_SOURCE=" ) { | 341 | if ( l.left(12) == "IPKG_SOURCE=" ) { |
342 | ipkg_old=1; | 342 | ipkg_old=1; |
343 | currentserver=servers->count(); | 343 | currentserver=servers->count(); |
344 | serverurlDic.insert(servers->count(),new QString(v)); | 344 | serverurlDic.insert(servers->count(),new QString(v)); |
345 | servers->insertItem(v); | 345 | servers->insertItem(v); |
346 | } else if ( l.left(13) == "#IPKG_SOURCE=" ) { | 346 | } else if ( l.left(13) == "#IPKG_SOURCE=" ) { |
347 | serverurlDic.insert(servers->count(),new QString(v)); | 347 | serverurlDic.insert(servers->count(),new QString(v)); |
348 | servers->insertItem(v); | 348 | servers->insertItem(v); |
349 | } else if ( l.left(10) == "IPKG_ROOT=" ) { | 349 | } else if ( l.left(10) == "IPKG_ROOT=" ) { |
350 | 350 | ||
351 | } | 351 | } |
352 | } | 352 | } |
353 | } | 353 | } |
354 | } | 354 | } |
355 | if ( ipkg_old ) { | 355 | if ( ipkg_old ) { |
356 | servers->setSelectionMode(QListBox::Single); | 356 | servers->setSelectionMode(QListBox::Single); |
357 | servers->setSelected(currentserver,TRUE); | 357 | servers->setSelected(currentserver,TRUE); |
358 | } | 358 | } |
359 | return TRUE; | 359 | return TRUE; |
360 | } else { | 360 | } else { |
361 | return FALSE; | 361 | return FALSE; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | void PackageManagerSettings::readSettings() | 365 | void PackageManagerSettings::readSettings() |
366 | { | 366 | { |
367 | readIpkgConfig("/etc/ipkg.conf"); | 367 | readIpkgConfig("/etc/ipkg.conf"); |
368 | readInstallationSettings(); | 368 | readInstallationSettings(); |
369 | } | 369 | } |
370 | 370 | ||
371 | void PackageManagerSettings::writeSettings() | 371 | void PackageManagerSettings::writeSettings() |
372 | { | 372 | { |
373 | writeIpkgConfig("/etc/ipkg.conf"); | 373 | writeIpkgConfig("/etc/ipkg.conf"); |
374 | writeInstallationSettings(); | 374 | writeInstallationSettings(); |
375 | } | 375 | } |
376 | 376 | ||
377 | bool PackageManagerSettings::showDialog( int i ) | 377 | bool PackageManagerSettings::showDialog( int i ) |
378 | { | 378 | { |
379 | TabWidget->setCurrentPage( i ); | 379 | TabWidget->setCurrentPage( i ); |
380 | showMaximized(); | 380 | showMaximized(); |
381 | bool ret = exec(); | 381 | bool ret = exec(); |
382 | if ( ret ) writeSettings(); | 382 | if ( ret ) writeSettings(); |
383 | else readSettings(); | 383 | else readSettings(); |
384 | return ret; | 384 | return ret; |
385 | } | 385 | } |
386 | 386 | ||
387 | QString PackageManagerSettings::getDestinationName() | 387 | QString PackageManagerSettings::getDestinationName() |
388 | { | 388 | { |
389 | return activeDestination->currentText(); | 389 | return activeDestination->currentText(); |
390 | } | 390 | } |
391 | 391 | ||
392 | QString PackageManagerSettings::getLinkDestinationName() | 392 | QString PackageManagerSettings::getLinkDestinationName() |
393 | { | 393 | { |
394 | return activeLinkDestination->currentText(); | 394 | return activeLinkDestination->currentText(); |
395 | } | 395 | } |
396 | 396 | ||
397 | /** Returns the URL of the active destination */ | 397 | /** Returns the URL of the active destination */ |
398 | QString PackageManagerSettings::getDestinationUrl() | 398 | QString PackageManagerSettings::getDestinationUrl() |
399 | { | 399 | { |
400 | int dnr = activeDestination->currentItem(); | 400 | int dnr = activeDestination->currentItem(); |
401 | return *destinationurlDic.find(dnr); | 401 | return *destinationurlDic.find(dnr); |
402 | } | 402 | } |
403 | 403 | ||
404 | /** Should oipkg create links form install destination to link destination */ | 404 | /** Should oipkg create links form install destination to link destination */ |
405 | bool PackageManagerSettings::createLinks() | 405 | bool PackageManagerSettings::createLinks() |
406 | { | 406 | { |
407 | return CheckBoxLink->isChecked(); | 407 | return CheckBoxLink->isChecked(); |
408 | } | 408 | } |
409 | 409 | ||
410 | /** get the servers that are active */ | 410 | /** get the servers that are active */ |
411 | QStringList PackageManagerSettings::getActiveServers() | 411 | QStringList PackageManagerSettings::getActiveServers() |
412 | { | 412 | { |
413 | QStringList sl; | 413 | QStringList sl; |
414 | for (int i=0; i<(int)activeServers->count(); i++) | 414 | for (int i=0; i<(int)activeServers->count(); i++) |
415 | { | 415 | { |
416 | if ( activeServers->isSelected(i) ) | 416 | if ( activeServers->isSelected(i) ) |
417 | sl += activeServers->text(i); | 417 | sl += activeServers->text(i); |
418 | } | 418 | } |
419 | return sl; | 419 | return sl; |
420 | } | 420 | } |
421 | 421 | ||
422 | /** returns the destination listed in ipkg.conf */ | 422 | /** returns the destination listed in ipkg.conf */ |
423 | QStringList PackageManagerSettings::getDestinationUrls() | 423 | QStringList PackageManagerSettings::getDestinationUrls() |
424 | { | 424 | { |
425 | QStringList sl; | 425 | QStringList sl; |
426 | for (int i=0; i<(int)destinations->count(); i++) | 426 | for (int i=0; i<(int)destinations->count(); i++) |
427 | { | 427 | { |
428 | sl += *destinationurlDic[i]; | 428 | sl += *destinationurlDic[i]; |
429 | } | 429 | } |
430 | return sl; | 430 | return sl; |
431 | } | 431 | } |
432 | 432 | ||
433 | void PackageManagerSettings::linkEnabled( bool b ) | 433 | void PackageManagerSettings::linkEnabled( bool b ) |
434 | { | 434 | { |
435 | activeLinkDestination->setEnabled( b ); | 435 | activeLinkDestination->setEnabled( b ); |
436 | } | 436 | } |
437 | 437 | ||
438 | void PackageManagerSettings::activeDestinationChange(int i) | 438 | void PackageManagerSettings::activeDestinationChange(int i) |
439 | { | 439 | { |
440 | activeLinkDestination->setCurrentItem( i ); | 440 | activeLinkDestination->setCurrentItem( i ); |
441 | } \ No newline at end of file | 441 | } \ No newline at end of file |