29 files changed, 51 insertions, 48 deletions
diff --git a/core/applets/cardmon/cardmon.cpp b/core/applets/cardmon/cardmon.cpp index 3dd9f54..93bc97a 100644 --- a/core/applets/cardmon/cardmon.cpp +++ b/core/applets/cardmon/cardmon.cpp @@ -1,281 +1,281 @@ /* * cardmon.cpp * * --------------------- * * copyright : (c) 2002 by Maximilian Reiss * email : max.reiss@gmx.de * based on two apps by Devin Butterfield */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cardmon.h" #include <qpe/resource.h> #include <qcopchannel_qws.h> #include <qpainter.h> #include <qmessagebox.h> #include <qfile.h> #include <qtextstream.h> #include <qtimer.h> #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <sys/vfs.h> #include <mntent.h> #endif CardMonitor::CardMonitor( QWidget *parent ) : QWidget( parent ), pm( Resource::loadPixmap( "cardmon/pcmcia" ) ) { QCopChannel* pcmciaChannel = new QCopChannel( "QPE/Card", this ); connect( pcmciaChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); QCopChannel* sdChannel = new QCopChannel( "QPE/Card", this ); connect( sdChannel, SIGNAL(received(const QCString &, const QByteArray &)), this, SLOT(cardMessage( const QCString &, const QByteArray &)) ); setFixedSize( pm.size() ); getStatusPcmcia(TRUE); getStatusSd(TRUE); repaint(FALSE); popUpMenu = 0; popUpMenuTimer = 0; } CardMonitor::~CardMonitor() { } void CardMonitor::popUp(QString message) { if ( ! popUpMenu ) { popUpMenu = new QPopupMenu(); } popUpMenu->clear(); popUpMenu->insertItem( message, 0 ); QPoint p = mapToGlobal ( QPoint ( 0, 0 )); QSize s = popUpMenu->sizeHint ( ); popUpMenu->popup( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ) ), 0); if ( ! popUpMenuTimer ) { popUpMenuTimer = new QTimer( this ); connect( popUpMenuTimer, SIGNAL(timeout()), this, SLOT(popUpTimeout()) ); } timerEvent(0); popUpMenuTimer->start( 2000 ); } void CardMonitor::popUpTimeout() { popUpMenu->hide(); popUpMenuTimer->stop(); } void CardMonitor::mousePressEvent( QMouseEvent * ) { QPopupMenu *menu = new QPopupMenu(); QString cmd; int err=0; if ( cardInSd ) { menu->insertItem( tr("Eject SD/MMC card"), 0 ); } if ( cardInPcmcia0 ) { menu->insertItem( tr("Eject card 0: %1").arg(cardInPcmcia0Name), 1 ); } if ( cardInPcmcia1 ) { menu->insertItem( tr("Eject card 1: %1").arg(cardInPcmcia1Name), 2 ); } QPoint p = mapToGlobal ( QPoint ( 0, 0 )); QSize s = menu->sizeHint ( ); int opt = menu->exec( QPoint ( p. x ( ) + ( width ( ) / 2 ) - ( s. width ( ) / 2 ), p. y ( ) - s. height ( ) ), 0); if ( opt == 1 ) { cmd = "/sbin/cardctl eject 0"; err = system( (const char *) cmd ); if ( ( err == 127 ) || ( err < 0 ) ) { qDebug("Could not execute `/sbin/cardctl eject 0'! err=%d", err); popUp( tr("CF/PCMCIA card eject failed!")); } } else if ( opt == 0 ) { cmd = "/etc/sdcontrol compeject"; err = system( (const char *) cmd ); if ( ( err != 0 ) ) { qDebug("Could not execute `/etc/sdcontrol comeject'! err=%d", err); popUp( tr("SD/MMC card eject failed!")); } } else if ( opt == 2 ) { cmd = "/sbin/cardctl eject 1"; err = system( (const char *) cmd ); if ( ( err == 127 ) || ( err < 0 ) ) { qDebug("Could not execute `/sbin/cardctl eject 1'! err=%d", err); popUp( tr("CF/PCMCIA card eject failed!")); } } delete menu; } void CardMonitor::cardMessage( const QCString &msg, const QByteArray & ) { if ( msg == "stabChanged()" ) { // qDebug("Pcmcia: stabchanged"); if ( getStatusPcmcia() ) { repaint(FALSE); } } else if ( msg == "mtabChanged()" ) { // qDebug("Pcmcia: mtabchanged"); if ( getStatusSd() ) { repaint(FALSE); } } } -bool CardMonitor::getStatusPcmcia( int showPopUp = FALSE ) { +bool CardMonitor::getStatusPcmcia( int showPopUp ) { bool cardWas0 = cardInPcmcia0; // remember last state bool cardWas1 = cardInPcmcia1; QString fileName; // one of these 3 files should exist if (QFile::exists("/var/run/stab")) { fileName = "/var/run/stab"; } else if (QFile::exists("/var/state/pcmcia/stab")) { fileName="/var/state/pcmcia/stab"; } else { fileName="/var/lib/pcmcia/stab"; } QFile f(fileName); if ( f.open(IO_ReadOnly) ) { QStringList list; QTextStream stream ( &f); QString streamIn; streamIn = stream.read(); list = QStringList::split("\n", streamIn); for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { if( (*line).startsWith("Socket 0:") ){ if( (*line).startsWith("Socket 0: empty") && cardInPcmcia0 ){ cardInPcmcia0 = FALSE; } else if ( !(*line).startsWith("Socket 0: empty") && !cardInPcmcia0 ){ cardInPcmcia0Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); cardInPcmcia0Name.stripWhiteSpace(); cardInPcmcia0 = TRUE; show(); } } if( (*line).startsWith("Socket 1:") ){ if( (*line).startsWith("Socket 1: empty") && cardInPcmcia1 ){ cardInPcmcia1 = FALSE; } else if ( !(*line).startsWith("Socket 1: empty") && !cardInPcmcia1 ){ cardInPcmcia1Name = (*line).mid(((*line).find(':')+1), (*line).length()-9 ); cardInPcmcia1Name.stripWhiteSpace(); cardInPcmcia1 = TRUE; show(); } } } } else { // no file found qDebug("no file found"); cardInPcmcia0 = FALSE; cardInPcmcia1 = FALSE; return FALSE; } if(!cardInPcmcia0 && !cardInPcmcia1) { qDebug("Pcmcia: no cards"); } if( !showPopUp && (cardWas0 != cardInPcmcia0 || cardWas1 != cardInPcmcia1)) { QString text = ""; if(cardWas0 != cardInPcmcia0) { if(cardInPcmcia0) { text += tr("New card: "); } else { text += tr("Ejected: "); } text += cardInPcmcia0Name; } if(cardWas0 != cardInPcmcia0 && cardWas1 != cardInPcmcia1) { text += "\n"; } if(cardWas1 != cardInPcmcia1) { if(cardInPcmcia1) { text += tr("New card: "); } else { text += tr("Ejected: "); } text += cardInPcmcia1Name; } popUp( text ); } f.close(); return ((cardWas0 == cardInPcmcia0 || cardWas1 == cardInPcmcia1) ? FALSE : TRUE); } -bool CardMonitor::getStatusSd( int showPopUp = FALSE ) { +bool CardMonitor::getStatusSd( int showPopUp ) { bool cardWas=cardInSd; // remember last state cardInSd=false; #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) struct mntent *me; FILE *mntfp = setmntent( "/etc/mtab", "r" ); if ( mntfp ) { while ( (me = getmntent( mntfp )) != 0 ) { QString fs = me->mnt_fsname; if ( fs.left(7)=="/dev/sd" || fs.left(9) == "/dev/mmcd" ) { cardInSd=true; } } endmntent( mntfp ); } if(!showPopUp && cardWas != cardInSd) { QString text = ""; if(cardInSd) { text += "SD Inserted"; } else { text += "SD Removed"; } popUp( text ); } #else #error "Not on Linux" #endif return ((cardWas == cardInSd) ? FALSE : TRUE); } void CardMonitor::paintEvent( QPaintEvent * ) { QPainter p( this ); if ( cardInPcmcia0 || cardInPcmcia1 || cardInSd ) { p.drawPixmap( 0, 0, pm ); show(); } else { p.eraseRect( rect() ); hide(); } } diff --git a/core/applets/vmemo/vmemo.cpp b/core/applets/vmemo/vmemo.cpp index b29ee62..4278f46 100644 --- a/core/applets/vmemo/vmemo.cpp +++ b/core/applets/vmemo/vmemo.cpp @@ -437,193 +437,194 @@ int VMemo::openWAV(const char *filename) wh.byte_p_sec = speed * channels * resolution/8; wh.byte_p_spl = channels * (resolution / 8); wh.bit_p_spl = resolution; wh.data_chunk = DATA; wh.data_length= 0; // qDebug("Write header channels %d, speed %d, b/s %d, blockalign %d, bitrate %d" // , wh.modus, wh.sample_fq, wh.byte_p_sec, wh.byte_p_spl, wh.bit_p_spl ); write (wav, &wh, sizeof(WaveHeader)); return 1; } void VMemo::record(void) { int length=0, result, value; QString msg; msg.sprintf("Recording format %d", format); qDebug(msg); if(systemZaurus) { msg.sprintf("Recording format zaurus"); qDebug(msg); signed short sound[512], monoBuffer[512]; if(format==AFMT_S16_LE) { while(recording) { result = read(dsp, sound, 512); // 8192 int j=0; // if(systemZaurus) { for (int i = 0; i < result; i++) { //since Z is mono do normally monoBuffer[i] = sound[i]; } length+=write(wav, monoBuffer, result); if(length<0) recording=false; // } else { //ipaq /stereo inputs // for (int i = 0; i < result; i+=2) { // monoBuffer[j] = sound[i]; // // monoBuffer[j] = (sound[i]+sound[i+1])/2; // j++; // } // length+=write(wav, monoBuffer, result); // if(length<0) // recording=false; // // length+=write(wav, monoBuffer, result/2); // } qApp->processEvents(); // printf("%d\r",length); // fflush(stdout); } } else { //AFMT_U8 // 8bit unsigned unsigned short sound[512], monoBuffer[512]; while(recording) { result = read(dsp, sound, 512); // 8192 int j=0; // if(systemZaurus) { for (int i = 0; i < result; i++) { //since Z is mono do normally monoBuffer[i] = sound[i]; } length+=write(wav, monoBuffer, result); // } else { //ipaq /stereo inputs // for (int i = 0; i < result; i+=2) { // monoBuffer[j] = (sound[i]+sound[i+1])/2; // j++; // } // length+=write(wav, monoBuffer, result/2); // if(length<0) // recording=false; // } length += result; // printf("%d\r",length); // fflush(stdout); } qApp->processEvents(); } } else { // 16 bit only capabilities msg.sprintf("Recording format other"); qDebug(msg); signed short sound[512], monoBuffer[512]; while(recording) { result = read(dsp, sound, 512); // 8192 write(wav, sound, result); length += result; if(length<0) { recording=false; perror("dev/dsp's is a lookin' messy"); QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); } // printf("%d\r",length); // fflush(stdout); qApp->processEvents(); } // qDebug("file has length of %d lasting %d seconds", // length, (( length / speed) / channels) / 2 ); // medialplayer states wrong length in secs } //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<// value = length+36; lseek(wav, 4, SEEK_SET); write(wav, &value, 4); lseek(wav, 40, SEEK_SET); write(wav, &length, 4); track.close(); qDebug("Tracvk closed"); if( ioctl( dsp, SNDCTL_DSP_RESET,0) == -1) perror("ioctl(\"SNDCTL_DSP_RESET\")"); ::close(dsp); fileName = fileName.left(fileName.length()-4); // if(useAlerts) // QMessageBox::message("Vmemo"," Done1 recording\n"+ fileName); qDebug("done recording "+fileName); QSound::play(Resource::findSound("vmemoe")); Config cfg("qpe"); cfg.setGroup("Volume"); QString foo = cfg.readEntry("Mute","TRUE"); if(foo.find("TRUE",0,TRUE) != -1) QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; //mute } int VMemo::setToggleButton(int tog) { for( int i=0; i < 10;i++) { switch (tog) { case 0: return -1; break; case 1: return 0; break; case 2: return Key_Escape; break; case 3: return Key_Space; break; case 4: return Key_F12; break; case 5: return Key_F9; break; case 6: return Key_F10; break; case 7: return Key_F11; break; case 8: return Key_F13; break; }; } + return -1; } diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index 8299b3d..7a67ab2 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc @@ -1,309 +1,309 @@ #include <qcheckbox.h> #include <qcombobox.h> #include <qheader.h> #include <qlabel.h> #include <qabstractlayout.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qmessagebox.h> #include <qpainter.h> #include <qpushbutton.h> #include <qwidgetstack.h> #include <qpopupmenu.h> #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include <qtimer.h> #include <qpe/qpeapplication.h> #include <qpe/applnk.h> #include <qpe/fileselector.h> #include <qpe/global.h> #include <qpe/mimetype.h> #include <qpe/resource.h> #include <qpe/storage.h> #include <unistd.h> #include <stdlib.h> #include <sys/stat.h> #include "ofileselector.h" QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; namespace { int indexByString( const QComboBox *box, const QString &str ){ int index= 0; for(int i= 0; i < box->count(); i++ ){ if( str == box->text(i ) ){ index= i; break; } } return index; } class OFileSelectorItem : public QListViewItem { public: OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, const QString &date, const QString &size, const QString &mDir, bool isLocked=false, bool isDir=false ): QListViewItem(view) { setPixmap(0, pixmap ); setText(1, path ); setText(2, size ); setText(3, date ); //setText(4, mDir ); m_dir = mDir; dir = isDir; mLocked = isLocked; } bool isLocked() const{ return mLocked; } QString directory()const{ return m_dir; } bool isDir()const{ return dir; } QString path()const{ return text(1 ); } QString key(int id, bool )const { QString ke; if( id == 0 || id == 1 ){ // name if( dir ){ ke.append("0" ); ke.append( text(1) ); }else{ ke.append("1" ); ke.append( text(1) ); } }else if( id == 2 ){ // size return text(2); }else if( id == 3 ){ // date return text(3); } return ke; }; private: bool mLocked:1; bool dir:1; QString m_dir; }; }; OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName, const QStringList &mimeTypes ) : QWidget( wid, "OFileSelector") { m_mimetypes = mimeTypes; initVars(); m_mode = mode; m_selector = selector; m_currentDir = dirName; init(); QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); } OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, - const char *name, bool newVisible = TRUE, - bool closeVisible = FALSE ) + const char *name, bool newVisible, + bool closeVisible ) : QWidget( parent, name ) { m_mimetypes = QStringList::split(";", mimeFilter ); initVars(); m_currentDir = QPEApplication::documentDir(); m_mode = OPEN; m_selector = NORMAL; m_shClose = closeVisible; m_shNew = newVisible; m_shLne = false; m_shPerm = false; m_shYesNo = false; init(); } OFileSelector::~OFileSelector() { } void OFileSelector::setNewVisible( bool visible ) { m_shNew = visible; if( m_selector == NORMAL ){ delete m_select; // we need to initialize but keep the selected mimetype QString mime = m_mimeCheck == 0 ? QString::null : m_mimeCheck->currentText() ; m_select = new FileSelector( m_autoMime ? mime : m_mimetypes.join(";") , m_stack, "fileselector", m_shNew, m_shClose); connect(m_select, SIGNAL(fileSelected( const DocLnk & ) ), this, SLOT( slotFileBridgeSelected(const DocLnk & ) ) ); //connect to close me and other signals as well m_stack->addWidget( m_select, NORMAL ); }else{ m_new->show(); } } void OFileSelector::setCloseVisible( bool visible ) { m_shClose = visible; if( m_selector == NORMAL ){ setNewVisible( m_shNew ); // yeah baby }else{ m_close->show(); } } void OFileSelector::reread() { if( m_selector == NORMAL ){ setNewVisible( m_shNew ); // make it a initializeSelector }else if ( m_selector == EXTENDED || m_selector == EXTENDED_ALL ){ reparse(); //}else{ //; } } const DocLnk *OFileSelector::selected() { if( m_selector == NORMAL ){ return m_select->selected(); }else{ DocLnk *lnk = new DocLnk(selectedDocument() ); return lnk; } } void OFileSelector::setYesCancelVisible( bool show ) { initializeYes(); // FIXME if YesCancel is not shown we will initialize it to hide it :( m_shYesNo = show; if( m_shYesNo ) m_boxOk->show(); else m_boxOk->hide(); } void OFileSelector::setToolbarVisible( bool show ) { m_shTool = show; initializeListView(); // FIXME see above waste of memory if(!m_shTool ){ m_location->hide(); m_up->hide(); m_homeButton->hide(); m_docButton->hide(); }else{ m_location->show(); m_up->show(); m_homeButton->show(); m_docButton->show(); } } void OFileSelector::setPermissionBarVisible( bool show ) { m_shPerm = show; initializePerm(); if( m_shPerm ) m_checkPerm->show(); else m_checkPerm->hide(); } void OFileSelector::setLineEditVisible( bool show ) { if( show ){ initializeName(); m_boxName->show(); }else{ if( m_shLne && m_boxName != 0 ){ // check if we showed before this is the way to go m_boxName->hide(); } } m_shLne = show; } void OFileSelector::setChooserVisible( bool show ) { m_shChooser = show; initializeChooser(); if( m_shChooser ){ m_boxView->hide(); }else{ m_boxView->show(); } } QCheckBox* OFileSelector::permissionCheckbox() { if( m_selector == NORMAL ) return 0l; else return m_checkPerm; } bool OFileSelector::setPermission()const { return m_checkPerm == 0 ? false : m_checkPerm->isChecked(); } void OFileSelector::setPermissionChecked( bool check ) { if( m_checkPerm ) m_checkPerm->setChecked( check ); } void OFileSelector::setMode(int mode) // FIXME do direct raising { m_mode = mode; if( m_selector == NORMAL ) return; } void OFileSelector::setShowDirs(bool ) { m_dir = true; reparse(); } void OFileSelector::setCaseSensetive(bool caSe ) { m_case = caSe; reparse(); } void OFileSelector::setShowFiles(bool show ) { m_files = show; reparse(); } /// bool OFileSelector::cd(const QString &path ) { m_currentDir = path; reparse(); return true; } void OFileSelector::setSelector(int mode ) { QString text; switch( mode ){ case NORMAL: text = tr("Documents"); break; case EXTENDED: text = tr("Files"); break; case EXTENDED_ALL: text = tr("All Files"); break; } slotViewCheck( text ); } void OFileSelector::setPopupMenu(QPopupMenu *popup ) diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 293c391..8f2b9c9 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -310,388 +310,388 @@ qDebug("read COnfig"); TabWidget->setCurrentPage(2); } OpieFtp::~OpieFtp() { } void OpieFtp::cleanUp() { if(conn) FtpQuit(conn); QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); if(file.exists()) file.remove(); exit(0); } void OpieFtp::tabChanged(QWidget *w) { if (TabWidget->currentPageIndex() == 0) { currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); tabMenu->setItemChecked(tabMenu->idAt(0),TRUE); tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); if(cdUpButton->isHidden()) cdUpButton->show(); if(homeButton->isHidden()) homeButton->show(); } if (TabWidget->currentPageIndex() == 1) { currentPathCombo->lineEdit()->setText( currentRemoteDir ); tabMenu->setItemChecked(tabMenu->idAt(1),TRUE); tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); tabMenu->setItemChecked(tabMenu->idAt(2),FALSE); if(cdUpButton->isHidden()) cdUpButton->show(); homeButton->hide(); } if (TabWidget->currentPageIndex() == 2) { tabMenu->setItemChecked(tabMenu->idAt(2),TRUE); tabMenu->setItemChecked(tabMenu->idAt(0),FALSE); tabMenu->setItemChecked(tabMenu->idAt(1),FALSE); cdUpButton->hide(); homeButton->hide(); } } void OpieFtp::newConnection() { UsernameComboBox->lineEdit()->setText(""); PasswordEdit->setText( "" ); ServerComboBox->lineEdit()->setText( ""); remotePath->setText( currentRemoteDir = "/"); PortSpinBox->setValue( 21); TabWidget->setCurrentPage(2); } void OpieFtp::serverComboEdited(const QString & edit) { if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { qDebug("ServerComboEdited"); currentServerConfig = -1; } } void OpieFtp::connectorBtnToggled(bool On) { if(On) { connector(); } else { disConnector(); } } void OpieFtp::connector() { // QCopEnvelope ( "QPE/System", "busy()" ); // qApp->processEvents(); currentRemoteDir=remotePath->text(); if(ServerComboBox->currentText().isEmpty()) { QMessageBox::warning(this,tr("Ftp"),tr("Please set the server info"),tr("Ok"),0,0); TabWidget->setCurrentPage(2); ServerComboBox->setFocus(); connectServerBtn->setOn(FALSE); connectServerBtn->setText( tr("Connect")); return; } FtpInit(); TabWidget->setCurrentPage(1); QString ftp_host = ServerComboBox->currentText(); QString ftp_user = UsernameComboBox->currentText(); QString ftp_pass = PasswordEdit->text(); QString port=PortSpinBox->cleanText(); port.stripWhiteSpace(); if(ftp_host.find("ftp://",0, TRUE) != -1 ) ftp_host=ftp_host.right(ftp_host.length()-6); ftp_host+=":"+port; if (!FtpConnect( ftp_host.latin1(), &conn)) { QMessageBox::message(tr("Note"),tr("Unable to connect to\n")+ftp_host); connectServerBtn->setOn(FALSE); connectServerBtn->setText( tr("Connect")); return ; } if (!FtpLogin( ftp_user.latin1(), ftp_pass.latin1(),conn )) { QString msg; msg.sprintf(tr("Unable to log in\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); if(conn) FtpQuit(conn); connectServerBtn->setOn(FALSE); connectServerBtn->setText( tr("Connect")); return ; } remoteDirList("/") ; setCaption(ftp_host); if( currentServerConfig == -1) writeConfig(); connectServerBtn->setText( tr("Disconnect")); // QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::disConnector() { if(conn) FtpQuit(conn); setCaption("OpieFtp"); currentRemoteDir="/"; Remote_View->clear(); connectServerBtn->setText( tr("Connect")); connectServerBtn->setOn(FALSE); setCaption("OpieFtp"); } void OpieFtp::localUpload() { int fsz; // QCopEnvelope ( "QPE/System", "busy()" ); // qApp->processEvents(); QList<QListViewItem> * getSelectedItems( QListView * Local_View ); QListViewItemIterator it( Local_View ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { QString strItem = it.current()->text(0); QString localFile = currentDir.canonicalPath()+"/"+strItem; QString remoteFile= currentRemoteDir+strItem; QFileInfo fi(localFile); if( !fi.isDir()) { fsz=fi.size(); ProgressBar->setTotalSteps(fsz); FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { QString msg; msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); } } else { QMessageBox::message(tr("Note"),tr("Cannot upload directories")); } ProgressBar->reset(); nullifyCallBack(); it.current()->setSelected(FALSE); } //end currentSelected } for ( ; it.current(); ++it ) { Local_View->clearSelection(); } Local_View->clearFocus(); TabWidget->setCurrentPage(1); remoteDirList( (const QString &)currentRemoteDir); //this also calls populate // QCopEnvelope ( "QPE/System", "notBusy()" ); } void OpieFtp::nullifyCallBack() { - FtpOptions(FTPLIB_CALLBACK, NULL, conn); - FtpOptions(FTPLIB_IDLETIME, NULL, conn); - FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); - FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); + FtpOptions(FTPLIB_CALLBACK, 0, conn); + FtpOptions(FTPLIB_IDLETIME, 0, conn); + FtpOptions(FTPLIB_CALLBACKARG, 0, conn); + FtpOptions(FTPLIB_CALLBACKBYTES, 0, conn); } void OpieFtp::remoteDownload() { // qApp->processEvents(); int fsz; // QCopEnvelope ( "QPE/System", "busy()" ); QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); QListViewItemIterator it( Remote_View ); for ( ; it.current(); ++it ) { if ( it.current()->isSelected() ) { QString strItem = it.current()->text(0); // strItem=strItem.right(strItem.length()-1); QString localFile = currentDir.canonicalPath(); if(localFile.right(1).find("/",0,TRUE) == -1) localFile += "/"; localFile += strItem; // QString localFile = currentDir.canonicalPath()+"/"+strItem; QString remoteFile= currentRemoteDir+strItem; if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) fsz = 0; QString temp; temp.sprintf( remoteFile+" "+" %dkb", fsz); ProgressBar->setTotalSteps(fsz); FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { QString msg; msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); } ProgressBar->reset(); nullifyCallBack(); it.current()->setSelected(FALSE); } } for ( ; it.current(); ++it ) { Remote_View->clearSelection(); } Remote_View->setFocus(); TabWidget->setCurrentPage(0); populateLocalView(); // QCopEnvelope ( "QPE/System", "notBusy()" ); } bool OpieFtp::remoteDirList(const QString &dir) { QString tmp = QDir::homeDirPath(); if(tmp.right(1) != "/") tmp+="/._temp"; else tmp+="._temp"; // qDebug("Listing remote dir "+tmp); // QCopEnvelope ( "QPE/System", "busy()" ); if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { QString msg; msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); return false; } populateRemoteView() ; // QCopEnvelope ( "QPE/System", "notBusy()" ); return true; } bool OpieFtp::remoteChDir(const QString &dir) { // QCopEnvelope ( "QPE/System", "busy()" ); if (!FtpChdir( dir.latin1(), conn )) { QString msg; msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); msg.replace(QRegExp(":"),"\n"); QMessageBox::message(tr("Note"),msg); // qDebug(msg); // QCopEnvelope ( "QPE/System", "notBusy()" ); return FALSE; } // QCopEnvelope ( "QPE/System", "notBusy()" ); return TRUE; } void OpieFtp::populateLocalView() { Local_View->clear(); currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); currentDir.setMatchAllDirs(TRUE); currentDir.setNameFilter(filterStr); QString fileL, fileS, fileDate; bool isDir=FALSE; const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); QFileInfoListIterator it(*list); QFileInfo *fi; while ( (fi=it.current()) ) { if (fi->isSymLink() ){ QString symLink=fi->readLink(); // qDebug("Symlink detected "+symLink); QFileInfo sym( symLink); fileS.sprintf( "%10li", sym.size() ); fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); fileDate = sym.lastModified().toString(); } else { // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); fileS.sprintf( "%10li", fi->size() ); fileL.sprintf( "%s",fi->fileName().data() ); fileDate= fi->lastModified().toString(); if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { fileL+="/"; isDir=TRUE; // qDebug( fileL); } } if(fileL !="./" && fi->exists()) { item= new QListViewItem( Local_View,fileL, fileDate, fileS ); QPixmap pm; if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) pm = Resource::loadPixmap( "lockedfolder" ); else pm= Resource::loadPixmap( "folder" ); item->setPixmap( 0,pm ); } else { if( !fi->isReadable() ) pm = Resource::loadPixmap( "locked" ); else { MimeType mt(fi->filePath()); pm=mt.pixmap(); //sets the correct pixmap for mimetype if(pm.isNull()) pm = Resource::loadPixmap( "UnknownDocument-14" ); item->setPixmap( 0,pm); } } if( fileL.find("->",0,TRUE) != -1) { // overlay link image pm= Resource::loadPixmap( "folder" ); QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); QPainter painter( &pm ); painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); pm.setMask( pm.createHeuristicMask( FALSE ) ); item->setPixmap( 0, pm); } } isDir=FALSE; ++it; } Local_View->setSorting( 3,FALSE); currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); fillCombo( (const QString &)currentDir); } bool OpieFtp::populateRemoteView( ) { // qDebug("populate remoteview"); QString sfile=QDir::homeDirPath(); if(sfile.right(1) != "/") sfile+="/._temp"; else sfile+="._temp"; QFile file( sfile); Remote_View->clear(); QString s, File_Name; QListViewItem *itemDir=NULL, *itemFile=NULL; QString fileL, fileS, fileDate; if ( file.open(IO_ReadOnly)) { QTextStream t( &file ); // use a text stream while ( !t.eof()) { s = t.readLine(); fileL = s.right(s.length()-55); fileL = fileL.stripWhiteSpace(); if(s.left(1) == "d") fileL = fileL+"/"; // fileL = "/"+fileL+"/"; fileS = s.mid( 30, 42-30); fileS = fileS.stripWhiteSpace(); fileDate = s.mid( 42, 55-42); fileDate = fileDate.stripWhiteSpace(); if(fileL.find("total",0,TRUE) == -1) { if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); item->setPixmap( 0, Resource::loadPixmap( "folder" )); // if(itemDir) item->moveItem(itemDir); itemDir=item; } else { diff --git a/noncore/settings/sound/soundsettings.cpp b/noncore/settings/sound/soundsettings.cpp index b490072..672548f 100644 --- a/noncore/settings/sound/soundsettings.cpp +++ b/noncore/settings/sound/soundsettings.cpp @@ -1,234 +1,234 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "soundsettings.h" #include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/storage.h> #include <qapplication.h> #include <qslider.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qcombobox.h> #include <sys/utsname.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <sys/stat.h> -SoundSettings::SoundSettings( QWidget* parent, const char* name, WFlags fl ) - : SoundSettingsBase( parent, name, TRUE, fl ) +SoundSettings::SoundSettings( QWidget* parent, const char* objname, WFlags fl ) + : SoundSettingsBase( parent, objname, TRUE, fl ) { keyReset=FALSE; Config config( "qpe"); config.setGroup( "Volume" ); volume->setValue(100-config.readNumEntry("VolumePercent")); mic->setValue(100-config.readNumEntry("Mic")); // touchsound->setChecked(config.readBoolEntry("TouchSound")); // keysound->setChecked(config.readBoolEntry("KeySound")); Config cfg("Vmemo"); connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); AlertCheckBox->setChecked(cfg.readBoolEntry("Alert")); cfg.setGroup("Record"); int rate=config.readNumEntry("SampleRate", 22050); if(rate == 8000) sampleRate->setCurrentItem(0); else if(rate == 11025) sampleRate->setCurrentItem(1); else if(rate == 22050) sampleRate->setCurrentItem(2); else if(rate == 33075) sampleRate->setCurrentItem(3); else if(rate==44100) sampleRate->setCurrentItem(4); stereoCheckBox->setChecked(cfg.readNumEntry("Stereo", 0)); //TODO hide if zaurus- mono only struct utsname name; /* check for embedix kernel running on the zaurus*/ if (uname(&name) != -1) { QString release=name.release; if( release.find("embedix",0,TRUE) !=-1) stereoCheckBox->hide(); } // else // stereoCheckBox->hide(); sixteenBitCheckBox->setChecked(cfg.readNumEntry("SixteenBit", 1)); cfg.setGroup("Defaults"); keyComboBox->setCurrentItem(cfg.readNumEntry("toggleKey") ); updateStorageCombo(); connect(volume, SIGNAL(valueChanged(int)), this, SLOT(setVolume(int))); connect(mic, SIGNAL(valueChanged(int)), this, SLOT(setMic(int))); connect(qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); connect(qApp, SIGNAL( micChanged(bool) ), this, SLOT ( micChanged(bool) ) ); connect( LocationComboBox,SIGNAL(activated(const QString &)),this,SLOT( setLocation(const QString &))); connect( keyComboBox,SIGNAL(activated(const QString &)),this,SLOT(setKeyButton(const QString &))); // connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); } // void SoundSettings::reject() // { // qDebug("reject"); // Config config( "qpe"); // config.setGroup( "Volume"); // setVolume(100-config.readNumEntry("VolumePercent")); // setMic(100-config.readNumEntry("Mic")); // // config.setGroup("Record"); // // int rate=config.readNumEntry("SampleRate", 11025); // // if(rate == 11025) // // sampleRate->setCurrentItem(0); // // else if(rate == 22050) // // sampleRate->setCurrentItem(1); // // else if(rate == 32000) // // sampleRate->setCurrentItem(2); // // else if(rate==44100) // // sampleRate->setCurrentItem(3); // // stereoCheckBox->setChecked(config.readNumEntry("Stereo", 0)); // // sixteenBitCheckBox->setChecked(config.readNumEntry("SixteenBit", 0)); // qDebug("QDialog::reject();"); // ::exit(-1); // } // void SoundSettings::accept() // { // qDebug("accept"); // Config config( "qpe" ); // config.setGroup( "Volume" ); // config.writeEntry("VolumePercent",100-volume->value()); // config.writeEntry("Mic",100-mic->value()); // // config.writeEntry("TouchSound",touchsound->isChecked()); // // config.writeEntry("KeySound",keysound->isChecked()); // Config cfg("Vmemo"); // cfg.writeEntry("Alert",AlertCheckBox->isChecked()); // setVolume(volume->value()); // setMic(mic->value()); // cfg.setGroup("Record"); // cfg.writeEntry("SampleRate",sampleRate->currentText()); // cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); // cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); // // Config cfg( "VMemo" ); // // cfg.setGroup( "Defaults" ); // // cfg.writeEntry( "hideIcon", HideIcon_CheckBox->isChecked()); // qDebug("QDialog::accept();"); // ::exit(0); // } void SoundSettings::setVolume(int v) { Config config( "qpe" ); config.setGroup( "Volume" ); config.writeEntry("VolumePercent",100-v); #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; #endif } void SoundSettings::setMic(int m) { Config config( "qpe" ); config.setGroup( "Volume" ); config.writeEntry("Mic",100-m); #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) QCopEnvelope( "QPE/System", "micChange(bool)" ) << FALSE; #endif } void SoundSettings::volumeChanged( bool ) { Config config( "qpe" ); config.setGroup( "Volume" ); volume->setValue(100-config.readNumEntry("VolumePercent")); } void SoundSettings::micChanged( bool ) { Config config( "qpe" ); config.setGroup( "Volume" ); mic->setValue(100-config.readNumEntry("Mic")); } void SoundSettings::updateStorageCombo() { Config config( "Vmemo" ); config.setGroup( "System" ); QString loc = config.readEntry("RecLocation","/"); int i=0; int set=0; StorageInfo storageInfo; QString sName, sPath; QStringList list; const QList<FileSystem> &fs = storageInfo.fileSystems(); QListIterator<FileSystem> it ( fs ); for( ; it.current(); ++it ){ const QString name = (*it)->name(); const QString path = (*it)->path(); qDebug("storage name "+name +" storage path is "+path); list << name + ": " +path; if( loc.find( path,0,TRUE) != -1) set = i; // if(dit.current()->file().find(path) != -1 ) storage=name; i++; } LocationComboBox->insertStringList(list); qDebug("set item %d", set); LocationComboBox->setCurrentItem(set); } void SoundSettings::setLocation(const QString & string) { Config config( "Vmemo" ); config.setGroup( "System" ); config.writeEntry("RecLocation",string); qDebug("set location "+string); config.write(); } void SoundSettings::cleanUp() { qDebug("cleanup"); Config config( "qpe" ); config.setGroup( "Volume" ); config.writeEntry("VolumePercent",100-volume->value()); config.writeEntry("Mic",100-mic->value()); // config.writeEntry("TouchSound",touchsound->isChecked()); // config.writeEntry("KeySound",keysound->isChecked()); Config cfg("Vmemo"); cfg.writeEntry("Alert",AlertCheckBox->isChecked()); setVolume(volume->value()); setMic(mic->value()); cfg.setGroup("Record"); cfg.writeEntry("SampleRate",sampleRate->currentText()); cfg.writeEntry("Stereo",stereoCheckBox->isChecked()); cfg.writeEntry("SixteenBit",sixteenBitCheckBox->isChecked()); diff --git a/noncore/tools/opie-sh/fviewer.cpp b/noncore/tools/opie-sh/fviewer.cpp index 882c72c..6f8f054 100644 --- a/noncore/tools/opie-sh/fviewer.cpp +++ b/noncore/tools/opie-sh/fviewer.cpp @@ -1,59 +1,59 @@ /* Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "fviewer.h" -FViewer::FViewer(QString icon, QString filename, QString title, QWidget *parent=0, const char*name=0):QWidget(parent, name) +FViewer::FViewer(QString icon, QString filename, QString title, QWidget *parent, const char*name):QWidget(parent, name) { QVBoxLayout *layout = new QVBoxLayout(this); setIcon(Resource::loadPixmap("opie-sh")); textView = new QTextBrowser(this, "textview"); layout->addWidget(textView); QString string; if(title.isNull()) { setCaption(filename); } else { setCaption(title); } file = new QFile(); if(!filename.isNull()) { file->setName(filename); file->open(IO_ReadOnly); } else { file->open(IO_ReadOnly, 0); } stream = new QTextStream(file); string = stream->read(); textView->mimeSourceFactory()->setFilePath(QDir::currentDirPath()+"/"); textView->setText(string, QDir::currentDirPath()+"/"); printf("%s\n", QDir::currentDirPath().latin1()); file->close(); } diff --git a/noncore/tools/opie-sh/inputdialog.cpp b/noncore/tools/opie-sh/inputdialog.cpp index 0780def..1c4e688 100644 --- a/noncore/tools/opie-sh/inputdialog.cpp +++ b/noncore/tools/opie-sh/inputdialog.cpp @@ -1,117 +1,118 @@ /* Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "inputdialog.h" -InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent=0, const char *name=0, bool modal=true, WFlags f=0):QDialog(parent, name, modal, f) +InputDialog::InputDialog(int w, int h, int newtype, QString labelString, QString title, QString filename, bool edit, QWidget *parent, const char *name, bool modal, WFlags f):QDialog(parent, name, modal, f) { type = newtype; QHBoxLayout *layout = new QHBoxLayout(this); layout->addStrut(32); QLabel *label = new QLabel(labelString, this, "label"); setCaption(title); int x, y; layout->addSpacing(5); layout->addWidget(label); layout->addSpacing(5); switch(type) { case 0: lineEdit = new QLineEdit(this, "line edit"); layout->addWidget(lineEdit); break; case 1: comboBox = new QComboBox(edit, this, "combo box"); layout->addWidget(comboBox); if(!filename.isNull()) { QFile file(filename); file.open(IO_ReadOnly); QTextStream stream(&file); QString string = stream.read(); comboBox->insertStringList(QStringList::split('\n', string)); } else { QFile file; file.open(IO_ReadOnly, 0); QTextStream stream(&file); QString string = stream.read(); comboBox->insertStringList(QStringList::split('\n', string)); } break; case 2: listBox = new QListBox(this, "list box"); listBox->setSelectionMode(QListBox::Multi); layout->addWidget(listBox); if(!filename.isNull()) { QFile file(filename); file.open(IO_ReadOnly); QTextStream stream(&file); QString string = stream.read(); listBox->insertStringList(QStringList::split('\n', string)); } else { QFile file; file.open(IO_ReadOnly, 0); QTextStream stream(&file); QString string = stream.read(); listBox->insertStringList(QStringList::split('\n', string)); } break; } layout->addSpacing(5); x=(w/2)-(width()/2); y=(h/2)-(height()/2); move(x,y); } QString InputDialog::getString() { switch (type) { case 0: return ((QLineEdit *)child("line edit"))->text(); break; case 1: return ((QComboBox *)child("combo box"))->currentText(); break; case 2: QString string; int i; for(i = 0; i < listBox->count(); i++) { if(listBox->isSelected(i)) { string+=listBox->text(i)+'\n'; } } if(string[string.length()-1] == '\n') { string.truncate(string.length()-1); } return string; } + return QString::null; } diff --git a/noncore/tools/opie-sh/mbox.cpp b/noncore/tools/opie-sh/mbox.cpp index cb3ea1b..04b397d 100644 --- a/noncore/tools/opie-sh/mbox.cpp +++ b/noncore/tools/opie-sh/mbox.cpp @@ -1,90 +1,90 @@ /* Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mbox.h" -MBox::MBox(int w, int h, int type, QString title, QString message, QString *btext0 = 0, QString *btext1= 0, QString *btext2 = 0, QWidget *parent=0, const char*name=0, bool modal=true, WFlags f=0):QDialog(parent, name, modal, f) +MBox::MBox(int w, int h, int type, QString title, QString message, QString *btext0, QString *btext1, QString *btext2, QWidget *parent, const char*name, bool modal, WFlags f):QDialog(parent, name, modal, f) { QVBoxLayout *layout = new QVBoxLayout(this); QHBoxLayout *hlayout1 = new QHBoxLayout(this); QHBoxLayout *hlayout2 = new QHBoxLayout(this); int x, y; layout->addLayout(hlayout1); layout->addLayout(hlayout2); setCaption(title); QLabel *image = new QLabel(this, "image"); QLabel *text = new QLabel(message, this, "text"); switch (type) { case 0: image->setPixmap(Resource::loadPixmap("opie-sh/info")); break; case 1: image->setPixmap(Resource::loadPixmap("opie-sh/warning")); break; case 2: image->setPixmap(Resource::loadPixmap("opie-sh/error")); break; } hlayout1->addWidget(image); hlayout1->addSpacing(5); hlayout1->addWidget(text); if(!btext0->isNull()) { QPushButton *button0 = new QPushButton((const QString)*btext0, this, "button0"); hlayout2->addSpacing(5); hlayout2->addWidget(button0); hlayout2->addSpacing(5); connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); } else { QPushButton *button0 = new QPushButton("Ok", this, "button0"); hlayout2->addSpacing(5); hlayout2->addWidget(button0); hlayout2->addSpacing(5); connect(button0, SIGNAL(clicked()), this, SLOT(b0pressed()) ); } if(!btext1->isNull()) { QPushButton *button1 = new QPushButton((const QString)*btext1, this, "button1"); hlayout2->addWidget(button1); hlayout2->addSpacing(5); connect(button1, SIGNAL(clicked()), this, SLOT(b1pressed()) ); } if(!btext2->isNull()) { QPushButton *button2 = new QPushButton((const QString)*btext2, this, "button2"); hlayout2->addWidget(button2); hlayout2->addSpacing(5); connect(button2, SIGNAL(clicked()), this, SLOT(b2pressed()) ); } x=(w/2)-(width()/2); y=(h/2)-(height()/2); move(x, y); } diff --git a/noncore/tools/opie-sh/opie-sh.cpp b/noncore/tools/opie-sh/opie-sh.cpp index e898cb1..96b4b93 100644 --- a/noncore/tools/opie-sh/opie-sh.cpp +++ b/noncore/tools/opie-sh/opie-sh.cpp @@ -1,277 +1,278 @@ /* Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <qstring.h> #include <qstringlist.h> #include <qpe/qpeapplication.h> #include <qmessagebox.h> #include <qwidget.h> #include <stdio.h> #include "mbox.h" #include "fviewer.h" #include "inputdialog.h" int myMessageBox(int wi, int h, QWidget *w, int argc, QStringList args) { int i, type=0; QString button0Text, button1Text, button2Text, string, title; bool full=true; for(i=0; i<argc; i++) { if(args[i] == "-t") { title = args[i+1]; } if(args[i] == "-M") { string = args[i+1]; } if(args[i] == "-0") { button0Text = args[i+1]; } if(args[i] == "-1") { button1Text = args[i+1]; } if(args[i] == "-2") { button2Text = args[i+1]; } if(args[i] == "-I") { type=0; } if(args[i] == "-w") { type = 1; } if(args[i] == "-e") { type = 2; } if(args[i] == "-g") { full = false; } } MBox *mbox = new MBox(wi, h, (int)type, title, string, &button0Text, &button1Text, &button2Text, w, (QString)"messagebox"); if(full) { w->setCaption(title); w->showMaximized(); } // mbox->show(); switch(mbox->exec() ) { case 0: return -1; case 1: return -1; case 2: return 0; case 3: return 1; case 4: return 2; + default: return -1; } } void printusage() { printf("Usage instructions for Opie-sh\n"); printf("Usage: opie-sh [dialog type] [type specific options]\n"); printf("Types:\n"); printf(" -m Message Box\n"); printf(" -f [filename] View file [Default = stdin]\n"); printf(" -i Input dialog\n"); printf(" -h --help These instructions\n"); printf(" -t [title] The window/dialog title\n"); printf("Message box options:\n"); printf(" -M [message] The message to display\n"); printf(" -I Use information icon\n"); printf(" -w Use the warning icon\n"); printf(" -e Use the error icon\n"); printf(" -0 [text] First button text [Default = OK]\n"); printf(" -1 [text] Second button text\n"); printf(" -2 [text] Third button text\n"); printf(" -g Disable fullscreen\n"); printf("Input Dialog options:\n"); printf(" -s A single line of input (output to console)\n"); printf(" -l List input (newline separated list read in from file)\n"); printf(" -b A list box, enabling multiple selections (input same as -l)\n"); printf(" -L [label] The label for the input field\n"); printf(" -F [filename] An input file (for when it makes sense) [Default = stdin]\n"); printf(" -E Makes list input editable\n"); - printf(" -g Disable fullscreen\n\0"); + printf(" -g Disable fullscreen\n"); } int fileviewer(QPEApplication *a, int argc, QStringList args) { int i; QString filename, title, icon; bool update=false; for(i=0; i < argc; i++) { if(args[i] == "-f") { if(args[i+1][0] != '-') { filename = args[i+1]; } } if(args[i] == "-I") { icon=args[i+1]; } if(args[i] == "-t") { title = args[i+1]; } } FViewer *fview = new FViewer(icon, filename, title, 0, (QString) "fileviewer"); a->setMainWidget(fview); fview->showMaximized(); return a->exec(); } int input(int wi, int h, QWidget *w, int argc, QStringList args) { int i, type = 0; QString title, label, filename; bool edit=false, full=true; for(i=0; i < argc; i++) { if(args[i] == "-s") { type = 0; } if(args[i] == "-l") { type = 1; } if(args[i] == "-b") { type = 2; } if(args[i] == "-t") { title = args[i+1]; } if(args[i] == "-L") { label = args[i+1]; } if(args[i] == "-F") { if(args[i+1][0] != '-') { filename = args[i+1]; } } if(args[i] =="-E") { edit = true; } if(args[i] == "-g") { full = false; } } InputDialog *id = new InputDialog(wi, h, type, label, title, filename, edit, w); if(full) { w->setCaption(title); w->showMaximized(); } if( id->exec() == 1) { printf("%s\n", id->getString().latin1()); return 0; } else { return -1; } } int main(int argc, char **argv) { int i; QStringList args; QPEApplication a(argc, argv); QWidget w; a.setMainWidget(&w); QWidget *d = a.desktop(); int width=d->width(); int height=d->height(); for(i=0; i < argc; i++) { args += argv[i]; } for(i=0; i < argc; i++) { if(args[i] == "-m") { return myMessageBox(width, height, &w, argc, args); } if(args[i] == "-f") { return fileviewer(&a, argc, args); } if(args[i] == "-i") { return input(width, height, &w, argc, args); } if(args[i] == "-h" || args[i] =="--help") { printusage(); return -1; } } printusage(); return -1; } diff --git a/noncore/tools/remote/buttondialog.cpp b/noncore/tools/remote/buttondialog.cpp index 7479e85..6ea4801 100644 --- a/noncore/tools/remote/buttondialog.cpp +++ b/noncore/tools/remote/buttondialog.cpp @@ -1,293 +1,293 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "buttondialog.h" -ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent=0, const char*name=0, bool modal=FALSE, WFlags f=0):QDialog(parent, name, modal, f) +ButtonDialog::ButtonDialog(QString buttonName, QWidget *parent, const char*name, bool modal, WFlags f):QDialog(parent, name, modal, f) { setCaption(tr(buttonName)); QVBoxLayout *layout = new QVBoxLayout(this); QHBoxLayout *hlayout1 = new QHBoxLayout(this); QHBoxLayout *hlayout2 = new QHBoxLayout(this); QHBoxLayout *hlayout3 = new QHBoxLayout(this); layout->addSpacing(5); layout->addLayout(hlayout1); layout->addSpacing(5); layout->addLayout(hlayout2); layout->addSpacing(5); layout->addLayout(hlayout3); layout->addSpacing(5); remote = new QComboBox(false, this, "remote"); QLabel *remoteLabel = new QLabel(remote, "Remote: ", this, "remoteLabel"); hlayout1->addSpacing(5); hlayout1->addWidget(remoteLabel); hlayout1->addSpacing(5); hlayout1->addWidget(remote); hlayout1->addSpacing(5); remote->insertItem("Remote "); remote->insertStringList(getRemotes()); connect(remote, SIGNAL(activated(const QString &)), this, SLOT(remoteSelected(const QString&)) ); button = new QComboBox(false, this, "button"); QLabel *buttonLabel = new QLabel(remote, "Button: ", this, "buttonLabel"); hlayout2->addSpacing(5); hlayout2->addWidget(buttonLabel); hlayout2->addSpacing(5); hlayout2->addWidget(button); hlayout2->addSpacing(5); button->insertItem("Button "); connect(button, SIGNAL(activated(const QString &)), this, SLOT(buttonSelected(const QString&)) ); label = new QLineEdit(this, "label"); label->setText(buttonName); QLabel *labelLabel = new QLabel(label, "Label: ", this, "labelLabel"); hlayout3->addSpacing(5); hlayout3->addWidget(labelLabel); hlayout3->addSpacing(5); hlayout3->addWidget(label); hlayout3->addSpacing(5); } void ButtonDialog::remoteSelected(const QString &string) { button->insertStringList(getButtons(string.latin1()) ); list="SEND_ONCE"; list+=string; } void ButtonDialog::buttonSelected(const QString &string) { list+=string; } QStringList ButtonDialog::getList() { return list; } QString ButtonDialog::getLabel() { return label->text(); } QStringList ButtonDialog::getRemotes() { const char write_buffer[] = "LIST\n"; const char *readbuffer; int i, numlines; QStringList list; addr.sun_family=AF_UNIX; strcpy(addr.sun_path,"/dev/lircd"); fd = socket(AF_UNIX, SOCK_STREAM, 0); if(fd == -1) { QMessageBox *mb = new QMessageBox("Error!", "couldnt connect to socket", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("ButtonDialog::GetRemotes"); return NULL; } - if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) + if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) { QMessageBox *mb = new QMessageBox("Error!", "couldnt connect to socket", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("ButtonDialog::GetRemotes"); return NULL; } write(fd, write_buffer, strlen(write_buffer)); for(i=0; i<5; i++) { printf("%d\n", i); readbuffer = readPacket(); printf("%s", readbuffer); printf("%d\n", i); } numlines = atoi(readbuffer); for(i=0; i<numlines; i++) { list+=readPacket(); } if(strcasecmp(readPacket(), "END") != 0) { QMessageBox *mb = new QMessageBox("Error!", "bad packet", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("ButtonDialog::GetRemotes"); return NULL; } - std::close(fd); + ::close(fd); return list; } QStringList ButtonDialog::getButtons(const char *remoteName) { QString write_buffer = "LIST "; const char *readbuffer; int i, j, numlines; QStringList list; QString string; write_buffer += remoteName; write_buffer += '\n'; fd = socket(AF_UNIX, SOCK_STREAM, 0); if(fd == -1) { QMessageBox *mb = new QMessageBox("Error!", "couldnt connect to socket", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("ButtonDialog::GetButtons"); return NULL; } - if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) + if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) { QMessageBox *mb = new QMessageBox("Error!", "couldnt connect to socket", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("ButtonDialog::GetButtons"); return NULL; } write(fd, write_buffer.latin1(), strlen(write_buffer) ); for(i=0; i<5; i++) { readbuffer = readPacket(); } numlines = atoi(readbuffer); for(i=0; i<numlines; i++) { list+=readPacket(); for(j=0; j<list[i].length(); j++) { if(list[i][j] == ' ') break; } list[i].remove(0, j+1); } if(strcasecmp(readPacket(), "END") != 0) { QMessageBox *mb = new QMessageBox("Error!", "bad packet", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("ButtonDialog::GetButtons"); return NULL; } - std::close(fd); + ::close(fd); return list; } //this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html const char *ButtonDialog::readPacket() { static char buffer[PACKET_SIZE+1]=""; char *end; static int ptr=0,end_len=0; ssize_t ret; timeout = 0; if(ptr>0) { memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); ptr=strlen(buffer); end=strchr(buffer,'\n'); } else { end=NULL; } alarm(TIMEOUT); while(end==NULL) { if(PACKET_SIZE<=ptr) { fprintf(stderr,"bad packet\n"); ptr=0; return(NULL); } ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); if(ret<=0 || timeout) { if(timeout) { fprintf(stderr,"timeout\n"); } else { alarm(0); } ptr=0; return(NULL); } buffer[ptr+ret]=0; ptr=strlen(buffer); end=strchr(buffer,'\n'); } alarm(0);timeout=0; end[0]=0; ptr=strlen(buffer)+1; //# ifdef DEBUG // printf("buffer: -%s-\n",buffer); //# endif return(buffer); } diff --git a/noncore/tools/remote/channelgroup.cpp b/noncore/tools/remote/channelgroup.cpp index 9f90284..7c33674 100644 --- a/noncore/tools/remote/channelgroup.cpp +++ b/noncore/tools/remote/channelgroup.cpp @@ -1,100 +1,100 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "channelgroup.h" -ChannelGroup::ChannelGroup(QWidget *parent=0, const char *name=0):QWidget(parent,name) +ChannelGroup::ChannelGroup(QWidget *parent, const char *name):QWidget(parent,name) { QGridLayout *layout = new QGridLayout(this); QVBoxLayout *volLayout = new QVBoxLayout(this); QVBoxLayout *chanLayout = new QVBoxLayout(this); layout->addRowSpacing(1,1); layout->addRowSpacing(3,1); layout->addRowSpacing(5,1); layout->addColSpacing(1,1); layout->addColSpacing(3,1); layout->addColSpacing(5,1); layout->addColSpacing(7,1); QPushButton *one = new QPushButton("1", this, "one"); layout->addWidget(one, 0, 2, 0); connect(one, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *two = new QPushButton("2", this, "two"); layout->addWidget(two, 0, 4, 0); connect(two, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *three = new QPushButton("3", this, "three"); layout->addWidget(three, 0, 6, 0); connect(three, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *four = new QPushButton("4", this, "four"); layout->addWidget(four, 2, 2, 0); connect(four, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *five = new QPushButton("5", this, "five"); layout->addWidget(five, 2, 4, 0); connect(five, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *six = new QPushButton("6", this, "six"); layout->addWidget(six, 2, 6, 0); connect(six, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *seven = new QPushButton("7", this, "seven"); layout->addWidget(seven, 4, 2, 0); connect(seven, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *eight = new QPushButton("8", this, "eight"); layout->addWidget(eight, 4, 4, 0); connect(eight, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *nine = new QPushButton("9", this, "nine"); layout->addWidget(nine, 4, 6, 0); connect(nine, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *zero = new QPushButton("0", this, "zero"); layout->addWidget(zero, 6, 4, 0); connect(zero, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); layout->addMultiCellLayout(volLayout, 0, 6, 0, 0, 0); layout->addMultiCellLayout(chanLayout, 0, 6, 8, 8, 0); QPushButton *volUp = new QPushButton("+", this, "volUp"); volLayout->addWidget(volUp, 1, 0); connect(volUp, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QLabel *volLabel = new QLabel("Volume ", this, "volLabel"); volLayout->addWidget(volLabel, 0, 0); QPushButton *volDown = new QPushButton("-", this, "volDown"); volLayout->addWidget(volDown, 1, 0); connect(volDown, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *chanUp = new QPushButton("+", this, "chanUp"); chanLayout->addWidget(chanUp, 1, 0); connect(chanUp, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QLabel *chanLabel = new QLabel("Channel", this, "chanLabel"); chanLayout->addWidget(chanLabel, 0, 0); QPushButton *chanDown = new QPushButton("-", this, "chanDown"); chanLayout->addWidget(chanDown, 1, 0); connect(chanDown, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); } diff --git a/noncore/tools/remote/channelgroupconf.cpp b/noncore/tools/remote/channelgroupconf.cpp index 2d98115..e39121e 100644 --- a/noncore/tools/remote/channelgroupconf.cpp +++ b/noncore/tools/remote/channelgroupconf.cpp @@ -1,100 +1,100 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "channelgroupconf.h" -ChannelGroupConf::ChannelGroupConf(QWidget *parent=0, const char *name=0):QWidget(parent,name) +ChannelGroupConf::ChannelGroupConf(QWidget *parent, const char *name):QWidget(parent,name) { QGridLayout *layout = new QGridLayout(this); QVBoxLayout *volLayout = new QVBoxLayout(this); QVBoxLayout *chanLayout = new QVBoxLayout(this); layout->addRowSpacing(1,5); layout->addRowSpacing(3,5); layout->addRowSpacing(5,5); layout->addColSpacing(1,1); layout->addColSpacing(3,1); layout->addColSpacing(5,1); layout->addColSpacing(7,1); QPushButton *one = new QPushButton("1", this, "one"); layout->addWidget(one, 0, 2, 0); connect(one, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *two = new QPushButton("2", this, "two"); layout->addWidget(two, 0, 4, 0); connect(two, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *three = new QPushButton("3", this, "three"); layout->addWidget(three, 0, 6, 0); connect(three, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *four = new QPushButton("4", this, "four"); layout->addWidget(four, 2, 2, 0); connect(four, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *five = new QPushButton("5", this, "five"); layout->addWidget(five, 2, 4, 0); connect(five, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *six = new QPushButton("6", this, "six"); layout->addWidget(six, 2, 6, 0); connect(six, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *seven = new QPushButton("7", this, "seven"); layout->addWidget(seven, 4, 2, 0); connect(seven, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *eight = new QPushButton("8", this, "eight"); layout->addWidget(eight, 4, 4, 0); connect(eight, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *nine = new QPushButton("9", this, "nine"); layout->addWidget(nine, 4, 6, 0); connect(nine, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *zero = new QPushButton("0", this, "zero"); layout->addWidget(zero, 6, 4, 0); connect(zero, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); layout->addMultiCellLayout(volLayout, 0, 6, 0, 0, 0); layout->addMultiCellLayout(chanLayout, 0, 6, 8, 8, 0); QPushButton *volUp = new QPushButton("+", this, "volUp"); volLayout->addWidget(volUp, 1, 0); connect(volUp, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QLabel *volLabel = new QLabel("Volume ", this, "volLabel"); volLayout->addWidget(volLabel, 0, 0); QPushButton *volDown = new QPushButton("-", this, "volDown"); volLayout->addWidget(volDown, 1, 0); connect(volDown, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *chanUp = new QPushButton("+", this, "chanUp"); chanLayout->addWidget(chanUp, 1, 0); connect(chanUp, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QLabel *chanLabel = new QLabel("Channel", this, "chanLabel"); chanLayout->addWidget(chanLabel, 0, 0); QPushButton *chanDown = new QPushButton("-", this, "chanDown"); chanLayout->addWidget(chanDown, 1, 0); connect(chanDown, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); } diff --git a/noncore/tools/remote/configtab.cpp b/noncore/tools/remote/configtab.cpp index f5896a9..17cdc6a 100644 --- a/noncore/tools/remote/configtab.cpp +++ b/noncore/tools/remote/configtab.cpp @@ -1,211 +1,211 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configtab.h" -ConfigTab::ConfigTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) +ConfigTab::ConfigTab(QWidget *parent, const char *name):QWidget(parent,name) { QVBoxLayout *layout = new QVBoxLayout(this); topGroupConf = new TopGroupConf(this, "topGroupConf"); layout->addWidget(topGroupConf, 1); layout->addSpacing(1); dvdGroupConf = new DVDGroupConf(this, "dvdGroupConf"); layout->addWidget(dvdGroupConf, 1); layout->addSpacing(1); vcrGroupConf = new VCRGroupConf(this, "vcrGroupConf"); layout->addWidget(vcrGroupConf, 1); layout->addSpacing(1); channelGroupConf = new ChannelGroupConf(this, "channelGroupConf"); layout->addWidget(channelGroupConf, 1); } void ConfigTab::setConfig(Config *newCfg) { cfg = newCfg; cfg->setGroup("Remotes"); topGroupConf->updateRemotes(cfg->readListEntry("remoteList", ',') ); cfg->setGroup("Default"); const QObject *obj; const QObjectList *objList = topGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(!cfg->hasKey((QString)obj->name()+"Label")) { cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); } } } objList = dvdGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(!cfg->hasKey((QString)obj->name()+"Label")) { cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); } } } objList = vcrGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(!cfg->hasKey((QString)obj->name()+"Label")) { cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); } } } objList = channelGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(!cfg->hasKey((QString)obj->name()+"Label")) { cfg->writeEntry((QString)obj->name()+"Label", ((QPushButton *)obj)->text()); } } } cfg->write(); cfg->setGroup("Remotes"); } /* void ConfigTab::savePressed() { cfg->setGroup(remotes->currentText()); ButtonDialog *bd = new ButtonDialog(this, "BD", true, 0); if( bd->exec() == 1) { printf("%s\n", bd->getList().join(" ").latin1()); } } */ void ConfigTab::newPressed() { QStringList list; cfg->setGroup("Remotes"); list=cfg->readListEntry("remoteList", ','); list+=topGroupConf->getRemotesText(); cfg->writeEntry("remoteList", list, ','); cfg->setGroup(topGroupConf->getRemotesText()); topGroupConf->updateRemotes(QStringList(topGroupConf->getRemotesText()) ); cfg->write(); emit remotesChanged(); remoteSelected(topGroupConf->getRemotesText()); } void ConfigTab::remoteSelected(const QString &string) { cfg->setGroup(string); const QObject *obj; const QObjectList *objList = topGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } objList = dvdGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } objList = vcrGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } objList = channelGroupConf->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } } void ConfigTab::buttonPressed() { const QObject *button = sender(); QString string = button->name(); ButtonDialog *bd = new ButtonDialog(((QPushButton *)button)->text(), this, "BD", true, 0); if( bd->exec() == 1) diff --git a/noncore/tools/remote/dvdgroup.cpp b/noncore/tools/remote/dvdgroup.cpp index a75c48a..d7ff515 100644 --- a/noncore/tools/remote/dvdgroup.cpp +++ b/noncore/tools/remote/dvdgroup.cpp @@ -1,93 +1,93 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "dvdgroup.h" -DVDGroup::DVDGroup(QWidget *parent=0, const char *name=0):QWidget(parent,name) +DVDGroup::DVDGroup(QWidget *parent, const char *name):QWidget(parent,name) { QGridLayout *layout = new QGridLayout(this); //put rows between the buttons of size 1 layout->addRowSpacing(1,1); layout->addRowSpacing(3,1); //put collumns between the buttons of size 5 layout->addColSpacing(1,5); layout->addColSpacing(3,5); layout->addColSpacing(5,5); layout->addColSpacing(7,5); //make sure that the collumns with the buttons in them stretch before the filler collumns do //since there is so little room, there is no need to do this for the rows layout->setColStretch(4,1); layout->setColStretch(2,1); layout->setColStretch(6,1); layout->setColStretch(8,1); layout->setColStretch(0,1); //add the menu navigation buttons, and connect them to the RemoteTab slots... QPushButton *up = new QPushButton("Up", this,"up"); layout->addWidget(up, 0, 4, 0); connect(up, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *down = new QPushButton("Down",this,"down"); layout->addWidget(down, 4, 4, 0); connect(down, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *left = new QPushButton("Left",this,"left"); layout->addWidget(left, 2, 2, 0); connect(left, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *right = new QPushButton("Right", this, "right"); layout->addWidget(right, 2, 6, 0); connect(right, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *enter = new QPushButton("Enter",this,"enter"); layout->addWidget(enter, 2, 4, 0); connect(enter, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); //add some other buttons QPushButton *eject = new QPushButton("Eject", this, "eject"); layout->addWidget(eject, 0, 0, 0); connect(eject, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *menu = new QPushButton("Menu", this, "menu"); layout->addWidget(menu, 2, 0, 0); connect(menu, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *topMenu = new QPushButton("Top", this, "topMenu"); layout->addWidget(topMenu, 4, 0, 0); connect(topMenu, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *audio = new QPushButton("Audio", this, "audio"); layout->addWidget(audio, 0, 8, 0); connect(audio, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *sub = new QPushButton("Sub", this, "sub"); layout->addWidget(sub, 2, 8, 0); connect(sub, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *angle = new QPushButton("Angle", this, "angle"); layout->addWidget(angle, 4, 8, 0); connect(angle, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); } diff --git a/noncore/tools/remote/dvdgroupconf.cpp b/noncore/tools/remote/dvdgroupconf.cpp index 5bfe393..2a08ab6 100644 --- a/noncore/tools/remote/dvdgroupconf.cpp +++ b/noncore/tools/remote/dvdgroupconf.cpp @@ -1,87 +1,87 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "dvdgroupconf.h" -DVDGroupConf::DVDGroupConf(QWidget *parent=0, const char *name=0):QWidget(parent,name) +DVDGroupConf::DVDGroupConf(QWidget *parent, const char *name):QWidget(parent,name) { QGridLayout *layout = new QGridLayout(this); //put rows between the buttons of size 1 layout->addRowSpacing(1,1); layout->addRowSpacing(3,1); //put collumns between the buttons of size 5 layout->addColSpacing(1,5); layout->addColSpacing(3,5); layout->addColSpacing(5,5); layout->addColSpacing(7,5); //make sure that the collumns with the buttons in them stretch before the filler collumns do //since there is so little room, there is no need to do this for the rows layout->setColStretch(4,1); layout->setColStretch(2,1); layout->setColStretch(6,1); layout->setColStretch(8,1); layout->setColStretch(0,1); //add the menu navigation buttons, and connect them to the RemoteTab slots... QPushButton *up = new QPushButton("Up",this,"up"); layout->addWidget(up, 0, 4, 0); connect(up, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *down = new QPushButton("Down",this,"down"); layout->addWidget(down, 4, 4, 0); connect(down, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *left = new QPushButton("Left",this,"left"); layout->addWidget(left, 2, 2, 0); connect(left, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *right = new QPushButton("Right", this, "right"); layout->addWidget(right, 2, 6, 0); connect(right, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *enter = new QPushButton("Enter",this,"enter"); layout->addWidget(enter, 2, 4, 0); connect(enter, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); //add some other buttons QPushButton *eject = new QPushButton("Eject", this, "eject"); layout->addWidget(eject, 0, 0, 0); connect(eject, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *menu = new QPushButton("Menu", this, "menu"); layout->addWidget(menu, 2, 0, 0); connect(menu, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *topMenu = new QPushButton("Top", this, "topMenu"); layout->addWidget(topMenu, 4, 0, 0); connect(topMenu, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *audio = new QPushButton("Audio", this, "audio"); layout->addWidget(audio, 0, 8, 0); connect(audio, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *sub = new QPushButton("Sub", this, "sub"); layout->addWidget(sub, 2, 8, 0); connect(sub, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *angle = new QPushButton("Angle", this, "angle"); layout->addWidget(angle, 4, 8, 0); connect(angle, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); } diff --git a/noncore/tools/remote/learntab.cpp b/noncore/tools/remote/learntab.cpp index 054bc7b..998f449 100644 --- a/noncore/tools/remote/learntab.cpp +++ b/noncore/tools/remote/learntab.cpp @@ -1,26 +1,26 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "learntab.h" -LearnTab::LearnTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) +LearnTab::LearnTab(QWidget *parent, const char *name):QWidget(parent,name) { QVBoxLayout *layout = new QVBoxLayout(this); QString *string = new QString("<qt><h1>Opie-Remote Usage Instructions</h1><p>First, some definitions. A Remote is a remote entry in an lircd.conf file, it represents one remote you want to emulate. A Remote Layout is one entry in your ~/Settings/Remote.conf file. It represents the buttons that you see on your screen. Each button on a Remote Layout can be mapped to any button in a Remote. This way you can have, for example, a vcr remote layout, in which all the play/pause/etc buttons are mapped to the buttons on your vcr's remote. However, most VCR's don't have volume controls, so the volume buttons can be mapped to the volume buttons on your TV.</p><p>The first things you need the lirc and lirc-modules ipkgs. If you installed this from an ipkg, they should already be there, thanks to the wonderful world of dependencies. If not, get them. The next thing you need is an lircd.conf file. you can get these at <a href=http://www.lirc.org/>http://www.lirc.org/</a>. Read the documentation there to figure out how to make your own, if one for your remote doesn't exist, or how to have multiple remotes in one lircd.conf file. Once you have a good lircd.conf file, put it in /etc, kill the lircd daemon (if its running) and do a modprobe lirc_sir. Then, run lircd again.</p><p>The next thing you want to do is to create a remote layout. Go to the config tab, and enter a name for your remote layout in the pulldown menu. Dont use the name Remotes, as that could confuse the app. Hopefully, that will be fixed soon. after entering the name you want to use, press New, and then select the name again from the pulldown menu (another oddity that i hope to fix). Then, press each button that you want to map, and a dialog should appear. Select the remote and button that you want to use, and click OK. Once you are done, go to the Remote tab, and select the new remote from the dropdown menu. It should works fine. If at any time you want to change a remote layout, go to the Config tab, select the layout from the dropdown menu, and change the buttons you want to change.</p><p>This is program is written and maintaned by Thomas (spiralman) Stephens. <a href=mailto:spiralman@softhome.net>spiralman@softhome.net</a>. Or, look for me on #opie or #handhelds.org on irc.openprojects.net.</p></qt>"); QTextView *textView = new QTextView(*string, 0, this); layout->addWidget(textView); } diff --git a/noncore/tools/remote/mainview.cpp b/noncore/tools/remote/mainview.cpp index 47027fb..a7be9e3 100644 --- a/noncore/tools/remote/mainview.cpp +++ b/noncore/tools/remote/mainview.cpp @@ -1,68 +1,68 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "mainview.h" -MainView::MainView(QWidget *parent, const char *name=0) : QWidget(parent, name) +MainView::MainView(QWidget *parent, const char *name) : QWidget(parent, name) { setIcon( Resource::loadPixmap( "remote" ) ); setCaption(tr("Remote") ); QVBoxLayout *layout = new QVBoxLayout(this); QTabWidget *tabs = new QTabWidget(this); layout->addWidget(tabs); printf("MainView: 1\n"); remote = new RemoteTab(tabs); printf("MainView: 2\n"); learn = new LearnTab(tabs); printf("MainView: 3\n"); config = new ConfigTab(tabs); printf("MainView: 4\n"); connect(config, SIGNAL(remotesChanged()), this, SLOT(updateRemotesList()) ); printf("MainView: 5\n"); remote->setIRSocket(fd); tabs->addTab(remote, tr("Remote") ); tabs->addTab(learn,tr("Learn") ); tabs->addTab(config,tr("Config") ); printf("1\n"); cfg = new Config("Remote"); printf("2\n"); remote->setConfig(cfg); config->setConfig(cfg); } int MainView::getIRSocket() { return fd; } void MainView::setIRSocket(int newfd) { fd = newfd; remote->setIRSocket(fd); } void MainView::updateRemotesList() { remote->updateRemotesList(); printf("MainView: got remotes changed signal\n"); } diff --git a/noncore/tools/remote/remotetab.cpp b/noncore/tools/remote/remotetab.cpp index 64b8ee4..5b02e94 100644 --- a/noncore/tools/remote/remotetab.cpp +++ b/noncore/tools/remote/remotetab.cpp @@ -1,263 +1,263 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "remotetab.h" -RemoteTab::RemoteTab(QWidget *parent=0, const char *name=0):QWidget(parent,name) +RemoteTab::RemoteTab(QWidget *parent, const char *name):QWidget(parent,name) { QVBoxLayout *layout = new QVBoxLayout(this); topGroup = new TopGroup(this); // topGroup->setMaximumHeight(22); layout->addWidget(topGroup, 0, 0); printf("%d %d", topGroup->width(), topGroup->height()); layout->addSpacing(1); dvdGroup = new DVDGroup(this); // dvdGroup->setMaximumHeight(68); layout->addWidget(dvdGroup, 0, 0); layout->addSpacing(1); vcrGroup = new VCRGroup(this); layout->addWidget(vcrGroup, 0, 0); // vcrGroup->setMaximumHeight(45); layout->addSpacing(1); channelGroup = new ChannelGroup(this); // channelGroup->setMaximumHeight(91); layout->addWidget(channelGroup, 0, 0); this->setMaximumWidth(240); timeout = 0; addr.sun_family=AF_UNIX; strcpy(addr.sun_path,"/dev/lircd"); } int RemoteTab::sendIR() { const QObject *button = sender(); QString string = cfg->readEntry(button->name()); string+='\n'; const char *write_buffer = string.latin1(); const char *read_buffer; bool done=false; fd = socket(AF_UNIX, SOCK_STREAM, 0); if(fd == -1) { QMessageBox *mb = new QMessageBox("Error!", "couldnt connect to socket", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("RemoteTab::SendIR"); - return NULL; + return 0; } - if(std::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) + if(::connect(fd,(struct sockaddr *) &addr, sizeof(addr) ) == -1) { QMessageBox *mb = new QMessageBox("Error!", "couldnt connect to socket", QMessageBox::NoIcon, QMessageBox::Ok, QMessageBox::NoButton, QMessageBox::NoButton); mb->exec(); perror("RemoteTab::SendIR"); } printf("fd2: %d\n", fd); printf("%s", write_buffer); printf("1\n"); printf("%d\n", write(fd, write_buffer, strlen(write_buffer) ) ); printf("2\n"); while(!done) { read_buffer=readPacket(); printf("%s\n", read_buffer); if(strcasecmp(read_buffer, "END") == 0) { printf("done reading packet\n"); done=true; } } - std::close(fd); + ::close(fd); } // printf("%s\n", readPacket()); // printf("%d\n", read(fd, read_buffer,sizeof(read_buffer)) ); // printf("%s", read_buffer); //this function was ripped for rc.c in xrc, it is available here: http://www.lirc.org/software.html const char *RemoteTab::readPacket() { static char buffer[PACKET_SIZE+1]=""; char *end; static int ptr=0,end_len=0; ssize_t ret; if(ptr>0) { memmove(buffer,buffer+ptr,strlen(buffer+ptr)+1); ptr=strlen(buffer); end=strchr(buffer,'\n'); } else { end=NULL; } alarm(TIMEOUT); while(end==NULL) { if(PACKET_SIZE<=ptr) { // fprintf(stderr,"%s: bad packet\n",progname); ptr=0; return(NULL); } ret=read(fd,buffer+ptr,PACKET_SIZE-ptr); if(ret<=0 || timeout) { if(timeout) { // fprintf(stderr,"%s: timeout\n",progname); } else { alarm(0); } ptr=0; return(NULL); } buffer[ptr+ret]=0; ptr=strlen(buffer); end=strchr(buffer,'\n'); } alarm(0);timeout=0; end[0]=0; ptr=strlen(buffer)+1; //# ifdef DEBUG // printf("buffer: -%s-\n",buffer); //# endif return(buffer); } void RemoteTab::setIRSocket(int newfd) { fd = newfd; } void RemoteTab::setConfig(Config *newCfg) { cfg = newCfg; cfg->setGroup("Remotes"); topGroup->updateRemotes(cfg); } void RemoteTab::remoteSelected(const QString &string) { printf("1%s\n", string.latin1() ); cfg->setGroup(string); const QObject *obj; const QObjectList *objList = topGroup->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } objList = dvdGroup->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } objList = vcrGroup->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } objList = channelGroup->children(); for(obj = ((QObjectList *)objList)->first(); obj != 0; obj=((QObjectList *)objList)->next()) { if(obj->inherits("QPushButton")) { if(cfg->hasKey((QString)obj->name()+"Label")) { ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); } else { cfg->setGroup("Default"); ((QPushButton *)obj)->setText(cfg->readEntry((QString)obj->name()+"Label") ); cfg->setGroup(string); } } } } void RemoteTab::updateRemotesList() { topGroup->updateRemotes(cfg); } diff --git a/noncore/tools/remote/topgroup.cpp b/noncore/tools/remote/topgroup.cpp index 94ea622..93cffbb 100644 --- a/noncore/tools/remote/topgroup.cpp +++ b/noncore/tools/remote/topgroup.cpp @@ -1,54 +1,54 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "topgroup.h" -TopGroup::TopGroup(QWidget *parent=0, const char *name=0):QWidget(parent,name) +TopGroup::TopGroup(QWidget *parent, const char *name):QWidget(parent,name) { QHBoxLayout *layout = new QHBoxLayout(this, 0, -1, 0); QPushButton *power = new QPushButton("Power",this,"power"); layout->addWidget(power); connect(power, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); // power->setGeometry(5, 5,40, 20); layout->addSpacing(5); QPushButton *source = new QPushButton("Source",this,"source"); layout->addWidget(source); connect(source, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); // source->setGeometry(50,5,40,20); remotes = new QComboBox(false, this, "remotes"); connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); remotes->insertItem("Select Remote"); // remotes->setGeometry(135,5,95,20); QLabel *remoteLabel = new QLabel(remotes, "Remote: ",this,"remoteLabel"); // remoteLabel->setGeometry(90,5,40,20); remoteLabel->setAlignment(AlignRight | AlignVCenter); layout->addWidget(remoteLabel); layout->addWidget(remotes); } void TopGroup::updateRemotes(Config *cfg) { remotes->clear(); remotes->insertItem(QString("SelectRemote")); cfg->setGroup("Remotes"); remotes->insertStringList(cfg->readListEntry("remoteList", ',') ); } diff --git a/noncore/tools/remote/topgroupconf.cpp b/noncore/tools/remote/topgroupconf.cpp index eb071fb..d763a3a 100644 --- a/noncore/tools/remote/topgroupconf.cpp +++ b/noncore/tools/remote/topgroupconf.cpp @@ -1,70 +1,70 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "topgroupconf.h" -TopGroupConf::TopGroupConf(QWidget *parent=0, const char *name=0):QWidget(parent,name) +TopGroupConf::TopGroupConf(QWidget *parent, const char *name):QWidget(parent,name) { QHBoxLayout *layout = new QHBoxLayout(this); QPushButton *power = new QPushButton("Power",this,"power"); layout->addWidget(power); connect(power, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); // power->setGeometry(5, 5,40, 20); layout->addSpacing(5); QPushButton *source = new QPushButton("Source",this,"source"); layout->addWidget(source); connect(source, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); // source->setGeometry(50,5,40,20); remotes = new QComboBox(true, this, "remotes"); remotes->insertItem(QString("Remotes")); layout->addWidget(remotes); layout->setStretchFactor(remotes, 1); connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); QPushButton *newrem = new QPushButton("New", this, "new"); layout->addWidget(newrem); connect(newrem, SIGNAL(pressed()), this->parentWidget(), SLOT(newPressed()) ); /* remotes = new QComboBox(false, this, "remotes"); connect(remotes, SIGNAL(activated(const QString &)), this->parentWidget(), SLOT(remoteSelected(const QString &)) ); remotes->insertItem("Select Remote"); // remotes->setGeometry(135,5,95,20); QLabel *remoteLabel = new QLabel(remotes, "Remote: ",this,"remoteLabel"); // remoteLabel->setGeometry(90,5,40,20); remoteLabel->setAlignment(AlignRight | AlignVCenter); layout->addWidget(remoteLabel); layout->addWidget(remotes); */ } void TopGroupConf::updateRemotes(QStringList list) { remotes->insertStringList(list); } QString TopGroupConf::getRemotesText() { return remotes->currentText(); } diff --git a/noncore/tools/remote/vcrgroup.cpp b/noncore/tools/remote/vcrgroup.cpp index 4f07ca3..10ebe5d 100644 --- a/noncore/tools/remote/vcrgroup.cpp +++ b/noncore/tools/remote/vcrgroup.cpp @@ -1,88 +1,88 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "vcrgroup.h" -VCRGroup::VCRGroup(QWidget *parent=0, const char *name=0) : QWidget(parent, +VCRGroup::VCRGroup(QWidget *parent, const char *name) : QWidget(parent, name) { QVBoxLayout *vlayout = new QVBoxLayout(this); QHBoxLayout *hlayout1 = new QHBoxLayout(this); QHBoxLayout *hlayout2 = new QHBoxLayout(this); vlayout->addLayout(hlayout1); vlayout->addSpacing(1); vlayout->addLayout(hlayout2); QPushButton *play = new QPushButton("Play",this, "play"); hlayout1->addWidget(play); connect(play, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); hlayout1->addSpacing(5); QPushButton *pause = new QPushButton("Pause",this, "pause"); hlayout1->addWidget(pause); connect(pause, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); hlayout1->addSpacing(5); QPushButton *stop = new QPushButton("Stop",this, "stop"); hlayout1->addWidget(stop); connect(stop, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); hlayout1->addSpacing(5); QPushButton *record = new QPushButton("Record",this, "record"); hlayout1->addWidget(record); connect(record, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); QPushButton *back = new QPushButton("Back",this, "back"); hlayout2->addWidget(back); connect(back, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); hlayout2->addSpacing(5); QPushButton *rewind = new QPushButton("Rewind",this, "rewind"); hlayout2->addWidget(rewind); connect(rewind, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); hlayout2->addSpacing(5); QPushButton *ff = new QPushButton("FF",this, "ff"); hlayout2->addWidget(ff); connect(ff, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); hlayout2->addSpacing(5); QPushButton *next = new QPushButton("Next",this, "next"); hlayout2->addWidget(next); connect(next, SIGNAL(pressed()), this->parentWidget(), SLOT(sendIR()) ); } diff --git a/noncore/tools/remote/vcrgroupconf.cpp b/noncore/tools/remote/vcrgroupconf.cpp index a50ed0a..2158d43 100644 --- a/noncore/tools/remote/vcrgroupconf.cpp +++ b/noncore/tools/remote/vcrgroupconf.cpp @@ -1,73 +1,73 @@ /* Opie-Remote. emulates remote controlls on an iPaq (and maybe a Zaurus) in Opie. Copyright (C) 2002 Thomas Stephens This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "vcrgroupconf.h" -VCRGroupConf::VCRGroupConf(QWidget *parent=0, const char *name=0) : QWidget(parent, name) +VCRGroupConf::VCRGroupConf(QWidget *parent, const char *name) : QWidget(parent, name) { QVBoxLayout *vlayout = new QVBoxLayout(this); QHBoxLayout *hlayout1 = new QHBoxLayout(this); QHBoxLayout *hlayout2 = new QHBoxLayout(this); vlayout->addLayout(hlayout1); vlayout->addSpacing(1); vlayout->addLayout(hlayout2); QPushButton *play = new QPushButton("Play",this, "play"); hlayout1->addWidget(play); connect(play, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); hlayout1->addSpacing(5); QPushButton *pause = new QPushButton("Pause",this, "pause"); hlayout1->addWidget(pause); connect(pause, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); hlayout1->addSpacing(5); QPushButton *stop = new QPushButton("Stop",this, "stop"); hlayout1->addWidget(stop); connect(stop, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); hlayout1->addSpacing(5); QPushButton *record = new QPushButton("Record",this, "record"); hlayout1->addWidget(record); connect(record, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); QPushButton *back = new QPushButton("Back",this, "back"); hlayout2->addWidget(back); connect(back, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); hlayout2->addSpacing(5); QPushButton *rewind = new QPushButton("Rewind",this, "rewind"); hlayout2->addWidget(rewind); connect(rewind, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); hlayout2->addSpacing(5); QPushButton *ff = new QPushButton("FF",this, "ff"); hlayout2->addWidget(ff); connect(ff, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); hlayout2->addSpacing(5); QPushButton *next = new QPushButton("Next",this, "next"); hlayout2->addWidget(next); connect(next, SIGNAL(pressed()), this->parentWidget(), SLOT(buttonPressed()) ); } diff --git a/noncore/unsupported/mail2/libmail/imaphandler.cpp b/noncore/unsupported/mail2/libmail/imaphandler.cpp index 730a004..7493240 100644 --- a/noncore/unsupported/mail2/libmail/imaphandler.cpp +++ b/noncore/unsupported/mail2/libmail/imaphandler.cpp @@ -1,343 +1,343 @@ #include "imapresponse.h" #include "imaphandler.h" #include "imapbase.h" IMAPHandler::IMAPHandler(const Account &account) : QObject(), _account(account) { _ready = false; _loggingin = false; _loggedin = false; _tag = 0; _ibase = new IMAPBase(account); connect(_ibase, SIGNAL(dataReceived(const QString &)), SLOT(slotDataReceived(const QString &))); connect(_ibase, SIGNAL(lookingUpHost()), SLOT(slotLookingUpHost())); connect(_ibase, SIGNAL(hostFound()), SLOT(slotHostFound())); connect(_ibase, SIGNAL(connected()), SLOT(slotConnected())); connect(_ibase, SIGNAL(disconnected()), SLOT(slotDisconnected())); connect(_ibase, SIGNAL(error(int)), SLOT(slotError(int))); } void IMAPHandler::doLogin() { if (_loggedin) return; if (_loggingin) return; _loggingin = true; iLogin(_account.user(), _account.pass()); } QString IMAPHandler::iCapability() { _ibase->sendCommand(QString("%1 CAPABILITY\r\n") .arg(tag())); return tag(false); } QString IMAPHandler::iNoop() { _ibase->sendCommand(QString("%1 NOOP\r\n") .arg(tag())); return tag(false); } QString IMAPHandler::iLogout() { _ibase->sendCommand(QString("%1 LOGOUT\r\n") .arg(tag())); return tag(false); } QString IMAPHandler::iAuthenticate(const QString &mechanism) { _ibase->sendCommand(QString("%1 AUTHENTICATE \"%2\"\r\n") .arg(tag()) .arg(escape(mechanism))); return tag(false); } QString IMAPHandler::iLogin(const QString &user, const QString &pass) { _ibase->sendCommand(QString("%1 LOGIN \"%2\" \"%3\"\r\n") .arg(tag()) .arg(escape(user)) .arg(escape(pass))); return tag(false); } QString IMAPHandler::iSelect(const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 SELECT \"%2\"\r\n") .arg(tag()) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iExamine(const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 EXAMINE \"%2\"\r\n") .arg(tag()) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iCreate(const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 CREATE \"%2\"\r\n") .arg(tag()) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iDelete(const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 DELETE \"%2\"\r\n") .arg(tag()) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iRename(const QString &mailbox, const QString &newMailbox) { doLogin(); _ibase->sendCommand(QString("%1 RENAME \"%2\" \"%3\"\r\n") .arg(tag()) .arg(escape(mailbox)) .arg(escape(newMailbox))); return tag(false); } QString IMAPHandler::iSubscribe(const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 SUBSCRIBE \"%2\"\r\n") .arg(tag()) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iUnsubscribe(const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 UNSUBSCRIBE \"%2\"\r\n") .arg(tag()) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iList(const QString &reference, const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 LIST \"%2\" \"%3\"\r\n") .arg(tag()) .arg(escape(reference)) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iLsub(const QString &reference, const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 LSUB \"%2\" \"%3\"\r\n") .arg(tag()) .arg(escape(reference)) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iStatus(const QString &mailbox, const QString &items) { doLogin(); _ibase->sendCommand(QString("%1 STATUS \"%2\" (%3)\r\n") .arg(tag()) .arg(escape(mailbox)) .arg(escape(items))); return tag(false); } -QString IMAPHandler::iAppend(const QString &mailbox, const QString &literal, const QString &flags, const QString &datetime = 0) +QString IMAPHandler::iAppend(const QString &mailbox, const QString &literal, const QString &flags, const QString &datetime) { doLogin(); _ibase->sendCommand(QString("%1 APPEND \"%2\" (%3) \"%4\" {%5}\r\n%6\r\n") .arg(tag()) .arg(escape(mailbox)) .arg(flags) .arg(escape(datetime)) .arg(literal.length()) .arg(literal)); return tag(false); } QString IMAPHandler::iCheck() { doLogin(); _ibase->sendCommand(QString("%1 CHECK\r\n") .arg(tag())); return tag(false); } QString IMAPHandler::iClose() { doLogin(); _ibase->sendCommand(QString("%1 CLOSE\r\n") .arg(tag())); return tag(false); } QString IMAPHandler::iExpunge() { doLogin(); _ibase->sendCommand(QString("%1 EXPUNGE\r\n") .arg(tag())); return tag(false); } QString IMAPHandler::iSearch(const QString &search, const QString &charset) { doLogin(); _ibase->sendCommand(QString("%1 SEARCH %2 %3\r\n") .arg(tag()) .arg(charset.isEmpty() ? QString(0) : escape(charset)) .arg(search)); return tag(false); } QString IMAPHandler::iFetch(const QString &message, const QString &items) { doLogin(); _ibase->sendCommand(QString("%1 FETCH %2 (%3)\r\n") .arg(tag()) .arg(message) .arg(items)); return tag(false); } QString IMAPHandler::iStore(const QString &message, const QString &items) { doLogin(); _ibase->sendCommand(QString("%1 STORE %2 %3\r\n") .arg(tag()) .arg(message) .arg(items)); return tag(false); } QString IMAPHandler::iCopy(const QString &message, const QString &mailbox) { doLogin(); _ibase->sendCommand(QString("%1 COPY %2 \"%3\"\r\n") .arg(tag()) .arg(message) .arg(escape(mailbox))); return tag(false); } QString IMAPHandler::iUid(const QString &command, const QString &arguments) { doLogin(); _ibase->sendCommand(QString("%1 UID %2 %3\r\n") .arg(tag()) .arg(command) .arg(arguments)); return tag(false); } QString IMAPHandler::iX(const QString &commandAtom, const QString &arguments) { doLogin(); _ibase->sendCommand(QString("%1 X%2 %3\r\n") .arg(tag()) .arg(commandAtom) .arg(arguments)); return tag(false); } QString IMAPHandler::escape(const QString &in) { QString in_ = in; return in_.replace(QRegExp("\""), "\\\""); } QString IMAPHandler::tag(bool count) { return QString("a%1").arg(count ? _tag++ : _tag); } void IMAPHandler::slotDataReceived(const QString &data) { if (!_ready) { // The first data is always the greeting string. // We can ignore it. _ready = true; return; } IMAPResponseParser parser(data); IMAPResponse response = parser.response(); response.setImapHandler(this); if (!_loggingin) emit gotResponse(response); else { if (response.statusResponse().status() == IMAPResponseEnums::OK) { _loggingin = false; _loggedin = true; qWarning("OK. Logged in. Leaving loggingin state."); } else { _loggingin = false; emit IMAPError(IMAPBase::IMAPErrLoginFailed); } } } void IMAPHandler::slotLookingUpHost() { emit IMAPLookingUpHost(); } void IMAPHandler::slotHostFound() { emit IMAPHostFound(); } void IMAPHandler::slotConnected() { emit IMAPConnected(); } void IMAPHandler::slotDisconnected() { _loggedin = false; emit IMAPDisconnected(); } void IMAPHandler::slotError(int err) { emit IMAPError(err); } diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 7df1d6b..05f2f06 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -1,226 +1,226 @@ // adadpted form qpe/qipkg #include "mainwindow.h" #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> #include <qpe/qcopenvelope_qws.h> #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> #include <qlistview.h> #include <qtextview.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qlayout.h> #include "pksettingsbase.h" #include "utils.h" #include "packagelistitem.h" -MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : +MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : QMainWindow( parent, name, f ) // packageListServers( QObject(parent), name ), // packageListSearch( parent, name ), // packageListDocLnk( parent, name ) { setCaption( tr("Package Manager") ); settings = new PackageManagerSettings(this,0,TRUE); listViewPackages = new PackageListView( this,"listViewPackages",settings ); setCentralWidget( listViewPackages ); listViewPackages->addList( tr("feeds"), &packageListServers ); listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); //listViewPackages->addList( tr("documents"), &packageListDocLnk ); ipkg = new PmIpkg( settings, this ); packageListServers.setSettings( settings ); packageListSearch.setSettings( settings ); packageListDocLnk.setSettings( settings ); pvDebug(9,"packageListServers.update"); packageListServers.update(); pvDebug(9,"packageListDocLnk.update"); pvDebug(0,"no UPDATE of DocLnk"); // packageListDocLnk.update(); pvDebug(9,"makeMenu"); makeMenu(); makeChannel(); //opie is hardcoded default ;) // pvDebug(9,"section->setCurrentItem"); // for (int i=0;i<section->count();i++) // if (section->text(i)=="opie") // section->setCurrentItem(i); // sectionChanged(); connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); connect( settings->removeLinksButton, SIGNAL( clicked()), SLOT(removeLinks()) ); connect( settings->createLinksButton, SIGNAL( clicked()), SLOT(createLinks()) ); pvDebug(9,"displayList"); displayList(); } void MainWindow::makeMenu() { QPEToolBar *toolBar = new QPEToolBar( this ); QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *srvMenu = new QPopupMenu( menuBar ); QPopupMenu *viewMenu = new QPopupMenu( menuBar ); QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); QPopupMenu *helpMenu = new QPopupMenu( menuBar ); setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); menuBar->insertItem( tr( "Package" ), srvMenu ); menuBar->insertItem( tr( "View" ), viewMenu ); menuBar->insertItem( tr( "Settings" ), cfgMenu ); menuBar->insertItem( tr( "Help" ), helpMenu ); QLabel *spacer; // spacer = new QLabel( "", toolBar ); // spacer->setBackgroundColor( toolBar->backgroundColor() ); // toolBar->setStretchableWidget( spacer ); runAction = new QAction( tr( "Apply" ), Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); connect( runAction, SIGNAL( activated() ), this, SLOT( runIpkg() ) ); runAction->addTo( toolBar ); runAction->addTo( srvMenu ); srvMenu->insertSeparator(); updateAction = new QAction( tr( "Update" ), Resource::loadIconSet( "oipkg/update" ), QString::null, 0, this, 0 ); connect( updateAction, SIGNAL( activated() ), this , SLOT( updateList() ) ); updateAction->addTo( toolBar ); updateAction->addTo( srvMenu ); QAction *cfgact; cfgact = new QAction( tr( "Setups" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettings() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Servers" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsSrv() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsDst() ) ); cfgact->addTo( cfgMenu ); QAction *a; // SECTIONS sectionBar = new QPEToolBar( this ); addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); sectionBar->setHorizontalStretchable( true ); QLabel *label = new QLabel( tr("Section: "), sectionBar ); label->setBackgroundColor( sectionBar->backgroundColor() ); section = new QComboBox( false, sectionBar ); label = new QLabel( " / ", sectionBar ); label->setBackgroundColor( sectionBar->backgroundColor() ); subsection = new QComboBox( false, sectionBar ); a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); a->addTo( sectionBar ); setSections(); setSubSections(); sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); sectionAction->setToggleAction( true ); sectionAction->addTo( viewMenu ); sectionBar->setStretchableWidget( section ); //FIND findBar = new QPEToolBar(this); addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); label = new QLabel( tr("Filter: "), findBar ); label->setBackgroundColor( findBar->backgroundColor() ); findBar->setHorizontalStretchable( TRUE ); findEdit = new QLineEdit( findBar, "findEdit" ); findBar->setStretchableWidget( findEdit ); connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( displayList() ) ); a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); a->addTo( findBar ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); a->addTo( findBar ); findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); findAction->setToggleAction( true ); findAction->addTo( viewMenu ); //SEARCH searchBar = new QPEToolBar(this); addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); label = new QLabel( tr("ipkgfind: "), searchBar ); label->setBackgroundColor( searchBar->backgroundColor() ); searchBar->setHorizontalStretchable( TRUE ); searchEdit = new QLineEdit( searchBar, "seachEdit" ); searchBar->setStretchableWidget( searchEdit ); // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), // this, SLOT( displayList() ) ); a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); a->addTo( searchBar ); searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); searchCommit->addTo( searchBar ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); a->addTo( searchBar ); searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); searchAction->setToggleAction( true ); searchAction->addTo( viewMenu ); //DEST destBar = new QPEToolBar(this); addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); label = new QLabel( tr("Destination: "), destBar ); label->setBackgroundColor( destBar->backgroundColor() ); destBar->setHorizontalStretchable( TRUE ); destination = new QComboBox( false, destBar ); destination->insertStringList( settings->getDestinationNames() ); setComboName(destination,settings->getDestinationName()); connect( destination, SIGNAL(activated(int)), settings, SLOT(activeDestinationChange(int)) ); spacer = new QLabel( " ", destBar ); spacer->setBackgroundColor( destBar->backgroundColor() ); CheckBoxLink = new QCheckBox( tr("Link"), destBar); CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); CheckBoxLink->setChecked( settings->createLinks() ); connect( CheckBoxLink, SIGNAL(toggled(bool)), settings, SLOT(linkEnabled(bool)) ); destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 97f7813..517b37a 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp @@ -1,261 +1,261 @@ #include "package.h" #include <qpe/process.h> #include <qpe/stringutil.h> #include <qfile.h> #include <qtextstream.h> #include <stdlib.h> #include <unistd.h> #include "debug.h" -Package::Package( QObject *parent=0, const char *name=0 ) +Package::Package( QObject *parent, const char *name ) : QObject(parent,name) { } Package::~Package() { } -Package::Package( PackageManagerSettings *s, QObject *parent=0, const char *name=0 ) +Package::Package( PackageManagerSettings *s, QObject *parent, const char *name ) : QObject(parent,name) { Package(parent,name); init(s); } void Package::init( PackageManagerSettings *s ) { settings = s; _size = ""; _section = ""; _subsection = ""; _shortDesc = ""; _desc = ""; _name = ""; _toProcess = false; _useFileName = false; _old = false; _status = ""; _dest = settings->getDestinationName(); _link = settings->createLinks(); _versions=0; _version=""; } -Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent=0, const char *name=0 ) +Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) : QObject(parent,name) { init(s); parsePackage( pack ); } -Package::Package( QString n, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ) +Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) { init(s); if ( !QFile::exists( n ) ) { _name = QString( n ); }else{ pvDebug(4,"remote file: "+n); parseIpkgFile( n ); _useFileName = true; _fileName = QString( n ); } } -Package::Package( Package *pi, QObject *parent=0, const char *name=0 ) +Package::Package( Package *pi, QObject *parent, const char *name ) { init(pi->settings); copyValues( pi ); } void Package::setValue( QString n, QString t ) { if ( n == "Package" ) { _name = QString( t ); }else if ( n == "Installed-Size" ) { _size = t; // }else if ( n == "Priority") // { }else if ( n == "Section") { setSection( t ); // }else if ( n == "Maintainer") // { // // }else if ( n == "Architecture") // { }else if ( n == "Version") { _version = t; // }else if ( n == "Pre-Depends") // { // // }else if ( n == "Depends") // { }else if ( n == "Filename") { _fileName = t; // }else if ( n == "Size") // { // // }else if ( n == "MD5Sum") // { }else if ( n == "Description") { setDesc( t ); }else if ( n == "Status") { if ( installed() ) return; _status = t; // }else if ( n == "Essential") // { }else{ _values.insert(n,new QString(t)); } } QString Package::name() { if (_displayName.isEmpty() ) return _name; else return _displayName; } QString Package::installName() { if (_useFileName) return _fileName; else return _name; } bool Package::installed() { if (_status.contains("installed")) { if (_status.contains("not-installed")) { _toProcess = true; return false; } else return true; } else if (_versions) { QDictIterator<Package> other( *_versions ); while ( other.current() ) { if (other.current()->status().contains("installed") && other.current()->version() == version()) return true; ++other; } } return false; } bool Package::otherInstalled() { if (_versions) { QDictIterator<Package> other( *_versions ); while ( other.current() ) { if (other.current()->installed()) return true; ++other; } } return false; } void Package::setDesc( QString s ) { _desc = s; _shortDesc = s.left( s.find("\n") ); } QString Package::desc() { return _desc; } QString Package::shortDesc() { return _shortDesc; } QString Package::size() { return _size; } QString Package::version() { return _version; } QString Package::sizeUnits() { int i = _size.toInt(); int c = 0; QString ret; QStringList unit; unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) while (i > 1) { ret=QString::number(i)+" "+unit[c]; c++; i /= 1024; } return ret; } bool Package::toProcess() { return _toProcess; } bool Package::toRemove() { if ( _toProcess && installed() ) return true; else return false; } bool Package::toInstall() { if ( _toProcess && !installed() ) return true; else return false; } void Package::toggleProcess() { _toProcess = ! _toProcess; } void Package::copyValues( Package* pack ) { if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index 3cc0443..e445570 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp @@ -1,221 +1,221 @@ #include "packagelist.h" #include <assert.h> #include <qfile.h> #include <qfileinfo.h> #include <qtextstream.h> #include "debug.h" static QDict<Package> *packageListAll; static int packageListAllRefCount = 0; -PackageList::PackageList(QObject *parent=0, const char *name=0) +PackageList::PackageList(QObject *parent, const char *name) : QObject(parent,name), packageIter( packageList ) { empty=true; if (!packageListAll) packageListAll = new QDict<Package>(); packageListAllRefCount++; sections << "All"; subSections.insert("All", new QStringList() ); QStringList *ss = subSections["All"]; *ss << "All"; aktSection = "All"; aktSubSection = "All"; } PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) : QObject(parent,name), packageIter( packageList ) { settings = s; PackageList(parent, name); } PackageList::~PackageList() { if (--packageListAllRefCount < 1 ) delete packageListAll; } /** Inserts a package into the list */ void PackageList::insertPackage( Package* pack ) { if (!pack) return; Package* p = packageListAll->find( pack->name() ); if ( p ) { if ( (p->version() == pack->version()) // && (p->dest() == pack->dest()) ) { p->copyValues( pack ); delete pack; pack = p; } else { QDict<Package> *packver = p->getOtherVersions(); // p->setName( pack->name()+"["+p->version()+"]" ); if (!packver) { packver = new QDict<Package>(); packver->insert( pack->name(), p ); p->setOtherVersions( packver ); } pack->setName( pack->name()+"["+pack->version()+"]" ); pack->setOtherVersions( packver ); packver->insert( pack->name(), pack ); packageListAll->insert( pack->name(), pack ); packageList.insert( pack->name(), pack ); origPackageList.insert( pack->name(), pack ); } }else{ packageListAll->insert( pack->name(), pack ); packageList.insert( pack->name(), pack ); origPackageList.insert( pack->name(), pack ); }; empty=false; updateSections( pack ); } void PackageList::filterPackages( QString f ) { packageList.clear(); QDictIterator<Package> filterIter( origPackageList ); filterIter.toFirst(); Package *pack= filterIter.current() ; while ( pack ) { if ( ((aktSection=="All")||(pack->section()==aktSection)) && ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) && pack->name().contains( f ) ) { packageList.insert( pack->name(), pack ); } ++filterIter; pack = filterIter.current(); } } Package* PackageList::find( QString n ) { return packageList.find( n ); } Package* PackageList::first() { packageIter.toFirst(); return packageIter.current(); } Package* PackageList::next() { ++packageIter; return packageIter.current(); } QStringList PackageList::getSections() { sections.sort(); return sections; } QStringList PackageList::getSubSections() { QStringList ss; if ( !subSections[aktSection] ) return ss; ss = *subSections[aktSection]; ss.sort(); return ss; } void PackageList::setSection( QString sec ) { aktSection = sec; } void PackageList::setSubSection( QString ssec ) { aktSubSection = ssec; } void PackageList::updateSections( Package* pack ) { QString s = pack->section(); if ( s.isEmpty() || s == "") return; if ( sections.contains(s) ) return; sections += s; QString ss = pack->subSection(); if ( ss.isEmpty() || ss == "" ) return; if ( !subSections[s] ) { subSections.insert( s, new QStringList() ); QStringList *subsecs = subSections[s]; *subsecs += "All"; } QStringList *subsecs = subSections[s]; *subsecs += ss; if ( !subSections["All"] ) subSections.insert( "All", new QStringList() ); subsecs = subSections["All"]; *subsecs += ss; } void PackageList::readFileEntries( QString filename, QString dest ) { pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+dest); QStringList packEntry; QFile f( filename ); if ( !f.open(IO_ReadOnly) ) return; QTextStream *statusStream = new QTextStream( &f ); while ( !statusStream ->eof() ) { QString line = statusStream->readLine(); if ( line.find(QRegExp("[\n\t ]*")) || line == "" ) { //end of package if ( ! packEntry.isEmpty() ) { Package *p = new Package( packEntry, settings ); if ( p ) { p->setDest( dest ); insertPackage( p ); packEntry.clear(); } } }else{ packEntry << line; }; } delete statusStream; return; } void PackageList::setSettings( PackageManagerSettings *s ) { settings = s; } Package* PackageList::getByName( QString n ) { - origPackageList[n]; + return origPackageList[n]; } void PackageList::clear() { origPackageList.clear(); packageList.clear(); } void PackageList::allPackages() { packageList.clear(); QDictIterator<Package> filterIter( origPackageList ); filterIter.toFirst(); Package *pack= filterIter.current() ; while ( pack ) { packageList.insert( pack->name(), pack ); ++filterIter; pack = filterIter.current(); } } diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.cpp b/noncore/unsupported/oipkg/packagelistdoclnk.cpp index b42cfdd..deb8a6d 100644 --- a/noncore/unsupported/oipkg/packagelistdoclnk.cpp +++ b/noncore/unsupported/oipkg/packagelistdoclnk.cpp @@ -1,45 +1,45 @@ #include "packagelistdoclnk.h" #include <qpe/applnk.h> #include <qpe/config.h> #include <qlist.h> #include "package.h" #include "pksettings.h" -PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s, QObject *parent=0, const char *name=0) +PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s, QObject *parent, const char *name) : PackageList(s) { PackageListDocLnk(parent, name); } -PackageListDocLnk::PackageListDocLnk(QObject *parent=0, const char *name=0) +PackageListDocLnk::PackageListDocLnk(QObject *parent, const char *name) : PackageList(parent, name) { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); docLnkDir = cfg.readEntry( "docLnkDir", "/root/" ); pvDebug(2,"opening DocLnkSet "+docLnkDir); doclnkset = new DocLnkSet(docLnkDir,"application/ipkg"); } PackageListDocLnk::~PackageListDocLnk() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); cfg.writeEntry( "docLnkDir", docLnkDir ); delete doclnkset; } void PackageListDocLnk::update() { pvDebug(2,"PackageListDocLnk::update "); QList<DocLnk> packlist = doclnkset->children(); for (DocLnk *pack =packlist.first(); pack != 0; pack=packlist.next() ) { insertPackage( new Package(pack->file(), settings ) ); } } diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 0c9c676..7c54441 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp @@ -1,166 +1,166 @@ #include "packagelistitem.h" #include <qpe/resource.h> #include <qobject.h> #include "debug.h" static QPixmap *pm_uninstalled=0; static QPixmap *pm_uninstalled_old=0; static QPixmap *pm_installed=0; static QPixmap *pm_installed_old=0; static QPixmap *pm_uninstall=0; static QPixmap *pm_install=0; static QPixmap *pm_uninstalled_old_installed_new=0; static QPixmap *pm_uninstalled_installed_old=0; PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) : QCheckListItem(lv,pi->name(),CheckBox) { init(pi,s); } PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) : QCheckListItem(lvi,pi->name(),CheckBox) { init(pi,s); } void PackageListItem::init( Package *pi, PackageManagerSettings *s) { package = pi; settings = s; setExpandable( true ); QCheckListItem *item; nameItem = new QCheckListItem( this, "" ); item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() ); item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); destItem = new QCheckListItem( this, "" ); linkItem = new QCheckListItem( this, "" ); statusItem = new QCheckListItem( this, "" ); QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") ); item = new QCheckListItem( otherItem, QObject::tr("Install Name: ")+pi->installName() ); QDict<QString> *fields = pi->getFields(); QDictIterator<QString> it( *fields ); while ( it.current() ) { item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) ); ++it; } displayDetails(); if (!pm_uninstalled) { pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); pm_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld")); pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew")); pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld")); pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld")); pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); } } void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, int column, int width, int alignment ) { if ( !p ) return; p->fillRect( 0, 0, width, height(), isSelected()? cg.highlight() : cg.base() ); if ( column != 0 ) { // The rest is text QListViewItem::paintCell( p, cg, column, width, alignment ); return; } QListView *lv = listView(); if ( !lv ) return; int marg = lv->itemMargin(); int r = marg; QPixmap pm = statePixmap(); p->drawPixmap(marg,(height()-pm.height())/2,pm); r += pm.width()+1; p->translate( r, 0 ); QListViewItem::paintCell( p, cg, column, width - r, alignment ); } void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, const QRect & r ) { // Skip QCheckListItem // (makes you wonder what we're getting from QCheckListItem) QListViewItem::paintFocus(p,cg,r); } QPixmap PackageListItem::statePixmap() const { bool installed = package->installed(); bool old = package->isOld(); bool versions = package->hasVersions(); bool verinstalled = package->otherInstalled(); if ( !package->toProcess() ) { if ( !installed ) if (old) { if (verinstalled) return *pm_uninstalled_old_installed_new; else return *pm_uninstalled_old; } else { if (verinstalled) return *pm_uninstalled_installed_old; else return *pm_uninstalled; } else if (old) return *pm_installed_old; else return *pm_installed; } else { //toProcess() == true if ( !installed ) return *pm_install; else return *pm_uninstall; } } QString PackageListItem::key( int column, bool ascending ) const { if ( column == 2 ) { QString t = text(2); double bytes=t.toDouble(); if ( t.contains('M') ) bytes*=1024*1024; else if ( t.contains('K') || t.contains('k') ) bytes*=1024; if ( !ascending ) bytes=999999999-bytes; return QString().sprintf("%09d",(int)bytes); } else { return QListViewItem::key(column,ascending); } } void PackageListItem::setOn( bool b ) { QCheckListItem::setOn( b ); package->toggleProcess(); package->setLink( settings->createLinks() ); displayDetails(); } void PackageListItem::displayDetails() { QString sod; sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); setText(0, package->name()+sod ); nameItem->setText( 0, QObject::tr("Name: ")+package->name()); - linkItem->setText( 0, QObject::tr("Link: ")+package->link()?QObject::tr("Yes"):QObject::tr("No")); + linkItem->setText( 0, QObject::tr("Link: ")+(package->link()?QObject::tr("Yes"):QObject::tr("No"))); destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); repaint(); } diff --git a/noncore/unsupported/qpdf/fixed.h b/noncore/unsupported/qpdf/fixed.h index d073421..ec0e696 100644 --- a/noncore/unsupported/qpdf/fixed.h +++ b/noncore/unsupported/qpdf/fixed.h @@ -1,191 +1,191 @@ #ifndef __FIXED_H__ #define __FIXED_H__ #include <iostream> #define _GCC_TEMPLATE_BUG_ 1 template <unsigned int SH> class fixed { public: inline fixed ( int i = 0 ) : m_f ( i2f( i ) ) { } inline fixed ( double d ) : m_f ( d2f( d )) { } inline fixed ( const fixed &f ) : m_f ( f. m_f ) { } inline operator bool ( ) const { return m_f != 0; } inline operator double ( ) const { return f2d( m_f ); } inline operator float ( ) const { return (float) f2d( m_f ); } inline operator int ( ) const { return (int) f2i( m_f ); } inline fixed &operator = ( const fixed &f ) { m_f = f. m_f; return *this; } inline fixed &operator = ( double d ) { m_f = d2f( d ); return *this; } inline fixed &operator = ( float f ) { m_f = d2f( f ); return *this; } inline fixed &operator = ( int i ) { m_f = i2f( i ); return *this; } inline fixed &operator += ( const fixed &f ) { m_f += f. m_f; return *this; } inline fixed &operator -= ( const fixed &f ) { m_f -= f. m_f; return *this; } inline fixed &operator *= ( const fixed &f ) { m_f = mul ( m_f, f. m_f ); return *this; } inline fixed &operator /= ( const fixed &f ) { m_f = div ( m_f, f. m_f ); return *this; } inline fixed &operator += ( int i ) { m_f += i2f( i ); return *this; } inline fixed &operator -= ( int i ) { m_f -= i2f( i ); return *this; } inline fixed &operator *= ( int i ) { m_f *= i; return *this; } inline fixed &operator /= ( int i ) { m_f /= i; return *this; } inline fixed &operator += ( double d ) { m_f += d2f( d ); return *this; } inline fixed &operator -= ( double d ) { m_f -= d2f( d ); return *this; } inline fixed &operator *= ( double d ) { m_f = mul ( m_f, d2f( d )); return *this; } inline fixed &operator /= ( double d ) { m_f = div ( m_f, d2f( d )); return *this; } inline fixed operator - ( ) const { return fixed ( -m_f, true ); } inline fixed operator + ( const fixed &f ) const { return fixed ( m_f + f. m_f, true ); } inline fixed operator - ( const fixed &f ) const { return fixed ( m_f - f. m_f, true ); } inline fixed operator * ( const fixed &f ) const { return fixed ( mul ( m_f, f. m_f ), true ); } inline fixed operator / ( const fixed &f ) const { return fixed ( div ( m_f, f. m_f ), true ); } inline fixed operator + ( double d ) const { return fixed ( m_f + d2f( d ), true ); } inline fixed operator - ( double d ) const { return fixed ( m_f - d2f( d ), true ); } inline fixed operator * ( double d ) const { return fixed ( mul ( m_f, d2f( d )), true ); } inline fixed operator / ( double d ) const { return fixed ( div ( m_f, d2f( d )), true ); } inline fixed operator + ( int i ) const { return fixed ( m_f + i2f( i ), true ); } inline fixed operator - ( int i ) const { return fixed ( m_f - i2f( i ), true ); } inline fixed operator * ( int i ) const { return fixed ( m_f * i, true ); } inline fixed operator / ( int i ) const { return fixed ( m_f / i, true ); } inline bool operator < ( const fixed &f ) const { return m_f < f. m_f; } inline bool operator > ( const fixed &f ) const { return m_f > f. m_f; } inline bool operator <= ( const fixed &f ) const { return m_f <= f. m_f; } inline bool operator >= ( const fixed &f ) const { return m_f >= f. m_f; } inline bool operator == ( const fixed &f ) const { return m_f == f. m_f; } inline bool operator != ( const fixed &f ) const { return m_f != f. m_f; } inline bool operator < ( double d ) const { return m_f < d2f( d ); } inline bool operator > ( double d ) const { return m_f > d2f( d ); } inline bool operator <= ( double d ) const { return m_f <= d2f( d ); } inline bool operator >= ( double d ) const { return m_f >= d2f( d ); } inline bool operator == ( double d ) const { return m_f == d2f( d ); } inline bool operator != ( double d ) const { return m_f != d2f( d ); } inline bool operator < ( int i ) const { return m_f < i2f( i ); } inline bool operator > ( int i ) const { return m_f > i2f( i ); } inline bool operator <= ( int i ) const { return m_f <= i2f( i ); } inline bool operator >= ( int i ) const { return m_f >= i2f( i ); } inline bool operator == ( int i ) const { return m_f == i2f( i ); } inline bool operator != ( int i ) const { return m_f != i2f( i ); } #if _GCC_TEMPLATE_BUG_ public: #else private: #endif typedef int fix_t; inline static double f2d ( fix_t f ) { return ((double) f ) / ((double) ( 1 << SH )); } inline static fix_t d2f ( double d ) { return (fix_t) ( d * ((double) ( 1 << SH ))); } inline static int f2i ( fix_t f ) { return (int) ( f >> SH ); } inline static fix_t i2f ( int i ) { return (fix_t) ( i << SH ); } inline static fix_t mul ( fix_t m1, fix_t m2 ) { return (fix_t) ((((long long int) m1 ) * m2 ) >> SH ); } inline static fix_t div ( fix_t d1, fix_t d2 ) { return (fix_t) ((((long long int) d1 ) << SH ) / d2 ); } fixed ( fix_t f, bool /*dummy*/ ) : m_f ( f ) { } //data fix_t m_f; // friends: #if !_GCC_TEMPLATE_BUG_ friend fixed operator + <> ( int i, const fixed &f ); friend fixed operator - <> ( int i, const fixed &f ); friend fixed operator * <> ( int i, const fixed &f ); friend fixed operator / <> ( int i, const fixed &f ); friend fixed operator + <> ( double d, const fixed &f ); friend fixed operator - <> ( double d, const fixed &f ); friend fixed operator * <> ( double d, const fixed &f ); friend fixed &operator / <> ( double d, const fixed<SH> &f ); friend bool operator < <> ( double d, const fixed &f ); friend bool operator > <> ( double d, const fixed &f ); friend bool operator <= <> ( double d, const fixed &f ); friend bool operator >= <> ( double d, const fixed &f ); friend bool operator == <> ( double d, const fixed &f ); friend bool operator != <> ( double d, const fixed &f ); friend bool operator < <> ( int i, const fixed &f ); friend bool operator > <> ( int i, const fixed &f ); friend bool operator <= <> ( int i, const fixed &f ); friend bool operator >= <> ( int i, const fixed &f ); friend bool operator == <> ( int i, const fixed &f ); friend bool operator != <> ( int i, const fixed &f ); friend long int lrint ( const fixed &f ); friend fixed sqrt ( const fixed &f ); friend fixed fabs ( const fixed &f ); #endif }; template <unsigned int SH> inline fixed<SH> operator + ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) + f. m_f, true ); } template <unsigned int SH> inline fixed<SH> operator - ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f( i ) - f. m_f, true ); } template <unsigned int SH> inline fixed<SH> operator * ( int i, const fixed<SH> &f ) { return fixed<SH> ( i * f. m_f, true ); } template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::div ( fixed<SH>::i2f( i ), f. m_f ), true ); } //template <unsigned int SH> inline fixed<SH> operator / ( int i, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::i2f ( i / fixed<SH>::f2i ( f. m_f )), true ); } template <unsigned int SH> inline fixed<SH> operator + ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) + f. m_f, true ); } template <unsigned int SH> inline fixed<SH> operator - ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::d2f( d ) - f. m_f, true ); } template <unsigned int SH> inline fixed<SH> operator * ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } template <unsigned int SH> inline fixed<SH> operator / ( double d, const fixed<SH> &f ) { return fixed<SH> ( fixed<SH>::mul ( fixed<SH>::d2f( d ), f. m_f ), true ); } template <unsigned int SH> inline bool operator < ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) < f. m_f; } template <unsigned int SH> inline bool operator > ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) > f. m_f; } template <unsigned int SH> inline bool operator <= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) <= f. m_f; } template <unsigned int SH> inline bool operator >= ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) >= f. m_f; } template <unsigned int SH> inline bool operator == ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) == f. m_f; } template <unsigned int SH> inline bool operator != ( double d, const fixed<SH> &f ) { return fixed<SH>::d2f( d ) != f. m_f; } template <unsigned int SH> inline bool operator < ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) < f. m_f; } template <unsigned int SH> inline bool operator > ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) > f. m_f; } template <unsigned int SH> inline bool operator <= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) <= f. m_f; } template <unsigned int SH> inline bool operator >= ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) >= f. m_f; } template <unsigned int SH> inline bool operator == ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) == f. m_f; } template <unsigned int SH> inline bool operator != ( int i, const fixed<SH> &f ) { return fixed<SH>::i2f( i ) != f. m_f; } template <unsigned int SH> inline long int lrint ( const fixed<SH> &f ) { return fixed<SH>::f2i (( f. m_f < 0 ) ? f. m_f - ( 1 << ( SH - 1 )) : f. m_f + ( 1 << ( SH - 1 ))); } template <unsigned int SH> inline fixed<SH> fabs ( const fixed<SH> &f ) { return ( f. m_f < 0 ) ? fixed<SH> ( -f. m_f, true ) : f; } // roughly from QPE / qmath.h template <unsigned int SH> inline fixed<SH> sqrt ( const fixed<SH> &f ) { if ( f. m_f <= 0 ) return fixed<SH> ( 0, true ); - fixed<SH>::fix_t a0 = 0; - fixed<SH>::fix_t a1 = f. m_f; // take value as first approximation + typename fixed<SH>::fix_t a0 = 0; + typename fixed<SH>::fix_t a1 = f. m_f; // take value as first approximation do { a0 = a1; a1 = ( a0 + fixed<SH>::div ( f. m_f, a0 )) >> 1; } while ( abs ( fixed<SH>::div ( a1 - a0, a1 )) > 1 ); return fixed<SH> ( a1, true ); } #if 0 // no std::ostream needed in OPIE template <unsigned int SH> inline std::ostream &operator << ( std::ostream &o, const fixed<SH> &f ) { o << double( f ); return o; } #endif #endif |