author | zecke <zecke> | 2004-03-14 16:13:28 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 16:13:28 (UTC) |
commit | f3d284849df36ef281dcb5aa2d00f613e3a354d8 (patch) (side-by-side diff) | |
tree | 65406b10a839ffa1ba683f59e61ef7227a0093d1 | |
parent | f12af18557c8f376f0c6c30e80a85737ff6c592e (diff) | |
download | opie-f3d284849df36ef281dcb5aa2d00f613e3a354d8.zip opie-f3d284849df36ef281dcb5aa2d00f613e3a354d8.tar.gz opie-f3d284849df36ef281dcb5aa2d00f613e3a354d8.tar.bz2 |
Fix up depends on LIBOPIE1
Proper signature for signal and slots and namespaces
22 files changed, 41 insertions, 46 deletions
diff --git a/noncore/applets/notesapplet/config.in b/noncore/applets/notesapplet/config.in index 866adfb..27a8187 100644 --- a/noncore/applets/notesapplet/config.in +++ b/noncore/applets/notesapplet/config.in @@ -1,4 +1,4 @@ config NOTESAPPLET boolean "opie-notesapplet (quick note taking applet)" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE + depends ( LIBQPE || LIBQPE-X11 ) diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index a694b70..6d41ac3 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp @@ -324,515 +324,515 @@ void AdvancedFm::copy() { tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) );
return;
}
}
setOtherTabCurrent();
rePopulate();
}
}
void AdvancedFm::copyAs() {
qApp->processEvents();
QStringList curFileList = getPath();
QString curFile, item;
InputDialog *fileDlg;
QDir *thisDir = CurrentDir();
QDir *thatDir = OtherDir();
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString destFile;
item=(*it);
curFile = thisDir->canonicalPath()+"/"+(*it);
fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
fileDlg->setInputText((const QString &) destFile );
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
destFile = thatDir->canonicalPath()+"/"+filename;
QFile f( destFile);
if( f.exists()) {
switch (QMessageBox::warning(this,tr("File Exists!"),
item+tr("\nexists. Ok to overwrite?"),
tr("Yes"),tr("No"),0,0,1) ) {
case 0:
f.remove();
break;
case 1:
return;
break;
};
}
if( !copyFile( curFile, destFile) ) {
QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+curFile +tr("to\n")+destFile);
return;
}
}
delete fileDlg;
}
rePopulate();
setOtherTabCurrent();
}
void AdvancedFm::copySameDir() {
qApp->processEvents();
QStringList curFileList = getPath();
QString curFile, item, destFile;
InputDialog *fileDlg;
QDir *thisDir = CurrentDir();
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item=(*it);
curFile = thisDir->canonicalPath()+"/"+ item;
fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
fileDlg->setInputText((const QString &) destFile );
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
destFile = thisDir->canonicalPath()+"/"+filename;
QFile f(destFile);
if( f.exists()) {
switch (QMessageBox::warning(this,tr("Delete"),
destFile+tr(" already exists.\nDo you really want to delete it?"),
tr("Yes"),tr("No"),0,0,1) ) {
case 0:
f.remove();
break;
case 1:
return;
break;
};
}
if(!copyFile( curFile,destFile) ) {
QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+curFile +tr("to\n")+destFile);
return;
}
// qDebug("copy "+curFile+" as "+destFile);
}
delete fileDlg;
}
rePopulate();
}
void AdvancedFm::move() {
qApp->processEvents();
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
QString curFile, destFile, item;
QDir *thisDir = CurrentDir();
QDir *thatDir = OtherDir();
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item=(*it);
QString destFile = thatDir->canonicalPath();
if(destFile.right(1).find("/",0,TRUE) == -1)
destFile+="/";
destFile += item;
// qDebug("Destination file is "+destFile);
curFile = thisDir->canonicalPath();
if(curFile.right(1).find("/",0,TRUE) == -1)
curFile +="/";
curFile+= item;
// qDebug("CurrentFile file is " + curFile);
if(QFileInfo(curFile).isDir()) {
moveDirectory( curFile, destFile );
rePopulate();
return;
}
QFile f( curFile);
if( f.exists()) {
if( !copyFile( curFile, destFile) ) {
QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
return;
} else
QFile::remove(curFile);
}
}
}
rePopulate();
setOtherTabCurrent();
}
bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) {
int err = 0;
if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src;
err = system((const char*)cmd);
} else
err = -1;
if(err!=0) {
QMessageBox::message(tr("Note"),tr("Could not move\n") + src);
return false;
}
return true;
}
bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) {
QString cmd = "/bin/cp -fpR " + src + " " + dest;
qWarning(cmd);
int err = system( (const char *) cmd );
if ( err != 0 ) {
QMessageBox::message("AdvancedFm",
tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) );
return false;
}
return true;
}
bool AdvancedFm::copyFile( const QString & src, const QString & dest ) {
if(QFileInfo(src).isDir()) {
if( copyDirectory( src, dest )) {
setOtherTabCurrent();
populateView();
return true;
}
else
return false;
}
bool success = true;
struct stat status;
QFile srcFile(src);
QFile destFile(dest);
int err=0;
int read_fd=0;
int write_fd=0;
struct stat stat_buf;
off_t offset = 0;
if(!srcFile.open( IO_ReadOnly|IO_Raw)) {
// qWarning("open failed");
return success = false;
}
read_fd = srcFile.handle();
if(read_fd != -1) {
fstat (read_fd, &stat_buf);
if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
// qWarning("destfile open failed");
return success = false;
}
write_fd = destFile.handle();
if(write_fd != -1) {
err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
if( err == -1) {
QString msg;
switch(err) {
case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
case EINVAL: msg = "Descriptor is not valid or locked. ";
case ENOMEM: msg = "Insufficient memory to read from in_fd.";
case EIO: msg = "Unspecified error while reading from in_fd.";
};
success = false;
// qWarning(msg);
}
} else {
success = false;
}
} else {
success = false;
}
srcFile.close();
destFile.close();
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ) {
chmod( (const char *) dest, status.st_mode );
}
return success;
}
void AdvancedFm::runCommand() {
if( !CurrentView()->currentItem()) return;
QDir *thisDir = CurrentDir();
QString curFile;
curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
//QString command;
if( fileDlg->result() == 1 ) {
// qDebug(fileDlg->LineEdit1->text());
QStringList command;
command << "/bin/sh";
command << "-c";
command << fileDlg->LineEdit1->text();
Output *outDlg;
outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
QPEApplication::execDialog( outDlg );
qApp->processEvents();
}
}
void AdvancedFm::runCommandStd() {
if( !CurrentView()->currentItem()) return;
QString curFile;
QDir *thisDir = CurrentDir();
QListView *thisView = CurrentView();
if( thisView->currentItem())
curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0);
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
qApp->processEvents();
startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
}
}
void AdvancedFm::fileStatus() {
if( !CurrentView()->currentItem()) return;
QString curFile;
curFile = CurrentView()->currentItem()->text(0);
QStringList command;
command << "/bin/sh";
command << "-c";
command << "stat -l "+ curFile;
Output *outDlg;
outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
QPEApplication::execDialog( outDlg );
qApp->processEvents();
}
void AdvancedFm::mkDir() {
makeDir();
}
void AdvancedFm::rn() {
renameIt();
}
void AdvancedFm::del() {
doDelete();
}
void AdvancedFm::mkSym() {
QString cmd;
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
QDir *thisDir = CurrentDir();
QDir * thatDir = OtherDir();
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString destName = thatDir->canonicalPath()+"/"+(*it);
if(destName.right(1) == "/") {
destName = destName.left( destName.length() -1);
}
QString curFile = thisDir->canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") {
curFile = curFile.left( curFile.length() -1);
}
cmd = "ln -s "+curFile+" "+destName;
// qDebug(cmd);
startProcess( (const QString)cmd );
}
rePopulate();
setOtherTabCurrent();
}
}
void AdvancedFm::doBeam() {
Ir ir;
if(!ir.supported()) {
} else {
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString curFile = (*it);
QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
if( curFilePath.right(1) == "/") {
curFilePath = curFilePath.left( curFilePath.length() -1);
}
Ir *file = new Ir(this, "IR");
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*)));
file->send( curFilePath, curFile );
}
}
}
}
void AdvancedFm::fileBeamFinished( Ir *) {
QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
}
void AdvancedFm::selectAll() {
QListView *thisView = CurrentView();
thisView->selectAll(true);
thisView->setSelected( thisView->firstChild(),false);
}
void AdvancedFm::startProcess(const QString & cmd) {
QStringList command;
OProcess *process;
process = new OProcess();
connect(process, SIGNAL(processExited(Opie::Core::OProcess*)),
- this, SLOT( processEnded(OProcess*)));
+ this, SLOT( processEnded(Opie::Core::OProcess*)));
connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)),
- this, SLOT( oprocessStderr(OProcess*,char*,int)));
+ this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int)));
command << "/bin/sh";
command << "-c";
command << cmd.latin1();
*process << command;
if(!process->start(OProcess::NotifyOnExit, OProcess::All) )
qDebug("could not start process");
}
void AdvancedFm::processEnded(OProcess *) {
rePopulate();
}
void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) {
// qWarning("received stderrt %d bytes", buflen);
QString lineStr = buffer;
QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") );
}
bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
if ( o->inherits( "QLineEdit" ) ) {
if ( e->type() == QEvent::KeyPress ) {
QKeyEvent *ke = (QKeyEvent*)e;
if ( ke->key() == Key_Return ||
ke->key() == Key_Enter ) {
okRename();
return true;
}
else if ( ke->key() == Key_Escape ) {
cancelRename();
return true;
}
}
else if ( e->type() == QEvent::FocusOut ) {
cancelRename();
return true;
}
}
if ( o->inherits( "QListView" ) ) {
if ( e->type() == QEvent::FocusIn ) {
if( o == Local_View) { //keep track of which view
whichTab=1;
}
else {
whichTab=2;
}
}
OtherView()->setSelected( OtherView()->currentItem(), FALSE );//make sure there's correct selection
}
return QWidget::eventFilter( o, e );
}
void AdvancedFm::cancelRename() {
// qDebug("cancel rename");
QListView * view;
view = CurrentView();
bool resetFocus = view->viewport()->focusProxy() == renameBox;
delete renameBox;
renameBox = 0;
if ( resetFocus ) {
view->viewport()->setFocusProxy( view);
view->setFocus();
}
}
void AdvancedFm::doRename(QListView * view) {
if( !CurrentView()->currentItem()) return;
QRect r = view->itemRect( view->currentItem( ));
r = QRect( view->viewportToContents( r.topLeft() ), r.size() );
r.setX( view->contentsX() );
if ( r.width() > view->visibleWidth() )
r.setWidth( view->visibleWidth() );
renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
renameBox->setFrame(true);
renameBox->setText( view->currentItem()->text(0) );
renameBox->selectAll();
renameBox->installEventFilter( this );
view->addChild( renameBox, r.x(), r.y() );
renameBox->resize( r.size() );
view->viewport()->setFocusProxy( renameBox );
renameBox->setFocus();
renameBox->show();
}
void AdvancedFm::renameIt() {
if( !CurrentView()->currentItem()) return;
QListView *thisView = CurrentView();
oldName = thisView->currentItem()->text(0);
doRename( thisView );
}
void AdvancedFm::okRename() {
if( !CurrentView()->currentItem()) return;
QString newName = renameBox->text();
cancelRename();
QListView * view = CurrentView();
QString path = CurrentDir()->canonicalPath() + "/";
oldName = path + oldName;
newName = path + newName;
if( rename( oldName.latin1(), newName.latin1())== -1)
QMessageBox::message(tr("Note"),tr("Could not rename"));
else
oldName = "";
view->takeItem( view->currentItem() );
delete view->currentItem();
rePopulate();
}
void AdvancedFm::openSearch() {
QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
}
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp index 16a0992..6906298 100644 --- a/noncore/apps/advancedfm/output.cpp +++ b/noncore/apps/advancedfm/output.cpp @@ -1,278 +1,278 @@ /**************************************************************************** ** outputEdit.cpp ** ** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com> ****************************************************************************/ #include "output.h" #include <qpe/qpeapplication.h> #include <qpe/applnk.h> #include <qfile.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <qlayout.h> #include <errno.h> /* XPM */ using namespace Opie::Core; using namespace Opie::Core; static char * filesave_xpm[] = { "16 16 78 1", " c None", ". c #343434", "+ c #A0A0A0", "@ c #565656", "# c #9E9E9E", "$ c #525252", "% c #929292", "& c #676767", "* c #848484", "= c #666666", "- c #D8D8D8", "; c #FFFFFF", "> c #DBDBDB", ", c #636363", "' c #989898", ") c #2D2D2D", "! c #909090", "~ c #AEAEAE", "{ c #EAEAEA", "] c #575757", "^ c #585858", "/ c #8A8A8A", "( c #828282", "_ c #6F6F6F", ": c #C9C9C9", "< c #050505", "[ c #292929", "} c #777777", "| c #616161", "1 c #3A3A3A", "2 c #BEBEBE", "3 c #2C2C2C", "4 c #7C7C7C", "5 c #F6F6F6", "6 c #FCFCFC", "7 c #6B6B6B", "8 c #959595", "9 c #4F4F4F", "0 c #808080", "a c #767676", "b c #818181", "c c #B8B8B8", "d c #FBFBFB", "e c #F9F9F9", "f c #CCCCCC", "g c #030303", "h c #737373", "i c #7A7A7A", "j c #7E7E7E", "k c #6A6A6A", "l c #FAFAFA", "m c #505050", "n c #9D9D9D", "o c #333333", "p c #7B7B7B", "q c #787878", "r c #696969", "s c #494949", "t c #555555", "u c #949494", "v c #E6E6E6", "w c #424242", "x c #515151", "y c #535353", "z c #3E3E3E", "A c #D4D4D4", "B c #0C0C0C", "C c #353535", "D c #474747", "E c #ECECEC", "F c #919191", "G c #7D7D7D", "H c #000000", "I c #404040", "J c #858585", "K c #323232", "L c #D0D0D0", "M c #1C1C1C", " ...+ ", " @#$%&..+ ", " .*=-;;>,..+ ", " ')!~;;;;;;{]..", " ^/(-;;;;;;;_:<", " [}|;;;;;;;{12$", " #34-55;;;;678$+", " 90ab=c;dd;e1fg ", " [ahij((kbl0mn$ ", " op^q^^7r&]s/$+ ", "@btu;vbwxy]zAB ", "CzDEvEv;;DssF$ ", "G.H{E{E{IxsJ$+ ", " +...vEKxzLM ", " +...z]n$ ", " +... "}; Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog( parent, name, modal, fl ) { QStringList cmmds; // cmmds=QStringList::split( " ", commands, false); cmmds=commands; // qDebug("count %d", cmmds.count()); if ( !name ) setName( tr("Output")); resize( 196, 269 ); setCaption( name ); OutputLayout = new QGridLayout( this ); OutputLayout->setSpacing( 2); OutputLayout->setMargin( 2); QPushButton *docButton; docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton"); docButton->setFixedSize( QSize( 20, 20 ) ); connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() )); // docButton->setFlat(TRUE); OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 ); OutputEdit = new QMultiLineEdit( this, "OutputEdit" ); OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 ); proc = new OProcess(); connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT( processFinished())); connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), - this, SLOT(commandStdout(OProcess*,char*,int))); + this, SLOT(commandStdout(Opie::Core::OProcess*,char*,int))); connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), - this, SLOT(commandStderr(OProcess*,char*,int))); + this, SLOT(commandStderr(Opie::Core::OProcess*,char*,int))); // connect( , SIGNAL(received(const QByteArray&)), // this, SLOT(commandStdin(const QByteArray&))); // * proc << commands.latin1(); for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) { qDebug( "%s", (*it).latin1() ); * proc << (*it).latin1(); } if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) { OutputEdit->append(tr("Process could not start") ); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); perror("Error: "); QString errorMsg=tr("Error\n")+(QString)strerror(errno); OutputEdit->append( errorMsg); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } } Output::~Output() { } void Output::saveOutput() { InputDialog *fileDlg; fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0); fileDlg->exec(); if( fileDlg->result() == 1 ) { QString filename = QPEApplication::documentDir(); if(filename.right(1).find('/') == -1) filename+="/"; QString name = fileDlg->LineEdit1->text(); filename+="text/plain/"+name; qDebug(filename); QFile f(filename); f.open( IO_WriteOnly); if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) { DocLnk lnk; lnk.setName(name); //sets file name lnk.setFile(filename); //sets File property lnk.setType("text/plain"); if(!lnk.writeLink()) { qDebug("Writing doclink did not work"); } } else qWarning("Could not write file"); f.close(); } } void Output::commandStdout(OProcess*, char *buffer, int buflen) { qWarning("received stdout %d bytes", buflen); // QByteArray data(buflen); // data.fill(*buffer, buflen); // for (uint i = 0; i < data.count(); i++ ) { // printf("%c", buffer[i] ); // } // printf("\n"); QString lineStr = buffer; lineStr=lineStr.left(lineStr.length()-1); OutputEdit->append(lineStr); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } void Output::commandStdin( const QByteArray &data) { qWarning("received stdin %d bytes", data.size()); // recieved data from the io layer goes to sz proc->writeStdin(data.data(), data.size()); } void Output::commandStderr(OProcess*, char *buffer, int buflen) { qWarning("received stderrt %d bytes", buflen); QString lineStr = buffer; // lineStr=lineStr.left(lineStr.length()-1); OutputEdit->append(lineStr); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); } void Output::processFinished() { delete proc; OutputEdit->append( tr("\nFinished\n") ); OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); // close(); // disconnect( layer(), SIGNAL(received(const QByteArray&)), // this, SLOT(commandStdin(const QByteArray&))); } //============================== InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "InputDialog" ); resize( 234, 50 ); setMaximumSize( QSize( 240, 50 ) ); setCaption( tr(name ) ); LineEdit1 = new QLineEdit( this, "LineEdit1" ); LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) ); LineEdit1->setFocus(); LineEdit1->setFocus(); connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() )); } InputDialog::~InputDialog() { inputText = LineEdit1->text(); } void InputDialog::setInputText(const QString &string) { LineEdit1->setText( string); } void InputDialog::returned() { inputText = LineEdit1->text(); this->accept(); } diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index 35a328f..a29fa8e 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp @@ -1,94 +1,93 @@ #include "io_bt.h" using namespace Opie::Core; -using namespace Opie::Core; IOBt::IOBt( const Profile &config ) : IOSerial( config ) { m_attach = 0; } IOBt::~IOBt() { if ( m_attach ) { delete m_attach; } } void IOBt::close() { IOSerial::close(); // still need error handling if ( m_attach ) { delete m_attach; m_attach = 0; } } bool IOBt::open() { bool ret = false; // only set up bt stuff if mac address was set, otherwise use the device set if ( !m_mac.isEmpty() ) { // now it should also be checked, if there is a connection to the device with that mac allready // hciattach here m_attach = new OProcess(); *m_attach << "hciattach /dev/ttyS2 any 57600"; // then start hcid, then rcfomm handling (m_mac) connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), - this, SLOT( slotExited(OProcess*) ) ); + this, SLOT( slotExited(Opie::Core::OProcess*) ) ); if ( m_attach->start() ) { ret = IOSerial::open(); } else { qWarning("could not attach to device"); delete m_attach; m_attach = 0; } } else { // directly to the normal serial // TODO: look first if the connection really exists. ( is set up ) ret =IOSerial::open(); } return ret; } void IOBt::reload( const Profile &config ) { m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); } QString IOBt::identifier() const { return "bluetooth"; } QString IOBt::name() const { return "BLuetooth IO Layer"; } void IOBt::slotExited( OProcess* proc ){ close(); delete proc; } QBitArray IOBt::supports() const { return QBitArray( 3 ); } bool IOBt::isConnected() { return false; } void IOBt::send(const QByteArray &data) { qDebug( "Please overload me..." ); } diff --git a/noncore/apps/opie-console/io_irda.cpp b/noncore/apps/opie-console/io_irda.cpp index ba0b0e5..07c2b62 100644 --- a/noncore/apps/opie-console/io_irda.cpp +++ b/noncore/apps/opie-console/io_irda.cpp @@ -1,79 +1,78 @@ #include "io_irda.h" using namespace Opie::Core; -using namespace Opie::Core; IOIrda::IOIrda( const Profile &config ) : IOSerial( config ) { m_attach = 0; } IOIrda::~IOIrda() { if ( m_attach ) { delete m_attach; } } void IOIrda::close() { IOSerial::close(); // still need error handling delete m_attach; } bool IOIrda::open() { bool ret; // irdaattach here m_attach = new OProcess(); *m_attach << "irattach /dev/ttyS2 -s"; connect( m_attach, SIGNAL( processExited(Opie::Core::OProcess*) ), - this, SLOT( slotExited(OProcess*) ) ); + this, SLOT( slotExited(Opie::Core::OProcess*) ) ); if ( m_attach->start() ) { ret= IOSerial::open(); } else { // emit error!!! qWarning("could not attach to device"); delete m_attach; m_attach = 0l; } return ret; } void IOIrda::reload( const Profile &config ) { m_device = config.readEntry("Device", IRDA_DEFAULT_DEVICE); m_baud = config.readNumEntry("Baud", IRDA_DEFAULT_BAUD); m_parity = config.readNumEntry("Parity", IRDA_DEFAULT_PARITY); m_dbits = config.readNumEntry("DataBits", IRDA_DEFAULT_DBITS); m_sbits = config.readNumEntry("StopBits", IRDA_DEFAULT_SBITS); m_flow = config.readNumEntry("Flow", IRDA_DEFAULT_FLOW); } QString IOIrda::identifier() const { return "irda"; } QString IOIrda::name() const { return "Irda IO Layer"; } void IOIrda::slotExited(OProcess* proc ){ close(); delete proc; } QBitArray IOIrda::supports()const { return QBitArray( 3 ); } bool IOIrda::isConnected() { return false; } void IOIrda::send(const QByteArray &data) { qDebug( "Please overload me..." ); } diff --git a/noncore/apps/opie-console/sz_transfer.cpp b/noncore/apps/opie-console/sz_transfer.cpp index 5958e93..fbc5306 100644 --- a/noncore/apps/opie-console/sz_transfer.cpp +++ b/noncore/apps/opie-console/sz_transfer.cpp @@ -1,86 +1,86 @@ #include "sz_transfer.h" #include <qfile.h> #include <stdio.h> #include <sys/termios.h> using namespace Opie::Core; using namespace Opie::Core; SzTransfer::SzTransfer(Type t, IOLayer *layer) : FileTransferLayer(layer), m_t(t) { } SzTransfer::~SzTransfer() { } void SzTransfer::sendFile(const QFile& file) { sendFile(file.name()); } void SzTransfer::sendFile(const QString& file) { //setcbreak(2); /* raw no echo */ proc = new OProcess; *proc << "sz"; *proc << "-v" << "-v" << "-b" << file; connect(proc, SIGNAL(processExited(Opie::Core::OProcess*)), this, SLOT(sent())); connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), - this, SLOT(SzReceivedStdout(OProcess*,char*,int))); + this, SLOT(SzReceivedStdout(Opie::Core::OProcess*,char*,int))); connect(proc, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), - this, SLOT(SzReceivedStderr(OProcess*,char*,int))); + this, SLOT(SzReceivedStderr(Opie::Core::OProcess*,char*,int))); connect(layer(), SIGNAL(received(const QByteArray&)), this, SLOT(receivedStdin(const QByteArray&))); proc->start(OProcess::NotifyOnExit, OProcess::All); } void SzTransfer::SzReceivedStdout(OProcess *, char *buffer, int buflen) { qWarning("recieved from sz on stdout %d bytes", buflen); QByteArray data(buflen); data.fill(*buffer, buflen); for (uint i = 0; i < data.count(); i++ ) { printf("%c", buffer[i] ); } printf("\n"); // send out through the io layer layer()->send(data); } void SzTransfer::SzReceivedStderr(OProcess *, char *buffer, int length) { // parse and show data in a progress dialog/widget printf("stderr:\n"); //for (int i = 0; i < length; i++) // printf("%c", buffer[i]); //printf("\n"); } void SzTransfer::receivedStdin(const QByteArray &data) { qWarning("recieved from io_serial %d bytes", data.size()); // recieved data from the io layer goes to sz proc->writeStdin(data.data(), data.size()); } void SzTransfer::sent() { qWarning("sent file"); //setcbreak(0); /* default */ delete proc; disconnect(layer(), SIGNAL(received(const QByteArray&)), this, SLOT(receivedStdin(const QByteArray&))); } diff --git a/noncore/net/mail/libmailwrapper/mhwrapper.cpp b/noncore/net/mail/libmailwrapper/mhwrapper.cpp index 21e24a0..5eae31f 100644 --- a/noncore/net/mail/libmailwrapper/mhwrapper.cpp +++ b/noncore/net/mail/libmailwrapper/mhwrapper.cpp @@ -1,444 +1,442 @@ #include "mhwrapper.h" #include "mailtypes.h" #include "mailwrapper.h" #include <libetpan/libetpan.h> #include <qdir.h> #include <qmessagebox.h> #include <stdlib.h> #include <qpe/global.h> #include <opie2/oprocess.h> using namespace Opie::Core; -using namespace Opie::Core; -using namespace Opie::Core; MHwrapper::MHwrapper(const QString & mbox_dir,const QString&mbox_name) : Genericwrapper(),MHPath(mbox_dir),MHName(mbox_name) { if (MHPath.length()>0) { if (MHPath[MHPath.length()-1]=='/') { MHPath=MHPath.left(MHPath.length()-1); } qDebug(MHPath); QDir dir(MHPath); if (!dir.exists()) { dir.mkdir(MHPath); } init_storage(); } } void MHwrapper::init_storage() { int r; QString pre = MHPath; if (!m_storage) { m_storage = mailstorage_new(NULL); r = mh_mailstorage_init(m_storage,(char*)pre.latin1(),0,0,0); if (r != MAIL_NO_ERROR) { qDebug("error initializing storage"); mailstorage_free(m_storage); m_storage = 0; return; } } r = mailstorage_connect(m_storage); if (r!=MAIL_NO_ERROR) { qDebug("error connecting storage"); mailstorage_free(m_storage); m_storage = 0; } } void MHwrapper::clean_storage() { if (m_storage) { mailstorage_disconnect(m_storage); mailstorage_free(m_storage); m_storage = 0; } } MHwrapper::~MHwrapper() { clean_storage(); } void MHwrapper::listMessages(const QString & mailbox, QValueList<Opie::Core::OSmartPointer<RecMail> > &target ) { init_storage(); if (!m_storage) { return; } QString f = buildPath(mailbox); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { qDebug("listMessages: error selecting folder!"); return; } parseList(target,m_storage->sto_session,f); Global::statusMessage(tr("Mailbox has %1 mail(s)").arg(target.count())); } QValueList<Opie::Core::OSmartPointer<Folder> >* MHwrapper::listFolders() { QValueList<Opie::Core::OSmartPointer<Folder> >* folders = new QValueList<Opie::Core::OSmartPointer<Folder> >(); /* this is needed! */ if (m_storage) mailstorage_disconnect(m_storage); init_storage(); if (!m_storage) { return folders; } mail_list*flist = 0; clistcell*current=0; int r = mailsession_list_folders(m_storage->sto_session,NULL,&flist); if (r != MAIL_NO_ERROR || !flist) { qDebug("error getting folder list"); return folders; } for (current=clist_begin(flist->mb_list);current!=0;current=clist_next(current)) { QString t = (char*)current->data; t.replace(0,MHPath.length(),""); folders->append(new MHFolder(t,MHPath)); } mail_list_free(flist); return folders; } void MHwrapper::deleteMail(const RecMailP&mail) { init_storage(); if (!m_storage) { return; } int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder!"); return; } r = mailsession_remove_message(m_storage->sto_session,mail->getNumber()); if (r != MAIL_NO_ERROR) { qDebug("error deleting mail"); } } void MHwrapper::answeredMail(const RecMailP&) { } RecBody MHwrapper::fetchBody( const RecMailP &mail ) { RecBody body; init_storage(); if (!m_storage) { return body; } mailmessage * msg; char*data=0; /* mail should hold the complete path! */ int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r != MAIL_NO_ERROR) { return body; } r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); if (r != MAIL_NO_ERROR) { qDebug("Error fetching mail %i",mail->getNumber()); return body; } body = parseMail(msg); mailmessage_fetch_result_free(msg,data); return body; } void MHwrapper::mbox_progress( size_t current, size_t maximum ) { qDebug("MH %i von %i",current,maximum); } QString MHwrapper::buildPath(const QString&p) { QString f=""; if (p.length()==0||p=="/") return MHPath; if (!p.startsWith(MHPath)) { f+=MHPath; } if (!p.startsWith("/")) { f+="/"; } f+=p; return f; } int MHwrapper::createMbox(const QString&folder,const FolderP&pfolder,const QString&,bool ) { init_storage(); if (!m_storage) { return 0; } QString f; if (!pfolder) { // toplevel folder f = buildPath(folder); } else { f = pfolder->getName(); f+="/"; f+=folder; } qDebug(f); int r = mailsession_create_folder(m_storage->sto_session,(char*)f.latin1()); if (r != MAIL_NO_ERROR) { qDebug("error creating folder %i",r); return 0; } qDebug("Folder created"); return 1; } void MHwrapper::storeMessage(const char*msg,size_t length, const QString&Folder) { init_storage(); if (!m_storage) { return; } QString f = buildPath(Folder); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder!"); return; } r = mailsession_append_message(m_storage->sto_session,(char*)msg,length); if (r!=MAIL_NO_ERROR) { qDebug("error storing mail"); } return; } encodedString* MHwrapper::fetchRawBody(const RecMailP&mail) { encodedString*result = 0; init_storage(); if (!m_storage) { return result; } mailmessage * msg = 0; char*data=0; size_t size; int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder!"); return result; } r = mailsession_get_message(m_storage->sto_session, mail->getNumber(), &msg); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); return 0; } r = mailmessage_fetch(msg,&data,&size); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error fetching mail %i").arg(mail->getNumber())); if (msg) mailmessage_free(msg); return 0; } result = new encodedString(data,size); if (msg) mailmessage_free(msg); return result; } void MHwrapper::deleteMails(const QString & mailbox,const QValueList<RecMailP> &target) { QString f = buildPath(mailbox); int r = mailsession_select_folder(m_storage->sto_session,(char*)f.latin1()); if (r!=MAIL_NO_ERROR) { qDebug("deleteMails: error selecting folder!"); return; } QValueList<RecMailP>::ConstIterator it; for (it=target.begin(); it!=target.end();++it) { r = mailsession_remove_message(m_storage->sto_session,(*it)->getNumber()); if (r != MAIL_NO_ERROR) { qDebug("error deleting mail"); break; } } } int MHwrapper::deleteAllMail(const FolderP&tfolder) { init_storage(); if (!m_storage) { return 0; } int res = 1; if (!tfolder) return 0; int r = mailsession_select_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting folder!"); return 0; } mailmessage_list*l=0; r = mailsession_get_messages_list(m_storage->sto_session,&l); if (r != MAIL_NO_ERROR) { qDebug("Error message list"); res = 0; } unsigned j = 0; for(unsigned int i = 0 ; l!= 0 && res==1 && i < carray_count(l->msg_tab) ; ++i) { mailmessage * msg; msg = (mailmessage*)carray_get(l->msg_tab, i); j = msg->msg_index; r = mailsession_remove_message(m_storage->sto_session,j); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error deleting mail %1").arg(i+1)); res = 0; break; } } if (l) mailmessage_list_free(l); return res; } int MHwrapper::deleteMbox(const FolderP&tfolder) { init_storage(); if (!m_storage) { return 0; } if (!tfolder) return 0; if (tfolder->getName()=="/" || tfolder->getName().isEmpty()) return 0; int r = mailsession_delete_folder(m_storage->sto_session,(char*)tfolder->getName().latin1()); if (r != MAIL_NO_ERROR) { qDebug("error deleting mail box"); return 0; } QString cmd = "rm -rf "+tfolder->getName(); QStringList command; command << "/bin/sh"; command << "-c"; command << cmd.latin1(); OProcess *process = new OProcess(); connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), - this, SLOT( processEnded(OProcess*))); + this, SLOT( processEnded(Opie::Core::OProcess*))); connect(process, SIGNAL( receivedStderr(Opie::Core::OProcess*,char*,int)), - this, SLOT( oprocessStderr(OProcess*,char*,int))); + this, SLOT( oprocessStderr(Opie::Core::OProcess*,char*,int))); *process << command; removeMboxfailed = false; if(!process->start(OProcess::Block, OProcess::All) ) { qDebug("could not start process"); return 0; } qDebug("mail box deleted"); return 1; } void MHwrapper::processEnded(OProcess *p) { if (p) delete p; } void MHwrapper::oprocessStderr(OProcess*, char *buffer, int ) { QString lineStr = buffer; QMessageBox::warning( 0, tr("Error"), lineStr ,tr("Ok") ); removeMboxfailed = true; } void MHwrapper::statusFolder(folderStat&target_stat,const QString & mailbox) { init_storage(); if (!m_storage) { return; } target_stat.message_count = 0; target_stat.message_unseen = 0; target_stat.message_recent = 0; QString f = buildPath(mailbox); int r = mailsession_status_folder(m_storage->sto_session,(char*)f.latin1(),&target_stat.message_count, &target_stat.message_recent,&target_stat.message_unseen); if (r != MAIL_NO_ERROR) { Global::statusMessage(tr("Error retrieving status")); } } MAILLIB::ATYPE MHwrapper::getType()const { return MAILLIB::A_MH; } const QString&MHwrapper::getName()const { return MHName; } void MHwrapper::mvcpMail(const RecMailP&mail,const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { init_storage(); if (!m_storage) { return; } if (targetWrapper != this) { qDebug("Using generic"); Genericwrapper::mvcpMail(mail,targetFolder,targetWrapper,moveit); return; } qDebug("Using internal routines for move/copy"); QString tf = buildPath(targetFolder); int r = mailsession_select_folder(m_storage->sto_session,(char*)mail->getMbox().latin1()); if (r != MAIL_NO_ERROR) { qDebug("Error selecting source mailbox"); return; } if (moveit) { r = mailsession_move_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); } else { r = mailsession_copy_message(m_storage->sto_session,mail->getNumber(),(char*)tf.latin1()); } if (r != MAIL_NO_ERROR) { qDebug("Error copy/moving mail internal (%i)",r); } } void MHwrapper::mvcpAllMails(const FolderP&fromFolder, const QString&targetFolder,AbstractMail*targetWrapper,bool moveit) { init_storage(); if (!m_storage) { return; } if (targetWrapper != this) { qDebug("Using generic"); Genericwrapper::mvcpAllMails(fromFolder,targetFolder,targetWrapper,moveit); return; } if (!fromFolder) return; int r = mailsession_select_folder(m_storage->sto_session,(char*)fromFolder->getName().latin1()); if (r!=MAIL_NO_ERROR) { qDebug("error selecting source folder!"); return; } QString tf = buildPath(targetFolder); mailmessage_list*l=0; r = mailsession_get_messages_list(m_storage->sto_session,&l); if (r != MAIL_NO_ERROR) { qDebug("Error message list"); } unsigned j = 0; for(unsigned int i = 0 ; l!= 0 && i < carray_count(l->msg_tab) ; ++i) { mailmessage * msg; msg = (mailmessage*)carray_get(l->msg_tab, i); j = msg->msg_index; if (moveit) { r = mailsession_move_message(m_storage->sto_session,j,(char*)tf.latin1()); } else { r = mailsession_copy_message(m_storage->sto_session,j,(char*)tf.latin1()); } if (r != MAIL_NO_ERROR) { qDebug("Error copy/moving mail internal (%i)",r); break; } } if (l) mailmessage_list_free(l); } diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc index d913853..18d26e4 100644 --- a/noncore/net/opietooth/lib/device.cc +++ b/noncore/net/opietooth/lib/device.cc @@ -1,153 +1,152 @@ #include <signal.h> #include <opie2/oprocess.h> #include "device.h" using namespace OpieTooth; using namespace Opie::Core; -using namespace Opie::Core; namespace { int parsePid( const QCString& par ){ int id=0; QString string( par ); QStringList list = QStringList::split( '\n', string ); for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ qWarning("parsePID: %s", (*it).latin1() ); if( !(*it).startsWith("CSR") ){ id = (*it).toInt(); break; } } return id; } } Device::Device(const QString &device, const QString &mode, const QString &speed ) : QObject(0, "device") { qWarning("OpieTooth::Device create" ); m_hci = 0; m_process = 0; m_attached = false; m_device = device; m_mode = mode; m_speed = speed; attach(); } Device::~Device(){ detach(); } void Device::attach(){ qWarning("attaching %s %s %s", m_device.latin1(), m_mode.latin1(), m_speed.latin1() ); if(m_process == 0 ){ m_output.resize(0); qWarning("new process to create" ); m_process = new OProcess(); *m_process << "hciattach"; *m_process << "-p"; *m_process << m_device << m_mode << m_speed; connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ), - this, SLOT( slotExited(OProcess* ) ) ); + this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); connect(m_process, SIGNAL( receivedStdout(Opie::Core::OProcess*, char*, int) ), - this, SLOT(slotStdOut(OProcess*,char*,int ) ) ); + this, SLOT(slotStdOut(Opie::Core::OProcess*,char*,int ) ) ); connect(m_process, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int ) ), - this, SLOT(slotStdErr(OProcess*,char*,int) ) ); + this, SLOT(slotStdErr(Opie::Core::OProcess*,char*,int) ) ); if(!m_process->start(OProcess::NotifyOnExit, OProcess::AllOutput ) ){ qWarning("Could not start" ); delete m_process; m_process = 0; } }; } void Device::detach(){ delete m_hci; delete m_process; // kill the pid we got if(m_attached ){ //kill the pid qWarning( "killing" ); kill(pid, 9); } qWarning("detached" ); } bool Device::isLoaded()const{ return m_attached; } QString Device::devName()const { return QString::fromLatin1("hci0"); }; void Device::slotExited( OProcess* proc) { qWarning("prcess exited" ); if(proc== m_process ){ qWarning("proc == m_process" ); if( m_process->normalExit() ){ // normal exit qWarning("normalExit" ); int ret = m_process->exitStatus(); if( ret == 0 ){ // attached qWarning("attached" ); qWarning("Output: %s", m_output.data() ); pid = parsePid( m_output ); qWarning("Pid = %d", pid ); // now hciconfig hci0 up ( determine hciX FIXME) // and call hciconfig hci0 up // FIXME hardcoded to hci0 now :( m_hci = new OProcess( ); *m_hci << "hciconfig"; *m_hci << "hci0 up"; connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ), - this, SLOT( slotExited(OProcess* ) ) ); + this, SLOT( slotExited(Opie::Core::OProcess* ) ) ); if(!m_hci->start() ){ qWarning("could not start" ); m_attached = false; emit device("hci0", false ); } }else{ qWarning("crass" ); m_attached = false; emit device("hci0", false ); } } delete m_process; m_process = 0; }else if(proc== m_hci ){ qWarning("M HCI exited" ); if( m_hci->normalExit() ){ qWarning("normal exit" ); int ret = m_hci->exitStatus(); if( ret == 0 ){ qWarning("attached really really attached" ); m_attached = true; emit device("hci0", true ); }else{ qWarning( "failed" ); emit device("hci0", false ); m_attached = false; } }// normal exit delete m_hci; m_hci = 0; } } void Device::slotStdOut(OProcess* proc, char* chars, int len) { qWarning("std out" ); if( len <1 ){ qWarning( "len < 1 " ); return; } if(proc == m_process ){ QCString string( chars, len+1 ); // \0 == +1 qWarning("output: %s", string.data() ); m_output.append( string.data() ); } } void Device::slotStdErr(OProcess* proc, char* chars, int len) { qWarning("std err" ); slotStdOut( proc, chars, len ); } diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index 56156a8..7c9ea5b 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc @@ -1,336 +1,336 @@ #include <opie2/oprocess.h> #include "parser.h" #include "manager.h" using namespace OpieTooth; using namespace Opie::Core; using namespace Opie::Core; Manager::Manager( const QString& dev ) : QObject() { qWarning("created"); m_device = dev; m_hcitool = 0; m_sdp = 0; } Manager::Manager( Device* /*dev*/ ) : QObject() { m_hcitool = 0; m_sdp = 0; } Manager::Manager() : QObject() { m_hcitool = 0; m_sdp = 0; } Manager::~Manager(){ delete m_hcitool; delete m_sdp; } void Manager::setDevice( const QString& dev ){ m_device = dev; } void Manager::setDevice( Device* /*dev*/ ){ } void Manager::isAvailable( const QString& device ){ OProcess* l2ping = new OProcess(); l2ping->setName( device.latin1() ); *l2ping << "l2ping" << "-c1" << device; connect(l2ping, SIGNAL(processExited(Opie::Core::OProcess* ) ), - this, SLOT(slotProcessExited(OProcess*) ) ); + this, SLOT(slotProcessExited(Opie::Core::OProcess*) ) ); if (!l2ping->start() ) { emit available( device, false ); delete l2ping; } } void Manager::isAvailable( Device* /*dev*/ ){ } void Manager::searchDevices( const QString& device ){ qWarning("search devices"); OProcess* hcitool = new OProcess(); hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); *hcitool << "hcitool" << "scan"; connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) , - this, SLOT(slotHCIExited(OProcess* ) ) ); + this, SLOT(slotHCIExited(Opie::Core::OProcess* ) ) ); connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), - this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); + this, SLOT(slotHCIOut(Opie::Core::OProcess*, char*, int ) ) ); if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning("could not start"); RemoteDevice::ValueList list; emit foundDevices( device, list ); delete hcitool; } } void Manager::searchDevices(Device* /*d*/ ){ } void Manager::addService(const QString& name ){ OProcess proc; proc << "sdptool" << "add" << name; bool bo = true; if (!proc.start(OProcess::DontCare ) ) bo = false; emit addedService( name, bo ); } void Manager::addServices(const QStringList& list){ QStringList::ConstIterator it; for (it = list.begin(); it != list.end(); ++it ) addService( (*it) ); } void Manager::removeService( const QString& name ){ OProcess prc; prc << "sdptool" << "del" << name; bool bo = true; if (!prc.start(OProcess::DontCare ) ) bo = false; emit removedService( name, bo ); } void Manager::removeServices( const QStringList& list){ QStringList::ConstIterator it; for (it = list.begin(); it != list.end(); ++it ) removeService( (*it) ); } void Manager::searchServices( const QString& remDevice ){ OProcess *m_sdp =new OProcess(); *m_sdp << "sdptool" << "browse" << remDevice; m_sdp->setName( remDevice.latin1() ); qWarning("search Services for %s", remDevice.latin1() ); connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ), - this, SLOT(slotSDPExited(OProcess* ) ) ); + this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) ); connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), - this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); + this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) ); if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning("could not start sdptool" ); delete m_sdp; Services::ValueList list; emit foundServices( remDevice, list ); } } void Manager::searchServices( const RemoteDevice& dev){ searchServices( dev.mac() ); } QString Manager::toDevice( const QString& /*mac*/ ){ return QString::null; } QString Manager::toMac( const QString &/*device*/ ){ return QString::null; } void Manager::slotProcessExited(OProcess* proc ) { bool conn= false; if (proc->normalExit() && proc->exitStatus() == 0 ) conn = true; QString name = QString::fromLatin1(proc->name() ); emit available( name, conn ); delete proc; } void Manager::slotSDPOut(OProcess* proc, char* ch, int len) { QCString str(ch, len+1 ); qWarning("SDP:%s", str.data() ); QMap<QString, QString>::Iterator it; it = m_out.find(proc->name() ); QString string; if ( it != m_out.end() ) { string = it.data(); } string.append( str ); m_out.replace( proc->name(), string ); } void Manager::slotSDPExited( OProcess* proc) { qWarning("proc name %s", proc->name() ); Services::ValueList list; if (proc->normalExit() ) { QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); if ( it != m_out.end() ) { qWarning("found process" ); list = parseSDPOutput( it.data() ); m_out.remove( it ); } } emit foundServices( proc->name(), list ); delete proc; } Services::ValueList Manager::parseSDPOutput( const QString& out ) { Services::ValueList list; qWarning("parsing output" ); Parser parser( out ); list = parser.services(); return list; } void Manager::slotHCIExited(OProcess* proc ) { qWarning("process exited"); RemoteDevice::ValueList list; if (proc->normalExit() ) { qWarning("normalExit %s", proc->name() ); QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); if (it != m_devices.end() ) { qWarning("!= end ;)"); list = parseHCIOutput( it.data() ); m_devices.remove( it ); } } emit foundDevices( proc->name(), list ); delete proc; } void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { QCString str( ch, len+1 ); qWarning("hci: %s", str.data() ); QMap<QString, QString>::Iterator it; it = m_devices.find( proc->name() ); qWarning("proc->name %s", proc->name() ); QString string; if (it != m_devices.end() ) { qWarning("slotHCIOut "); string = it.data(); } string.append( str ); m_devices.replace( proc->name(), string ); } RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { qWarning("parseHCI %s", output.latin1() ); RemoteDevice::ValueList list; QStringList strList = QStringList::split('\n', output ); QStringList::Iterator it; QString str; for ( it = strList.begin(); it != strList.end(); ++it ) { str = (*it).stripWhiteSpace(); qWarning("OpieTooth %s", str.latin1() ); int pos = str.findRev(':' ); if ( pos > 0 ) { QString mac = str.left(17 ); str.remove( 0, 17 ); qWarning("mac %s", mac.latin1() ); qWarning("rest:%s", str.latin1() ); RemoteDevice rem( mac , str.stripWhiteSpace() ); list.append( rem ); } } return list; } ////// hcitool cc and hcitool con /** * Create it on the stack as don't care * so we don't need to care for it * cause hcitool gets reparented */ void Manager::connectTo( const QString& mac) { OProcess proc; proc << "hcitool"; proc << "cc"; proc << mac; proc.start(OProcess::DontCare); // the lib does not care at this point } void Manager::searchConnections() { qWarning("searching connections?"); OProcess* proc = new OProcess(); m_hcitoolCon = QString::null; connect(proc, SIGNAL(processExited(Opie::Core::OProcess*) ), - this, SLOT(slotConnectionExited( OProcess*) ) ); + this, SLOT(slotConnectionExited( Opie::Core::OProcess*) ) ); connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ), - this, SLOT(slotConnectionOutput(OProcess*, char*, int) ) ); + this, SLOT(slotConnectionOutput(Opie::Core::OProcess*, char*, int) ) ); *proc << "hcitool"; *proc << "con"; if (!proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { ConnectionState::ValueList list; emit connections( list ); delete proc; } } void Manager::slotConnectionExited( OProcess* proc ) { ConnectionState::ValueList list; list = parseConnections( m_hcitoolCon ); emit connections(list ); delete proc; } void Manager::slotConnectionOutput(OProcess* /*proc*/, char* cha, int len) { QCString str(cha, len ); m_hcitoolCon.append( str ); //delete proc; } ConnectionState::ValueList Manager::parseConnections( const QString& out ) { ConnectionState::ValueList list2; QStringList list = QStringList::split('\n', out ); QStringList::Iterator it; // remove the first line ( "Connections:") it = list.begin(); it = list.remove( it ); for (; it != list.end(); ++it ) { QString row = (*it).stripWhiteSpace(); QStringList value = QStringList::split(' ', row ); qWarning("0: %s", value[0].latin1() ); qWarning("1: %s", value[1].latin1() ); qWarning("2: %s", value[2].latin1() ); qWarning("3: %s", value[3].latin1() ); qWarning("4: %s", value[4].latin1() ); qWarning("5: %s", value[5].latin1() ); qWarning("6: %s", value[6].latin1() ); qWarning("7: %s", value[7].latin1() ); qWarning("8: %s", value[8].latin1() ); ConnectionState con; con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); con.setConnectionMode( value[1] ); con.setMac( value[2] ); con.setHandle( value[4].toInt() ); con.setState( value[6].toInt() ); con.setLinkMode( value[8] == QString::fromLatin1("MASTER") ? Master : Client ); list2.append( con ); } return list2; } void Manager::signalStrength( const QString &mac ) { OProcess* sig_proc = new OProcess(); connect(sig_proc, SIGNAL(processExited(Opie::Core::OProcess*) ), - this, SLOT(slotSignalStrengthExited( OProcess*) ) ); + this, SLOT(slotSignalStrengthExited( Opie::Core::OProcess*) ) ); connect(sig_proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ), - this, SLOT(slotSignalStrengthOutput(OProcess*, char*, int) ) ); + this, SLOT(slotSignalStrengthOutput(Opie::Core::OProcess*, char*, int) ) ); *sig_proc << "hcitool"; *sig_proc << "lq"; *sig_proc << mac; sig_proc->setName( mac.latin1() ); if (!sig_proc->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { emit signalStrength( mac, "-1" ); delete sig_proc; } } void Manager::slotSignalStrengthOutput(OProcess* proc, char* cha, int len) { QCString str(cha, len ); QString temp = QString(str).stripWhiteSpace(); QStringList value = QStringList::split(' ', temp ); emit signalStrength( proc->name(), value[2].latin1() ); } void Manager::slotSignalStrengthExited( OProcess* proc ) { delete proc; } diff --git a/noncore/net/opietooth/lib/startdunconnection.cpp b/noncore/net/opietooth/lib/startdunconnection.cpp index 90ef04a..09b19d2 100644 --- a/noncore/net/opietooth/lib/startdunconnection.cpp +++ b/noncore/net/opietooth/lib/startdunconnection.cpp @@ -1,69 +1,68 @@ #include "startdunconnection.h" using namespace OpieTooth; using namespace Opie::Core; -using namespace Opie::Core; StartDunConnection::StartDunConnection() { m_dunConnect = 0l; setConnectionType(); } StartDunConnection::~StartDunConnection() { delete m_dunConnect; } StartDunConnection::StartDunConnection( QString mac ) { m_dunConnect = 0l; m_mac = mac; setConnectionType(); } void StartDunConnection::setName( QString name ) { m_name = name; } QString StartDunConnection::name() { return m_name; } void StartDunConnection::setConnectionType() { m_connectionType = Pan; } StartConnection::ConnectionType StartDunConnection::type() { return m_connectionType; } void StartDunConnection::start() { m_dunConnect = new OProcess(); *m_dunConnect << "dund" << "--listen" << "--connect" << m_mac; connect( m_dunConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) , - this, SLOT( slotExited(OProcess*) ) ); + this, SLOT( slotExited(Opie::Core::OProcess*) ) ); connect( m_dunConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ), - this, SLOT( slotStdOut(OProcess*,char*,int) ) ); + this, SLOT( slotStdOut(Opie::Core::OProcess*,char*,int) ) ); if (!m_dunConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning( "could not start" ); delete m_dunConnect; } } void StartDunConnection::slotExited( OProcess* proc ) { delete m_dunConnect; } void StartDunConnection::slotStdOut(OProcess* proc, char* chars, int len) {} void StartDunConnection::stop() { if ( m_dunConnect ) { delete m_dunConnect; m_dunConnect = 0l; } } diff --git a/noncore/net/opietooth/lib/startpanconnection.cpp b/noncore/net/opietooth/lib/startpanconnection.cpp index fef35d9..24ac530 100644 --- a/noncore/net/opietooth/lib/startpanconnection.cpp +++ b/noncore/net/opietooth/lib/startpanconnection.cpp @@ -1,84 +1,84 @@ #include "startpanconnection.h" using namespace OpieTooth; using namespace Opie::Core; using namespace Opie::Core; StartPanConnection::StartPanConnection() { m_panConnect = 0l; setConnectionType(); } StartPanConnection::~StartPanConnection() { delete m_panConnect; } StartPanConnection::StartPanConnection( QString mac ) { m_panConnect = 0l; m_mac = mac; setConnectionType(); } void StartPanConnection::setName( QString name ) { m_name = name; } QString StartPanConnection::name() { return m_name; } void StartPanConnection::setConnectionType() { m_connectionType = Pan; } StartConnection::ConnectionType StartPanConnection::type() { return m_connectionType; } void StartPanConnection::start() { m_panConnect = new OProcess(); qDebug( "IM START " + m_mac ); *m_panConnect << "pand" << "--connect" << m_mac; connect( m_panConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) , - this, SLOT( slotExited(OProcess*) ) ); + this, SLOT( slotExited(Opie::Core::OProcess*) ) ); connect( m_panConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ), - this, SLOT( slotStdOut(OProcess*,char*,int) ) ); + this, SLOT( slotStdOut(Opie::Core::OProcess*,char*,int) ) ); if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning( "could not start" ); delete m_panConnect; } } void StartPanConnection::slotExited( OProcess* proc ) { delete m_panConnect; m_panConnect = 0l; } void StartPanConnection::slotStdOut(OProcess* proc, char* chars, int len) {} void StartPanConnection::stop() { if ( m_panConnect ) { delete m_panConnect; m_panConnect = 0l; } m_panConnect = new OProcess(); qDebug("IM STOP " + m_mac); *m_panConnect << "pand" << "--kill" << m_mac; connect( m_panConnect, SIGNAL( processExited(Opie::Core::OProcess*) ) , - this, SLOT( slotExited(OProcess*) ) ); + this, SLOT( slotExited(Opie::Core::OProcess*) ) ); connect( m_panConnect, SIGNAL( receivedStdout(Opie::Core::OProcess*,char*,int) ), - this, SLOT( slotStdOut(OProcess*,char*,int) ) ); + this, SLOT( slotStdOut(Opie::Core::OProcess*,char*,int) ) ); if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning( "could not stop" ); delete m_panConnect; } } diff --git a/noncore/net/opietooth/manager/pppdialog.cpp b/noncore/net/opietooth/manager/pppdialog.cpp index 870e7fd..78c1501 100644 --- a/noncore/net/opietooth/manager/pppdialog.cpp +++ b/noncore/net/opietooth/manager/pppdialog.cpp @@ -1,70 +1,69 @@ #include "pppdialog.h" #include <qpushbutton.h> #include <qmultilineedit.h> #include <qlineedit.h> #include <qlayout.h> #include <qlabel.h> #include <opie2/oprocess.h> using namespace OpieTooth; using namespace Opie::Core; -using namespace Opie::Core; PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "PPPDialog" ); setCaption( tr( "ppp connection " ) ) ; m_device = device; layout = new QVBoxLayout( this ); QLabel* info = new QLabel( this ); info->setText( tr("Enter an ppp script name:") ); cmdLine = new QLineEdit( this ); outPut = new QMultiLineEdit( this ); QFont outPut_font( outPut->font() ); outPut_font.setPointSize( 8 ); outPut->setFont( outPut_font ); outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); connectButton = new QPushButton( this ); connectButton->setText( tr( "Connect" ) ); layout->addWidget(info); layout->addWidget(cmdLine); layout->addWidget(outPut); layout->addWidget(connectButton); connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); } PPPDialog::~PPPDialog() { } void PPPDialog::connectToDevice() { outPut->clear(); // vom popupmenu beziehen QString connectScript = "/etc/ppp/peers/" + cmdLine->text(); OProcess* pppDial = new OProcess(); *pppDial << "pppd" << m_device << "call" << connectScript; connect( pppDial, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int) ), - this, SLOT(fillOutPut(OProcess*,char*,int) ) ); + this, SLOT(fillOutPut(Opie::Core::OProcess*,char*,int) ) ); if (!pppDial->start(OProcess::DontCare, OProcess::AllOutput) ) { qWarning("could not start"); delete pppDial; } } void PPPDialog::fillOutPut( OProcess* pppDial, char* cha, int len ) { QCString str(cha, len ); outPut->insertLine( str ); delete pppDial; } diff --git a/noncore/settings/networksettings/ppp/config.in b/noncore/settings/networksettings/ppp/config.in index 3b8501d..0b71434 100644 --- a/noncore/settings/networksettings/ppp/config.in +++ b/noncore/settings/networksettings/ppp/config.in @@ -1,4 +1,4 @@ config PPP boolean "opie-networksettingsplugin-kppp (PPP module)" default "n" if NETWORKSETUP - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES + depends ( LIBQPE || LIBQPE-X11 ) && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES diff --git a/noncore/settings/networksettings/wlan/config.in b/noncore/settings/networksettings/wlan/config.in index 97fa468..d4661cb 100644 --- a/noncore/settings/networksettings/wlan/config.in +++ b/noncore/settings/networksettings/wlan/config.in @@ -1,6 +1,6 @@ config WLAN boolean "opie-networksettingsplugin-wlan (wireless LAN module)" default "n" if NETWORKSETUP depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2UI && NETWORKSETUP && NETWORKSETUP-CORE && INTERFACES && LIBOPIE2NET #comment "opie-networksettingsplugin-wlan needs libopie2ui, libopie2net and networksetup" - #depends !( LIBOPIE2NET && LIBOPIE && NETWORKSETUP)
\ No newline at end of file + #depends !( LIBOPIE2NET && NETWORKSETUP)
\ No newline at end of file diff --git a/noncore/unsupported/mail2/bend/bend.cpp b/noncore/unsupported/mail2/bend/bend.cpp index ab6eb45..4ded402 100644 --- a/noncore/unsupported/mail2/bend/bend.cpp +++ b/noncore/unsupported/mail2/bend/bend.cpp @@ -1,124 +1,124 @@ #include <qlayout.h> #include <qpixmap.h> #include <qlabel.h> #include <qsound.h> #include <qtimer.h> #include <qdir.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> #include <qpe/config.h> -#include <opie/odevice.h> +#include <opie2/odevice.h> #include "imapresponse.h" #include "imaphandler.h" #include "configfile.h" #include "bend.h" using namespace Opie; BenD::BenD(QWidget *parent, const char *name, WFlags fl) : QButton(parent, name, fl) { _config = new Config("mail"); _config->setGroup("Settings"); QVBoxLayout *layout = new QVBoxLayout(this); layout->addItem(new QSpacerItem(0,0)); QLabel *pixmap = new QLabel(this); pixmap->setPixmap(Resource::loadPixmap("mail/mailchecker")); layout->addWidget(pixmap); layout->addItem(new QSpacerItem(0,0)); hide(); connect(this, SIGNAL(clicked()), SLOT(slotClicked())); if (!_config->readBoolEntry("Disabled", false)) { _intervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; _intervalTimer = new QTimer(); _intervalTimer->start(_intervalMs); connect(_intervalTimer, SIGNAL(timeout()), SLOT(slotCheck())); QTimer::singleShot(0, this, SLOT(slotCheck())); } } void BenD::drawButton(QPainter *) { } void BenD::drawButtonText(QPainter *) { } void BenD::slotClicked() { QCopEnvelope e("QPE/System", "execute(QString)"); e << QString("mail"); ODevice *device = ODevice::inst(); if ( !device-> ledList ( ). isEmpty ( )) { OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; device->setLedState(led, Led_Off); } } void BenD::slotCheck() { // Check wether the check interval has been changed. int newIntervalMs = _config->readNumEntry("CheckEvery", 5) * 60000; if (newIntervalMs != _intervalMs) { _intervalTimer->changeInterval(newIntervalMs); _intervalMs = newIntervalMs; #ifndef QT_NO_DEBUG qWarning("BenD: Detected interval change"); #endif } QValueList<Account> acList = ConfigFile::getAccounts(); QValueList<Account>::Iterator ot; for (ot = acList.begin(); ot != acList.end(); ot++) { if (!((*ot).imapServer().isEmpty() || (*ot).imapPort().isEmpty() || (*ot).user().isEmpty() || (*ot).pass().isEmpty())) { if (!((*ot).imapSsl() && (*ot).imapSslPort().isEmpty())) { IMAPHandler *handler = new IMAPHandler(*ot); handler->iStatus("INBOX", "RECENT"); connect(handler, SIGNAL(gotResponse(IMAPResponse&)), SLOT(slotIMAPStatus(IMAPResponse&))); } } } } void BenD::slotIMAPStatus(IMAPResponse &response) { disconnect(response.imapHandler(), SIGNAL(gotResponse(IMAPResponse&)), this, SLOT(slotIMAPStatus(IMAPResponse&))); if (response.statusResponse().status() == IMAPResponseEnums::OK) { if (response.STATUS()[0].recent().toInt() > 0) { ODevice *device = ODevice::inst(); if (isHidden()) show(); if (_config->readBoolEntry("BlinkLed", true)) { if ( !device-> ledList ( ). isEmpty ( )) { OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; device->setLedState(led, device-> ledStateList ( led ). contains ( Led_BlinkSlow ) ? Led_BlinkSlow : Led_On ); } } if (_config->readBoolEntry("PlaySound", false)) device->alarmSound(); } else { ODevice *device = ODevice::inst(); if (!isHidden()) hide(); if ( !device-> ledList ( ). isEmpty ( )) { OLed led = ( device-> ledList ( ). contains ( Led_Mail )) ? Led_Mail : device-> ledList ( ) [0]; device->setLedState(led, Led_Off); } } response.imapHandler()->iLogout(); } else qWarning("BenD: WARNING: Couldn't retrieve INBOX status."); } diff --git a/noncore/unsupported/mail2/composerbase.cpp b/noncore/unsupported/mail2/composerbase.cpp index 94de15c..cac3f26 100644 --- a/noncore/unsupported/mail2/composerbase.cpp +++ b/noncore/unsupported/mail2/composerbase.cpp @@ -1,205 +1,205 @@ #include <qmultilineedit.h> #include <qpopupmenu.h> #include <qcombobox.h> #include <qlineedit.h> #include <qlayout.h> #include <qaction.h> #include <qlabel.h> #include <qvbox.h> -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> #include <qmenubar.h> #include <qpe/resource.h> #include "mailstatusbar.h" #include "listviewplus.h" #include "composerbase.h" ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setCaption(tr("Compose Message")); setToolBarsMovable(false); toolbar = new QToolBar(this); menubar = new QMenuBar( toolbar ); mailmenu = new QPopupMenu( menubar ); menubar->insertItem( tr( "Mail" ), mailmenu ); addToolBar(toolbar); toolbar->setHorizontalStretchable(true); QLabel *spacer = new QLabel(toolbar); spacer->setBackgroundMode(QWidget::PaletteButton); toolbar->setStretchableWidget(spacer); sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this); sendmail->addTo(toolbar); sendmail->addTo(mailmenu); queuemail = new QAction(tr("Queue the mail"), QIconSet(Resource::loadPixmap("mail/sendall")), 0, 0, this); queuemail->addTo(toolbar); queuemail->addTo(mailmenu); attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); attachfile->addTo(toolbar); attachfile->addTo(mailmenu); connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool))); addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this); addressbook->addTo(toolbar); addressbook->addTo(mailmenu); QWidget *main = new QWidget(this); setCentralWidget(main); QGridLayout *layout = new QGridLayout(main); fromBox = new QComboBox(main); fromBox->insertItem(tr("From"), POPUP_FROM_FROM); fromBox->insertItem(tr("Reply"), POPUP_FROM_REPLYTO); layout->addWidget(fromBox, 0, 0); connect(fromBox, SIGNAL(activated(int)), SLOT(slotFromMenuChanged(int))); QHBoxLayout *fromLayout = new QHBoxLayout(); layout->addLayout(fromLayout, 0, 1); from = new QComboBox(main); fromLayout->addWidget(from); replyto = new QLineEdit(main); replyto->hide(); fromLayout->addWidget(replyto); receiversBox = new QComboBox(main); receiversBox->insertItem(tr("To"), POPUP_RECV_TO); receiversBox->insertItem(tr("Cc"), POPUP_RECV_CC); receiversBox->insertItem(tr("Bcc"), POPUP_RECV_BCC); layout->addWidget(receiversBox, 1, 0); connect(receiversBox, SIGNAL(activated(int)), SLOT(slotReceiverMenuChanged(int))); QHBoxLayout *receiverLayout = new QHBoxLayout(); layout->addLayout(receiverLayout, 1, 1); to = new QLineEdit(main); receiverLayout->addWidget(to); cc = new QLineEdit(main); cc->hide(); receiverLayout->addWidget(cc); bcc = new QLineEdit(main); bcc->hide(); receiverLayout->addWidget(bcc); subjectBox = new QComboBox(main); subjectBox->insertItem(tr("Subj."), POPUP_SUBJ_SUBJECT); subjectBox->insertItem(tr("Prio."), POPUP_SUBJ_PRIORITY); layout->addWidget(subjectBox, 2, 0); connect(subjectBox, SIGNAL(activated(int)), SLOT(slotSubjectMenuChanged(int))); QHBoxLayout *subjectLayout = new QHBoxLayout(); layout->addLayout(subjectLayout, 2, 1); subject = new QLineEdit(main); subjectLayout->addWidget(subject); priority = new QComboBox(main); priority->insertItem(tr("Low"), POPUP_PRIO_LOW); priority->insertItem(tr("Normal"), POPUP_PRIO_NORMAL); priority->insertItem(tr("High"), POPUP_PRIO_HIGH); priority->setCurrentItem(POPUP_PRIO_NORMAL); priority->hide(); subjectLayout->addWidget(priority); QVBox *view = new QVBox(main); layout->addMultiCellWidget(view, 3, 3, 0, 1); message = new QMultiLineEdit(view); message->setMinimumHeight(30); attachWindow = new QMainWindow(view, 0, 0); attachWindow->setMinimumHeight(80); attachWindow->setMaximumHeight(80); attachWindow->setToolBarsMovable(false); attachWindow->hide(); attachToolbar = new QToolBar(attachWindow); attachToolbar->setVerticalStretchable(true); addattach = new QAction(tr("Add an Attachement"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this); addattach->addTo(attachToolbar); delattach = new QAction(tr("Remove Attachement"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); delattach->addTo(attachToolbar); QLabel *attachSpacer = new QLabel(attachToolbar); attachSpacer->setBackgroundMode(QWidget::PaletteButton); attachToolbar->setStretchableWidget(attachSpacer); attachWindow->addToolBar(attachToolbar, QMainWindow::Left); attachView = new ListViewPlus(attachWindow); attachView->addColumn(tr("Name"), 80); attachView->addColumn(tr("Description"), 110); attachView->setAllColumnsShowFocus(true); attachWindow->setCentralWidget(attachView); attachPopup = new QPopupMenu(attachView); attachPopup->insertItem(tr("Rename"), POPUP_ATTACH_RENAME); attachPopup->insertItem(tr("Change Description"), POPUP_ATTACH_DESC); attachPopup->insertSeparator(); attachPopup->insertItem(tr("Remove"), POPUP_ATTACH_REMOVE); attachView->setPopup(attachPopup); status = new MailStatusBar(view); } void ComposerBase::slotAttachfileChanged(bool toggled) { if (toggled) { if (attachWindow->isHidden()) attachWindow->show(); } else { if (!attachWindow->isHidden()) attachWindow->hide(); } } void ComposerBase::slotFromMenuChanged(int id) { if (POPUP_FROM_FROM == id) { if (from->isHidden()) from->show(); if (!replyto->isHidden()) replyto->hide(); } else if (POPUP_FROM_REPLYTO == id) { if (!from->isHidden()) from->hide(); if (replyto->isHidden()) replyto->show(); } } void ComposerBase::slotReceiverMenuChanged(int id) { if (POPUP_RECV_TO == id) { if (to->isHidden()) to->show(); if (!cc->isHidden()) cc->hide(); if (!bcc->isHidden()) bcc->hide(); } else if (POPUP_RECV_CC == id) { if (!to->isHidden()) to->hide(); if (cc->isHidden()) cc->show(); if (!bcc->isHidden()) bcc->hide(); } else if (POPUP_RECV_BCC == id) { if (!to->isHidden()) to->hide(); if (!cc->isHidden()) cc->hide(); if (bcc->isHidden()) bcc->show(); } } void ComposerBase::slotSubjectMenuChanged(int id) { if (POPUP_SUBJ_SUBJECT == id) { if (subject->isHidden()) subject->show(); if (!priority->isHidden()) priority->hide(); } else if (POPUP_SUBJ_PRIORITY == id) { if (!subject->isHidden()) subject->hide(); if (priority->isHidden()) priority->show(); } } diff --git a/noncore/unsupported/mail2/main.cpp b/noncore/unsupported/mail2/main.cpp index a11b4e2..fce9b0b 100644 --- a/noncore/unsupported/mail2/main.cpp +++ b/noncore/unsupported/mail2/main.cpp @@ -1,9 +1,10 @@ #include <qpe/qpeapplication.h> +using namespace Opie::Core; #include "mainwindow.h" #include <opie/oapplicationfactory.h> OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) diff --git a/noncore/unsupported/mail2/mainwindowbase.cpp b/noncore/unsupported/mail2/mainwindowbase.cpp index 4e804c2..666cc4a 100644 --- a/noncore/unsupported/mail2/mainwindowbase.cpp +++ b/noncore/unsupported/mail2/mainwindowbase.cpp @@ -1,75 +1,75 @@ #include <qpopupmenu.h> #include <qaction.h> #include <qheader.h> #include <qlabel.h> #include <qvbox.h> -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> #include <qmenubar.h> #include <qpe/resource.h> #include "mainwindowbase.h" #include "mailstatusbar.h" #include "folderwidget.h" #include "mailtable.h" MainWindowBase::MainWindowBase(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setCaption(tr("E-Mail")); setToolBarsMovable(false); toolbar = new QToolBar(this); menubar = new QMenuBar( toolbar ); mailmenu = new QPopupMenu( menubar ); servermenu = new QPopupMenu( menubar ); menubar->insertItem( tr( "Mail" ), mailmenu ); menubar->insertItem( tr( "Servers" ), servermenu ); addToolBar(toolbar); toolbar->setHorizontalStretchable(true); QLabel *spacer = new QLabel(toolbar); spacer->setBackgroundMode(QWidget::PaletteButton); toolbar->setStretchableWidget(spacer); compose = new QAction(tr("Compose new mail"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this); compose->addTo(toolbar); compose->addTo(mailmenu); sendQueue = new QAction(tr("Send queued mails"), QIconSet(Resource::loadPixmap("mail/sendqueue")), 0, 0, this); sendQueue->addTo(toolbar); sendQueue->addTo(mailmenu); folders = new QAction(tr("Show/hide folders"), QIconSet(Resource::loadPixmap("mail/folder")), 0, 0, this, 0, true); folders->addTo(toolbar); folders->addTo(servermenu); connect(folders, SIGNAL(toggled(bool)), SLOT(slotFoldersToggled(bool))); findmails = new QAction(tr("Search mails"), QIconSet(Resource::loadPixmap("mail/find")), 0, 0, this); findmails->addTo(toolbar); findmails->addTo(mailmenu); configure = new QAction(tr("Configuration"), QIconSet(Resource::loadPixmap("mail/configure")), 0, 0, this); configure->addTo(servermenu); QVBox *view = new QVBox(this); setCentralWidget(view); folderView = new FolderWidget(view); folderView->setMinimumHeight(90); folderView->setMaximumHeight(90); folderView->hide(); mailView = new MailTable(view); mailView->setMinimumHeight(50); status = new MailStatusBar(view); } void MainWindowBase::slotFoldersToggled(bool toggled) { if (folderView->isHidden() && toggled) folderView->show(); if (!folderView->isHidden() && !toggled) folderView->hide(); } diff --git a/noncore/unsupported/mail2/viewmailbase.cpp b/noncore/unsupported/mail2/viewmailbase.cpp index f72026f..ff02a7d 100644 --- a/noncore/unsupported/mail2/viewmailbase.cpp +++ b/noncore/unsupported/mail2/viewmailbase.cpp @@ -1,75 +1,75 @@ #include <qtextbrowser.h> #include <qlistview.h> #include <qaction.h> #include <qlabel.h> #include <qvbox.h> #include <qpopupmenu.h> -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> #include <qmenubar.h> #include <qpe/resource.h> #include "viewmailbase.h" #include "opendiag.h" ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setCaption(tr("E-Mail by %1")); setToolBarsMovable(false); toolbar = new QToolBar(this); menubar = new QMenuBar( toolbar ); mailmenu = new QPopupMenu( menubar ); menubar->insertItem( tr( "Mail" ), mailmenu ); toolbar->setHorizontalStretchable(true); addToolBar(toolbar); QLabel *spacer = new QLabel(toolbar); spacer->setBackgroundMode(QWidget::PaletteButton); toolbar->setStretchableWidget(spacer); reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); reply->addTo(toolbar); reply->addTo(mailmenu); forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); forward->addTo(toolbar); forward->addTo(mailmenu); attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); attachbutton->addTo(toolbar); attachbutton->addTo(mailmenu); connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); deleteMail->addTo(toolbar); deleteMail->addTo(mailmenu); QVBox *view = new QVBox(this); setCentralWidget(view); attachments = new QListView(view); attachments->setMinimumHeight(90); attachments->setMaximumHeight(90); attachments->setAllColumnsShowFocus(true); attachments->addColumn("Mime Type", 100); attachments->addColumn("Filename", 100); attachments->addColumn("Description", 100); attachments->hide(); browser = new QTextBrowser(view); openDiag = new OpenDiag(view); openDiag->hide(); } void ViewMailBase::slotChangeAttachview(bool state) { if (state) attachments->show(); else attachments->hide(); } diff --git a/noncore/unsupported/mailit/main.cpp b/noncore/unsupported/mailit/main.cpp index 71f8877..1ccd666 100644 --- a/noncore/unsupported/mailit/main.cpp +++ b/noncore/unsupported/mailit/main.cpp @@ -1,25 +1,26 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qt Palmtop 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 <qpe/qpeapplication.h> #include "mailitwindow.h" #include <opie/oapplicationfactory.h> +using namespace Opie::Core; OPIE_EXPORT_APP( OApplicationFactory<MailItWindow> )
\ No newline at end of file diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index cfaadbf..db4db71 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,399 +1,399 @@ /*************************************************************************** * * * 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. * * * ***************************************************************************/ // (c) 2002 Patrick S. Vogt <tille@handhelds.org> #include "pmipkg.h" #include "pksettings.h" #include "package.h" #include "packagelistitem.h" -//#include <opie/oprocess.h> +//#include <opie2/oprocess.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/stringutil.h> #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qgroupbox.h> #include <qmultilineedit.h> #include <qstring.h> #include <qcheckbox.h> #include <qtextstream.h> #include <qtextview.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qlayout.h> #include <stdlib.h> #include <unistd.h> #include "mainwindow.h" PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) : QObject ( p ) { settings = s; runwindow = new RunWindow( p, name, true, f ); Config cfg( "oipkg", Config::User ); cfg.setGroup( "ipkg" ); ipkg_cmd = cfg.readEntry( "cmd", "ipkg" )+" "; } PmIpkg::~PmIpkg() { } bool PmIpkg::runIpkg(const QString& args, const QString& dest ) { bool ret=false; QDir::setCurrent("/tmp"); QString cmd = ipkg_cmd; pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if (!args.contains("update")) { if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; if ( installDialog && installDialog->_force_depends ) { if (installDialog->_force_depends->isChecked()) cmd += " -force-depends "; if (installDialog->_force_reinstall->isChecked()) cmd += " -force-reinstall "; if (installDialog->_force_remove->isChecked()) cmd += " -force-removal-of-essential-packages "; if (installDialog->_force_overwrite->isChecked()) cmd += " -force-overwrite "; } } //!args.contains("update") out( "Starting to "+ args+"\n"); qApp->processEvents(); cmd += args; out( "running:\n"+cmd+"\n" ); pvDebug(2,"running:"+cmd); qApp->processEvents(); FILE *fp; char line[130]; QString lineStr, lineStrOld; sleep(1); cmd +=" 2>&1"; fp = popen( (const char *) cmd, "r"); if ( fp == NULL ) { qDebug("Could not execute '" + cmd + "'! err=%d", fp); out("\nError while executing "+ cmd+"\n\n"); ret = false; } else { while ( fgets( line, sizeof line, fp) != NULL) { lineStr = line; lineStr=lineStr.left(lineStr.length()-1); //Configuring opie-oipkg...Done if (lineStr.contains("Done")) ret = true; if (lineStr!=lineStrOld) out(lineStr); lineStrOld = lineStr; qApp->processEvents(); } } pclose(fp); pvDebug(2,QString(ret?"success\n":"failure\n")); return ret; } void PmIpkg::makeLinks(OipkgPackage *pack) { pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); QString pn = pack->name(); linkPackage( pack->packageName(), pack->dest() ); } QStringList* PmIpkg::getList( QString packFileName, QString d ) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; // if (dest == "/" ) return 0; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } QString packFileDir = dest+"/"+statusDir+"/info/"+packFileName+".list"; QFile f( packFileDir ); qDebug("Try to open %s", packFileDir.latin1()); if ( ! f.open(IO_ReadOnly) ) { out( "Could not open:\n"+packFileDir ); f.close(); packFileDir = "/"+statusDir+"/info/"+packFileName+".list"; f.setName( packFileDir ); qDebug("Try to open %s", packFileDir.latin1()); if ( ! f.open(IO_ReadOnly) ) { qDebug(" Panik! Could not open"+packFileDir); out( "Could not open:\n"+packFileDir+"\n Panik!" ); return (QStringList*)0; } } QStringList *fileList = new QStringList(); QTextStream t( &f ); while ( !t.eof() ) { *fileList += t.readLine(); } f.close(); return fileList; } void PmIpkg::linkPackage( QString packFileName, QString dest ) { if (dest == "root" || dest == "/" ) return; QStringList *fileList = getList( packFileName, dest ); processFileList( fileList, dest ); delete fileList; } void PmIpkg::processFileList( QStringList *fileList, QString d ) { if (!fileList || fileList->isEmpty()) return; for (uint i=0; i < fileList->count(); i++) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; processLinkDir( (*fileList)[i], dest ); } } void PmIpkg::processLinkDir( QString file, QString dest ) { pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); if ( dest == "???" || dest == "" ) return; QString destFile = file; file = dest+"/"+file; if (file == dest) return; // if (linkOpp==createLink) out( "\ncreating links\n" ); // if (linkOpp==removeLink) out( "\nremoving links\n" ); QFileInfo fileInfo( file ); if ( fileInfo.isDir() ) { pvDebug(4, "process dir "+file); QDir destDir( destFile ); if (linkOpp==createLink) destDir.mkdir( destFile, true ); QDir d( file ); // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { pvDebug(4, "processLinkDir "+fi->absFilePath()); processLinkDir( fi->absFilePath(), dest ); ++it; } } else if ( fileInfo.isFile() ) { const char *instFile = strdup( (file).latin1() ); const char *linkFile = strdup( (destFile).latin1()); if( linkOpp==createLink ) { pvDebug(4, "linking: "+file+" -> "+destFile ); symlink( instFile, linkFile ); } } else { const char *linkFile = strdup( (destFile).latin1()); if( linkOpp==removeLink ) { QFileInfo toRemoveLink( destFile ); if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) { pvDebug(4,"removing "+destFile+" no "+file); unlink( linkFile ); } } } } void PmIpkg::loadList( PackageList *pl ) { for( OipkgPackage *pack = pl->first();pack ; (pack = pl->next()) ) { if ( pack && (pack->name() != "") && pack) { if ( pack->toInstall() ) to_install.append( pack ); if ( pack->toRemove() ) to_remove.append( pack ); } } } void PmIpkg::commit() { int sizecount = 0; installDialog = new InstallDialog(settings,0,0,true); installDialog->toRemoveItem->setOpen( true ); installDialog->toInstallItem->setOpen( true ); for (uint i=0; i < to_remove.count(); i++) { sizecount += 1; installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); } for (uint i=0; i < to_install.count(); i++) { sizecount += to_install.at(i)->size().toInt(); installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); } runwindow->progress->setTotalSteps(sizecount); qDebug("Install size %i",sizecount); installDialog->showMaximized(); installDialog->show(); if ( installDialog->exec() ) { doIt(); runwindow->showMaximized(); runwindow->show(); } installDialog->close(); delete installDialog; installDialog = 0; out(tr("\nAll done.")); } void PmIpkg::doIt() { runwindow->progress->setProgress(0); show(); remove(); install(); } void PmIpkg::remove() { if ( to_remove.count() == 0 ) return; out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); QStringList *fileList = new QStringList; for (uint i=0; i < to_remove.count(); i++) { if ( to_remove.at(i)->link() ) fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) { runwindow->progress->setProgress( 1 ); linkOpp = removeLink; to_remove.at(i)->processed(); pvDebug(3,"link "+QString::number(i)); if ( to_remove.at(i)->link() ) processFileList( fileList, to_remove.at(i)->dest() ); //pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count())); //if ( to_remove.at(i) ) to_remove.take( i ); out("\n"); }else{ out(tr("Error while removing ")+to_remove.at(i)->name()+"\n"); if ( to_remove.at(i)->link() ) processFileList( fileList, to_remove.at(i)->dest() ); } if ( to_remove.at(i)->link() ) processFileList( fileList, to_remove.at(i)->dest() ); if ( to_remove.at(i)->link() )delete fileList; } to_remove.clear(); out("\n"); } void PmIpkg::install() { if ( to_install.count() == 0 ) return; out(tr("Installing")+"\n"+tr("please wait")+"\n"); for (uint i=0; i < to_install.count(); i++) { qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug if (to_install.at(i)->link()) { // hack to have package.list // in "dest"/usr/lib/ipkg/info/ QString rds = settings->getDestinationUrlByName("root"); QString lds = settings->getDestinationUrlByName(to_install.at(i)->dest()); QString listFile = "usr/lib/ipkg/lists/"+to_install.at(i)->name()+".list"; rds += listFile; lds += listFile; const char *rd = rds.latin1(); const char *ld = lds.latin1(); pvDebug(4, "linking: "+rds+" -> "+lds ); symlink( rd, ld ); } if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) { runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); to_install.at(i)->processed(); linkOpp = createLink; if ( to_install.at(i)->link() ) makeLinks( to_install.at(i) ); // to_install.take( i ); out("\n"); }else{ out(tr("Error while installing")+to_install.at(i)->name()+"\n"); linkOpp = createLink; if ( to_install.at(i)->link() ) makeLinks( to_install.at(i) ); } } out("\n"); to_install.clear(); } void PmIpkg::createLinks( const QString &dest ) { pvDebug(2,"PmIpkg::createLinks "+dest); linkOpp=createLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::removeLinks( const QString &dest ) { pvDebug(2,"PmIpkg::removeLinks "+dest); linkOpp=removeLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::update() { show(); runIpkg( "update" ); } void PmIpkg::out( QString o ) { // runwindow->outPut->append(o); runwindow->outPut->setText(runwindow->outPut->text()+o); runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); } diff --git a/noncore/unsupported/qpdf/qpdf.cpp b/noncore/unsupported/qpdf/qpdf.cpp index 75e86d0..df9df54 100644 --- a/noncore/unsupported/qpdf/qpdf.cpp +++ b/noncore/unsupported/qpdf/qpdf.cpp @@ -1,407 +1,407 @@ //======================================================================== // // qpdf.cc // // Copyright 2001 Robert Griebl // //======================================================================== #include "aconf.h" #include "GString.h" #include "PDFDoc.h" #include "TextOutputDev.h" #include "QPEOutputDev.h" #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/applnk.h> #include <qpe/qcopenvelope_qws.h> #include <qclipboard.h> -#include <qpe/qpetoolbar.h> +#include <qtoolbar.h> #include <qtoolbutton.h> #include <qmenubar.h> #include <qpopupmenu.h> #include <qwidgetstack.h> #include <qtimer.h> #include <qfileinfo.h> #include <qstring.h> #include <qlineedit.h> #include <qspinbox.h> #include <qlayout.h> #include <qdialog.h> #include <qlabel.h> #include <qmessagebox.h> #include "qpdf.h" #ifdef QPDF_QPE_ONLY #include <qpe/fileselector.h> #else #include <opie/ofileselector.h> #endif int main ( int argc, char **argv ) { QPEApplication app ( argc, argv ); // read config file globalParams = new GlobalParams ( "" ); globalParams-> setErrQuiet ( true ); QPdfDlg *dlg = new QPdfDlg ( ); app. showMainDocumentWidget ( dlg ); if (( app. argc ( ) == 3 ) && ( app. argv ( ) [1] == QCString ( "-f" ))) dlg-> openFile ( app. argv ( ) [2] ); return app. exec ( ); } QPdfDlg::QPdfDlg ( ) : QMainWindow ( ) { setCaption ( tr( "QPdf" )); setIcon ( Resource::loadPixmap ( "qpdf_icon" )); m_busy = false; m_doc = 0; m_pages = 0; m_zoom = 72; m_currentpage = 0; m_fullscreen = false; m_renderok = false; setToolBarsMovable ( false ); m_stack = new QWidgetStack ( this ); m_stack-> setSizePolicy ( QSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding )); setCentralWidget ( m_stack ); m_outdev = new QPEOutputDev ( m_stack ); connect ( m_outdev, SIGNAL( selectionChanged(const QRect&)), this, SLOT( copyToClipboard(const QRect&))); #ifdef QPDF_QPE_ONLY m_filesel = new FileSelector ( "application/pdf", m_stack, "fs", false, true ); #else m_filesel = new OFileSelector ( "application/pdf", m_stack, "fs", false, true ); #endif connect ( m_filesel, SIGNAL( closeMe()), this, SLOT( closeFileSelector())); connect ( m_filesel, SIGNAL( fileSelected(const DocLnk&)), this, SLOT( openFile(const DocLnk&))); m_tb_menu = new QToolBar ( this ); m_tb_menu-> setHorizontalStretchable ( true ); QMenuBar *mb = new QMenuBar ( m_tb_menu ); m_pm_zoom = new QPopupMenu ( mb ); m_pm_zoom-> setCheckable ( true ); mb-> insertItem ( tr( "Zoom" ), m_pm_zoom ); m_pm_zoom-> insertItem ( tr( "Fit to width" ), 1 ); m_pm_zoom-> insertItem ( tr( "Fit to page" ), 2 ); m_pm_zoom-> insertSeparator ( ); m_pm_zoom-> insertItem ( tr( "50%" ), 50 ); m_pm_zoom-> insertItem ( tr( "75%" ), 75 ); m_pm_zoom-> insertItem ( tr( "100%" ), 100 ); m_pm_zoom-> insertItem ( tr( "125%" ), 125 ); m_pm_zoom-> insertItem ( tr( "150%" ), 150 ); m_pm_zoom-> insertItem ( tr( "200%" ), 200 ); connect ( m_pm_zoom, SIGNAL( activated(int)), this, SLOT( setZoom(int))); m_tb_tool = new QToolBar ( this ); new QToolButton ( Resource::loadIconSet ( "fileopen" ), tr( "Open..." ), QString::null, this, SLOT( openFile()), m_tb_tool, "open" ); m_tb_tool-> addSeparator ( ); m_to_find = new QToolButton ( Resource::loadIconSet ( "find" ), tr( "Find..." ), QString::null, this, SLOT( toggleFindBar()), m_tb_tool, "find" ); m_to_find-> setToggleButton ( true ); m_tb_tool-> addSeparator ( ); m_to_full = new QToolButton ( Resource::loadIconSet ( "fullscreen" ), tr( "Fullscreen" ), QString::null, this, SLOT( toggleFullscreen()), m_tb_tool, "fullscreen" ); m_to_full-> setToggleButton ( true ); m_tb_tool-> addSeparator ( ); new QToolButton ( Resource::loadIconSet ( "fastback" ), tr( "First page" ), QString::null, this, SLOT( firstPage()), m_tb_tool, "first" ); new QToolButton ( Resource::loadIconSet ( "back" ), tr( "Previous page" ), QString::null, this, SLOT( prevPage()), m_tb_tool, "prev" ); new QToolButton ( Resource::loadIconSet ( "down" ), tr( "Goto page..." ), QString::null, this, SLOT( gotoPageDialog()), m_tb_tool, "goto" ); new QToolButton ( Resource::loadIconSet ( "forward" ), tr( "Next page" ), QString::null, this, SLOT( nextPage()), m_tb_tool, "next" ); new QToolButton ( Resource::loadIconSet ( "fastforward" ), tr( "Last page" ), QString::null, this, SLOT( lastPage()), m_tb_tool, "last" ); m_tb_find = new QToolBar ( this ); addToolBar ( m_tb_find, "Search", QMainWindow::Top, true ); m_tb_find-> setHorizontalStretchable ( true ); m_tb_find-> hide ( ); m_findedit = new QLineEdit ( m_tb_find, "findedit" ); m_tb_find-> setStretchableWidget ( m_findedit ); connect ( m_findedit, SIGNAL( textChanged(const QString&)), this, SLOT( findText(const QString&))); new QToolButton ( Resource::loadIconSet ( "next" ), tr( "Next" ), QString::null, this, SLOT( findText()), m_tb_find, "findnext" ); openFile ( ); } QPdfDlg::~QPdfDlg ( ) { delete m_doc; } // vv Fullscreen handling (for broken QT-lib) [David Hedbor, www.eongames.com] void QPdfDlg::resizeEvent ( QResizeEvent * ) { if ( m_fullscreen && ( size ( ) != qApp-> desktop ( )-> size ( ))) setFullscreen ( true ); } void QPdfDlg::focusInEvent ( QFocusEvent * ) { if ( m_fullscreen ) setFullscreen ( true ); } void QPdfDlg::toggleFullscreen ( ) { if ( m_to_full-> isOn ( ) == m_fullscreen ) m_to_full-> setOn ( !m_fullscreen ); m_fullscreen = !m_fullscreen; setFullscreen ( m_fullscreen ); } void QPdfDlg::setFullscreen ( bool b ) { static QSize normalsize; if ( b ) { if ( !normalsize. isValid ( )) normalsize = size ( ); setFixedSize ( qApp-> desktop ( )-> size ( )); showNormal ( ); reparent ( 0, WStyle_Customize | WStyle_NoBorder, QPoint ( 0, 0 )); showFullScreen ( ); } else { showNormal ( ); reparent ( 0, 0, QPoint ( 0, 0 )); resize ( normalsize ); showMaximized ( ); normalsize = QSize ( ); } } // ^^ Fullscreen handling (for broken QT-lib) void QPdfDlg::setBusy ( bool b ) { if ( b != m_busy ) { m_busy = b; m_outdev-> setBusy ( m_busy ); setEnabled ( !m_busy ); } } bool QPdfDlg::busy ( ) const { return m_busy; } void QPdfDlg::updateCaption ( ) { QString cap = ""; if ( !m_currentdoc. isEmpty ( )) cap = QString ( "%1 - " ). arg ( m_currentdoc ); cap += "QPdf"; setCaption ( cap ); } void QPdfDlg::setZoom ( int id ) { int dpi = 0; switch ( id ) { case 1: if ( m_doc && m_doc-> isOk ( )) dpi = m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage ); break; case 2: if ( m_doc && m_doc-> isOk ( )) dpi = QMIN( m_outdev-> visibleWidth ( ) * 72 / m_doc-> getPageWidth ( m_currentpage ), \ m_outdev-> visibleHeight ( ) * 72 / m_doc-> getPageHeight ( m_currentpage )); break; default: dpi = id * 72 / 100; break; } if ( dpi < 18 ) dpi = 18; if ( dpi > 216 ) dpi = 216; for ( uint i = 0; i < m_pm_zoom-> count ( ); i++ ) { int xid = m_pm_zoom-> idAt ( i ); m_pm_zoom-> setItemChecked ( xid, xid == id ); } if ( dpi != m_zoom ) { m_zoom = dpi; renderPage ( ); } } void QPdfDlg::gotoPageDialog ( ) { QDialog *d = new QDialog ( this, "gotodlg", true ); d-> setCaption ( tr( "Goto page" )); QBoxLayout *lay = new QVBoxLayout ( d, 4, 4 ); QLabel *l = new QLabel ( tr( "Select from 1 .. %1:" ). arg ( m_pages ), d ); lay-> addWidget ( l ); QSpinBox *spin = new QSpinBox ( 1, m_pages, 1, d ); spin-> setValue ( m_currentpage ); spin-> setWrapping ( true ); spin-> setButtonSymbols ( QSpinBox::PlusMinus ); lay-> addWidget ( spin ); if ( d-> exec ( ) == QDialog::Accepted ) { gotoPage ( spin-> value ( )); } delete d; } void QPdfDlg::toggleFindBar ( ) { if ( m_to_find-> isOn ( ) == m_tb_find-> isVisible ( )) m_to_find-> setOn ( !m_tb_find-> isVisible ( )); if ( m_tb_find-> isVisible ( )) { m_tb_find-> hide ( ); m_outdev-> setFocus ( ); } else { m_tb_find-> show ( ); m_findedit-> setFocus ( ); } } void QPdfDlg::findText ( const QString &str ) { if ( !m_doc || !m_doc-> isOk ( ) || str. isEmpty ( )) return; TextOutputDev *textOut = 0; int pg = 0; setBusy ( true ); int len = str. length ( ); Unicode *u = new Unicode [len]; for ( int i = 0; i < len; i++ ) u [i] = str [i]. unicode ( ); int xMin = 0, yMin = 0, xMax = 0, yMax = 0; QRect selr = m_outdev-> selection ( ); bool fromtop = true; if ( selr. isValid ( )) { xMin = selr. right ( ); yMin = selr. top ( ) + selr. height ( ) / 2; fromtop = false; } if ( m_outdev-> findText ( u, len, fromtop, true, &xMin, &yMin, &xMax, &yMax )) goto found; qApp-> processEvents ( ); // search following pages textOut = new TextOutputDev ( 0, gFalse, gFalse ); if ( !textOut-> isOk ( )) goto done; qApp-> processEvents ( ); for ( pg = ( m_currentpage % m_pages ) + 1; pg != m_currentpage; pg = ( pg % m_pages ) + 1 ) { m_doc-> displayPage ( textOut, pg, 72, 0, gFalse ); fp_t xMin1, yMin1, xMax1, yMax1; qApp-> processEvents ( ); if ( textOut-> findText ( u, len, gTrue, gTrue, &xMin1, &yMin1, &xMax1, &yMax1 )) goto foundPage; qApp-> processEvents ( ); } // search current page ending at current selection if ( selr. isValid ( )) { xMax = selr. left ( ); yMax = selr. top ( ) + selr. height ( ) / 2; if ( m_outdev-> findText ( u, len, gTrue, gFalse, &xMin, &yMin, &xMax, &yMax )) goto found; } // not found QMessageBox::information ( this, tr( "Find..." ), tr( "'%1' could not be found." ). arg ( str )); goto done; foundPage: qApp-> processEvents ( ); gotoPage ( pg ); if ( !m_outdev-> findText ( u, len, gTrue, gTrue, &xMin, &yMin, &xMax, &yMax )) { // this can happen if coalescing is bad goto done; } found: selr. setCoords ( xMin, yMin, xMax, yMax ); m_outdev-> setSelection ( selr, true ); // this will emit QPEOutputDev::selectionChanged ( ) -> copyToClipboard ( ) done: delete [] u; delete textOut; setBusy ( false ); } void QPdfDlg::findText ( ) { findText ( m_findedit-> text ( )); } void QPdfDlg::copyToClipboard ( const QRect &r ) { if ( m_doc && m_doc-> isOk ( ) && m_doc-> okToCopy ( )) qApp-> clipboard ( )-> setText ( m_outdev-> getText ( r )); } void QPdfDlg::firstPage ( ) { gotoPage ( 1 ); |