summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-gutenbrowser/gutenbrowser.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/opie-gutenbrowser/gutenbrowser.cpp38
1 files changed, 19 insertions, 19 deletions
diff --git a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
index c7cdd83..413ab51 100644
--- a/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
+++ b/noncore/apps/opie-gutenbrowser/gutenbrowser.cpp
@@ -120,55 +120,55 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
120 Config config("Gutenbrowser"); // populate menubuttonlist 120 Config config("Gutenbrowser"); // populate menubuttonlist
121 config.setGroup("General"); 121 config.setGroup("General");
122 122
123 config.setGroup( "Files" ); 123 config.setGroup( "Files" );
124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" ); 124 QString s_numofFiles = config.readEntry("NumberOfFiles", "0" );
125 int i_numofFiles = s_numofFiles.toInt(); 125 int i_numofFiles = s_numofFiles.toInt();
126 126
127 QString tempFileName; 127 QString tempFileName;
128 128
129 for (int i = 0; i <= i_numofFiles; i++) { 129 for (int i = 0; i <= i_numofFiles; i++) {
130 // tempFileName.setNum(i); 130 // tempFileName.setNum(i);
131 config.setGroup( "Files" ); 131 config.setGroup( "Files" );
132 QString ramble = config.readEntry( QString::number(i), "" ); 132 QString ramble = config.readEntry( QString::number(i), "" );
133 133
134 config.setGroup( "Titles" ); 134 config.setGroup( "Titles" );
135 QString tempTitle = config.readEntry( ramble, ""); 135 QString tempTitle = config.readEntry( ramble, "");
136 config.setGroup( tempTitle); 136 config.setGroup( tempTitle);
137 int index = config.readNumEntry( "LineNumber", -1 ); 137 int index = config.readNumEntry( "LineNumber", -1 );
138 if( index != -1) { 138 if( index != -1) {
139 odebug << tempTitle << oendl; 139 odebug << tempTitle << oendl;
140 if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle); 140 if(!tempTitle.isEmpty()) bookmarksMenu->insertItem( tempTitle);
141 } 141 }
142 } 142 }
143 143
144 // QString gutenIndex= local_library + "GUTINDEX.ALL"; 144 QString gutenIndex = local_library + "/GUTINDEX.ALL";
145 QString gutenIndex = QPEApplication::qpeDir()+ "etc/gutenbrowser/GUTINDEX.ALL";
146 qDebug("gutenindex "+gutenIndex ); 145 qDebug("gutenindex "+gutenIndex );
146
147 if( QFile( gutenIndex).exists() ) { 147 if( QFile( gutenIndex).exists() ) {
148 indexLib.setName( gutenIndex); 148 indexLib.setName( gutenIndex);
149 } else { 149 } else {
150 QString localLibIndexFile = QPEApplication::qpeDir()+ "etc/gutenbrowser/PGWHOLE.TXT"; 150 QString localLibIndexFile = local_library + "/PGWHOLE.TXT";
151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT"; 151 // QString localLibIndexFile= local_library + "PGWHOLE.TXT";
152 newindexLib.setName( localLibIndexFile); 152 newindexLib.setName( localLibIndexFile);
153 } 153 }
154 qDebug("attempting new library"); 154 qDebug("attempting new library");
155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */); 155 LibraryDlg = new LibraryDialog( this, "Library Index" /*, TRUE */);
156 loadCheck = false; 156 loadCheck = false;
157 chdir(local_library); 157 chdir(local_library);
158 if(!showMainList) { 158 if(!showMainList) {
159 Lview->setFocus(); 159 Lview->setFocus();
160 // if(firstTime) 160 // if(firstTime)
161 // Bookmark(); 161 // Bookmark();
162 for (int i=1;i< qApp->argc();i++) { 162 for (int i=1;i< qApp->argc();i++) {
163 qDebug("Suppose we open somethin"); 163 qDebug("Suppose we open somethin");
164 if(!load(qApp->argv()[i])) return; 164 if(!load(qApp->argv()[i])) return;
165 } 165 }
166 } else { 166 } else {
167 fillWithTitles(); 167 fillWithTitles();
168 mainList->setFocus(); 168 mainList->setFocus();
169 // mainList->setCurrentItem(0); 169 // mainList->setCurrentItem(0);
170 170
171 } 171 }
172 writeConfig(); 172 writeConfig();
173 QTimer::singleShot( 250, this, SLOT(hideView()) ); 173 QTimer::singleShot( 250, this, SLOT(hideView()) );
174} //end init 174} //end init
@@ -176,70 +176,70 @@ Gutenbrowser::Gutenbrowser(QWidget *,const char*, WFlags )
176Gutenbrowser::~Gutenbrowser() { 176Gutenbrowser::~Gutenbrowser() {
177 // QPEApplication::grabKeyboard(); 177 // QPEApplication::grabKeyboard();
178 // QPEApplication::ungrabKeyboard(); 178 // QPEApplication::ungrabKeyboard();
179 odebug << "Exit" << oendl; 179 odebug << "Exit" << oendl;
180} 180}
181 181
182 /* 182 /*
183 Google.com search */ 183 Google.com search */
184void Gutenbrowser::InfoBarClick() { 184void Gutenbrowser::InfoBarClick() {
185 QString text; 185 QString text;
186 if( Lview->hasSelectedText()) { 186 if( Lview->hasSelectedText()) {
187 Lview->copy(); 187 Lview->copy();
188 QClipboard *cb = QApplication::clipboard(); 188 QClipboard *cb = QApplication::clipboard();
189 text = cb->text(); 189 text = cb->text();
190 } else { 190 } else {
191 // text=title; 191 // text=title;
192 text=this->caption(); 192 text=this->caption();
193 } 193 }
194 searchGoogle(text); 194 searchGoogle(text);
195} 195}
196 196
197 /* 197 /*
198 download http with wget or preferred browser */ 198 download http with wget or preferred browser */
199void Gutenbrowser::goGetit( const QString &url, bool showMsg) { 199void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
200 // int eexit=0;
201 QString cmd; 200 QString cmd;
202 // config.read();
203 qApp->processEvents(); 201 qApp->processEvents();
204 QString filename = QPEApplication::qpeDir();
205 if(filename.right(1)!="/")
206 filename+="/etc/gutenbrowser/";
207 else
208 filename+="etc/gutenbrowser/";
209 odebug << "filename "+filename << oendl;
210 // QString filename = QDir::homeDirPath()+"/Applications/gutenbrowser/";
211 202
212 filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1); 203 QString filename = local_library + "/GUTINDEX.ALL";
204// QString filename = old_index;
213 205
214 Config config("Gutenbrowser"); 206 // filename += url.right( url.length() - url.findRev("/",-1,TRUE) -1);
215 config.setGroup( "Browser" ); 207
216 QString brow = config.readEntry("Preferred", "Opera"); 208 Config cfg("Gutenbrowser");
217 odebug << "Preferred browser is "+brow << oendl; 209 cfg.setGroup("FTPsite");
210 ftp_host=cfg.readEntry("SiteName", "sailor.gutenberg.org");
211 ftp_base_dir= cfg.readEntry("base", "/pub/gutenberg");
212
213 // Config config("Gutenbrowser");
214 // config.setGroup( "Browser" );
215 // QString brow = config.readEntry("Preferred", "Opera");
216 // //odebug << "Preferred browser is "+brow << oendl;
218 if(!showMsg) { //if we just get the gutenindex.all 217 if(!showMsg) { //if we just get the gutenindex.all
218// QString cmd="wget -O " + gutenindex1 + " http://sailor.gutenberg.org/GUTINDEX.ALL 2>&1";
219 cmd="wget -O " + filename +" " + url+" 2>&1" ; 219 cmd="wget -O " + filename +" " + url+" 2>&1" ;
220 chdir(local_library); 220 chdir(local_library);
221 odebug << "Issuing the system command: " << cmd << "" << oendl; 221 // //odebug << "Issuing the system command: " << cmd << "" << oendl;
222 222
223 Output *outDlg; 223 Output *outDlg;
224 224
225 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE); 225 outDlg = new Output( 0, tr("Downloading Gutenberg Index...."),TRUE);
226 226
227 outDlg->showMaximized(); 227 outDlg->showMaximized();
228 outDlg->show(); 228 outDlg->show();
229 qApp->processEvents(); 229 qApp->processEvents();
230 FILE *fp; 230 FILE *fp;
231 char line[130]; 231 char line[130];
232 outDlg->OutputEdit->append( tr("Running wget") ); 232 outDlg->OutputEdit->append( tr("Running wget") );
233 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 233 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
234 sleep(1); 234 sleep(1);
235 fp = popen( (const char *) cmd, "r"); 235 fp = popen( (const char *) cmd, "r");
236 if ( !fp ) { 236 if ( !fp ) {
237 } else { 237 } else {
238 //odebug << "Issuing the command\n"+cmd << oendl; 238 //odebug << "Issuing the command\n"+cmd << oendl;
239 // system(cmd); 239 // system(cmd);
240 while ( fgets( line, sizeof line, fp)) { 240 while ( fgets( line, sizeof line, fp)) {
241 outDlg->OutputEdit->append(line); 241 outDlg->OutputEdit->append(line);
242 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); 242 outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
243 } 243 }
244 pclose(fp); 244 pclose(fp);
245 outDlg->OutputEdit->append("Finished downloading\n"); 245 outDlg->OutputEdit->append("Finished downloading\n");
@@ -253,49 +253,49 @@ void Gutenbrowser::goGetit( const QString &url, bool showMsg) {
253 delete outDlg; 253 delete outDlg;
254 } else { 254 } else {
255 if( brow == "Konq") { 255 if( brow == "Konq") {
256 cmd = "konqueror "+url+" &"; 256 cmd = "konqueror "+url+" &";
257 } 257 }
258 if( brow == "Opera") { //for desktop testing 258 if( brow == "Opera") { //for desktop testing
259 cmd = "opera "+url+" &"; 259 cmd = "opera "+url+" &";
260 } 260 }
261 // if( brow == "Opera") { // on Zaurus 261 // if( brow == "Opera") { // on Zaurus
262 // cmd = "operagui "+url+" &"; 262 // cmd = "operagui "+url+" &";
263 // } 263 // }
264 if( brow == "Mozilla") { 264 if( brow == "Mozilla") {
265 cmd = "mozilla "+url+" &"; 265 cmd = "mozilla "+url+" &";
266 } 266 }
267 if( brow == "Netscape") { 267 if( brow == "Netscape") {
268 cmd = "netscape "+url+" &"; 268 cmd = "netscape "+url+" &";
269 } 269 }
270 if(brow == "wget") { 270 if(brow == "wget") {
271 // cmd="wget -q "+url+" &"; 271 // cmd="wget -q "+url+" &";
272 QString tempHtml=local_library+"webster.html"; 272 QString tempHtml=local_library+"webster.html";
273 cmd="wget -O "+tempHtml+" -q "+url; 273 cmd="wget -O "+tempHtml+" -q "+url;
274 } 274 }
275 275
276 chdir(local_library); 276 chdir(local_library);
277 odebug << "Issuing the sys command: " << cmd << "" << oendl; 277 // //odebug << "Issuing the sys command: " << cmd << "" << oendl;
278 system(cmd); 278 system(cmd);
279 } 279 }
280} 280}
281 281
282void Gutenbrowser::toggleButtonIcons( bool useEm) { 282void Gutenbrowser::toggleButtonIcons( bool useEm) {
283 QString pixDir; 283 QString pixDir;
284 if(useEm) 284 if(useEm)
285 useEm=TRUE; 285 useEm=TRUE;
286 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser"; 286 pixDir=QPEApplication::qpeDir()+"pics/gutenbrowser";
287 odebug << "Docdir is "+QPEApplication::documentDir() << oendl; 287 odebug << "Docdir is "+QPEApplication::documentDir() << oendl;
288 288
289 if( useIcons && QDir( pixDir).exists() ) { 289 if( useIcons && QDir( pixDir).exists() ) {
290 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline 290 LibraryButton->setPixmap( Resource::loadPixmap("home") ); //in inline
291 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook")); 291 OpenButton->setPixmap( Resource::loadPixmap("gutenbrowser/openbook"));
292 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline 292 ForwardButton->setPixmap( Resource::loadPixmap("forward"));//in inline
293 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline 293 BackButton->setPixmap( Resource::loadPixmap("back") );//in inline
294 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline 294 SearchButton->setPixmap( Resource::loadPixmap("gutenbrowser/search") );//in inline
295 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder")); 295 lastBmkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark_folder"));
296 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") ); 296 setBookmarkButton->setPixmap( Resource::loadPixmap("gutenbrowser/bookmark") );
297 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") ); 297 dictionaryButton->setPixmap( Resource::loadPixmap("gutenbrowser/spellcheck") );
298 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google")); 298 InfoBar->setPixmap( Resource::loadPixmap("gutenbrowser/google"));
299 } 299 }
300} 300}
301 301