From 1af1f1d9f398d38a2bc666cd2edff5725da7a770 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Wed, 29 Oct 2003 18:18:19 +0000 Subject: mrege noncore/net/* --- diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 90664bb..8359acf 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp @@ -42,31 +42,31 @@ MailAccount* AccountList::dupl(MailAccount *in) EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) -{ +{ emailHandler = new EmailHandler(); addressList = new AddressList(); - + sending = FALSE; receiving = FALSE; previewingMail = FALSE; mailIdCount = 1; accountIdCount = 1; allAccounts = FALSE; - + init(); - - - + + + connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); - + connect(emailHandler, SIGNAL(smtpError(int,const QString &)), this, SLOT(smtpError(int,const QString &)) ); connect(emailHandler, SIGNAL(popError(int,const QString &)), this, SLOT(popError(int,const QString &)) ); - + connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); - + connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); @@ -74,20 +74,20 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) SLOT(mailArrived(const Email &, bool)) ); connect(emailHandler, SIGNAL(mailTransfered(int)), this, SLOT(allMailArrived(int)) ); - + mailconf = new Config("mailit"); //In case Synchronize is not defined in settings.txt readSettings(); - + updateAccounts(); - + lineShift = "\n"; readMail(); lineShift = "\r\n"; - + mailboxView->setCurrentTab(0); //ensure that inbox has focus - + /*channel = new QCopChannel( "QPE/Application/mailit", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );*/ @@ -104,18 +104,18 @@ EmailClient::~EmailClient() //different properties saveMail(getPath(FALSE) + "outbox.txt", outboxView); saveSettings(); - + mailconf->write(); delete mailconf; - + } void EmailClient::init() { initStatusBar(this); - + setToolBarsMovable(FALSE); - + bar = new QToolBar(this); QWhatsThis::add(bar,tr("Main operation toolbar")); bar->setHorizontalStretchable( TRUE ); @@ -127,7 +127,7 @@ void EmailClient::init() QPopupMenu *configure = new QPopupMenu(mb); mb->insertItem( tr( "Accounts" ), configure); - + selectAccountMenu = new QPopupMenu(mb); editAccountMenu = new QPopupMenu(mb); deleteAccountMenu = new QPopupMenu(mb); @@ -142,32 +142,32 @@ void EmailClient::init() QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); getMailButton->setPopup(selectAccountMenu); - + sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); sendMailButton->addTo(bar); sendMailButton->addTo(mail); sendMailButton->setWhatsThis("Send mail queued in the outbox"); - + composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); composeButton->addTo(bar); composeButton->addTo(mail); composeButton->setWhatsThis("Compose a new mail"); - + cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); cancelButton->addTo(mail); cancelButton->addTo(bar); cancelButton->setEnabled(FALSE); cancelButton->setWhatsThis("Stop the currently active mail transfer"); - - + + deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); deleteButton->addTo(bar); deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); - + mailboxView = new OTabWidget( this, "mailboxView" ); QWidget* widget = new QWidget( mailboxView, "widget" ); @@ -205,23 +205,23 @@ void EmailClient::init() "reviewed by double clicking the entry.")); grid_3->addWidget( outboxView, 0, 0 ); mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); - + setCentralWidget(mailboxView); - + } void EmailClient::initStatusBar(QWidget* parent) { statusBar = new QStatusBar(parent); statusBar->setSizeGripEnabled(FALSE); - + status1Label = new QLabel( tr("Idle"), statusBar); status2Label = new QLabel("", statusBar); connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); - + progressBar = new QProgressBar(statusBar); connect(emailHandler, SIGNAL(mailboxSize(int)), @@ -260,20 +260,20 @@ void EmailClient::enqueMail(const Email &mail) tr("No account selected"), tr("You must create an account"), "OK\n"); return; } - + if (accountList.count() > 0) { currentAccount = accountList.first(); qWarning("using account " + currentAccount->name); } - + Email addMail = mail; addMail.from = currentAccount->name; addMail.fromMail = currentAccount->emailAddress; addMail.rawMail.prepend("From: \"" + addMail.from + "\" <" + addMail.fromMail + ">\n"); item = new EmailListItem(outboxView, addMail, false); - + mailboxView->setCurrentTab(1); - + } void EmailClient::sendQuedMail() @@ -281,7 +281,7 @@ void EmailClient::sendQuedMail() int count = 0; if (accountList.count() == 0) { - QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); + QMessageBox::warning(qApp->activeWindow(), tr("No account selected"), tr("You must create an account"), "OK\n"); return; } //traverse listview, find messages to send @@ -313,30 +313,30 @@ void EmailClient::mailSent() { sending = FALSE; sendMailButton->setEnabled(TRUE); - + quedMessages.clear(); outboxView->clear(); //should be moved to an sentBox } void EmailClient::getNewMail() { - + if (accountList.count() == 0) { - QMessageBox::warning(qApp->activeWindow(),"No account selected", - "You must create an account", "OK\n"); + QMessageBox::warning(qApp->activeWindow(),tr("No account selected"), + tr("You must create an account"), "OK\n"); return; } - + setMailAccount(); - + receiving = TRUE; previewingMail = TRUE; getMailButton->setEnabled(FALSE); cancelButton->setEnabled(TRUE); selectAccountMenu->setEnabled(FALSE); - + status1Label->setText(currentAccount->accountName + " headers"); progressBar->reset(); - + //get any previous mails not downloaded and add to queue /*mailDownloadList.clear(); Email *mailPtr; @@ -348,16 +348,16 @@ void EmailClient::getNewMail() { } item = (EmailListItem *) item->nextSibling(); }*/ - + emailHandler->getMailHeaders(); - + } void EmailClient::getAllNewMail() { allAccounts = TRUE; currentAccount = accountList.first(); - getNewMail(); + getNewMail(); } void EmailClient::mailArrived(const Email &mail, bool fromDisk) @@ -367,57 +367,57 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) int thisMailId; emailHandler->parse( mail.rawMail, lineShift, &newMail); mailconf->setGroup(newMail.id); - - if (fromDisk) + + if (fromDisk) { - + newMail.downloaded = mailconf->readBoolEntry("downloaded"); newMail.size = mailconf->readNumEntry("size"); newMail.serverId = mailconf->readNumEntry("serverid"); newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); - } - else + } + else { //mail arrived from server - + newMail.serverId = mail.serverId; newMail.size = mail.size; newMail.downloaded = mail.downloaded; - + newMail.fromAccountId = emailHandler->getAccount()->id; mailconf->writeEntry("fromaccountid", newMail.fromAccountId); } - + //add if read or not newMail.read = mailconf->readBoolEntry("mailread"); - + //check if new mail if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { thisMailId = mailIdCount; mailIdCount++; - + //set server count, so that if the user aborts, the new //header is not reloaded if ((currentAccount)&&(currentAccount->synchronize)) currentAccount->lastServerMailCount++; - + mailconf->writeEntry("internalmailid", thisMailId); mailconf->writeEntry("downloaded", newMail.downloaded); mailconf->writeEntry("size", (int) newMail.size); mailconf->writeEntry("serverid", newMail.serverId); - + //addressList->addContact(newMail.fromMail, newMail.from); } - + mailconf->writeEntry("downloaded", newMail.downloaded); - + QString stringMailId; stringMailId.setNum(thisMailId); //see if any attatchments needs to be stored - + for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { QString stringId; stringId.setNum(ePtr->id); - + int id = mailconf->readNumEntry("enclosureid_" + stringId); if (id != ePtr->id) { //new entry mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); @@ -426,7 +426,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); mailconf->writeEntry("saved_" + stringId, ePtr->saved); mailconf->writeEntry("installed_" + stringId, FALSE); - + ePtr->name = stringMailId + "_" + stringId; ePtr->path = getPath(TRUE); if (emailHandler->getEnclosure(ePtr)) { //file saved @@ -444,18 +444,18 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) if (ePtr->saved) { ePtr->name = mailconf->readEntry("filename_" + stringId); ePtr->path = mailconf->readEntry("path_" + stringId); - } + } } } bool found=false; - - if (!fromDisk) + + if (!fromDisk) { - + Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); - while ((item != NULL)&&(!found)) + while ((item != NULL)&&(!found)) { mailPtr = item->getMail(); if (mailPtr->id == newMail.id) { @@ -472,12 +472,12 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) // if (item->getMail()->files.count()>0) // { // item->setPixmap(0, Resource::loadPixmap("mailit/attach")); -// } +// } /*if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ - + mailboxView->setCurrentTab(0); - + } void EmailClient::allMailArrived(int /*count*/) @@ -495,18 +495,18 @@ void EmailClient::allMailArrived(int /*count*/) cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); status1Label->setText("Idle"); - + progressBar->reset(); return; } //} - + // all headers downloaded from server, start downloading remaining mails previewingMail = FALSE; status1Label->setText(currentAccount->accountName); progressBar->reset(); - + mailboxView->setCurrentTab(0); } @@ -521,7 +521,7 @@ void EmailClient::moveMailFront(Email *mailPtr) void EmailClient::smtpError(int code, const QString & Msg) { QString temp; - + if (code == ErrUnknownResponse) { temp = tr("Unknown response from server"); if( ! Msg.isEmpty() ) @@ -533,13 +533,13 @@ void EmailClient::smtpError(int code, const QString & Msg) } else if (code == QSocket::ErrSocketRead) { temp = tr("socket packet error"); } - + if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); } else { status2Label->setText("Aborted by user"); } - + sending = FALSE; sendMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); @@ -549,7 +549,7 @@ void EmailClient::smtpError(int code, const QString & Msg) void EmailClient::popError(int code, const QString & Msg) { QString temp; - + if (code == ErrUnknownResponse) { temp = tr("Unknown response from server"); if( ! Msg.isEmpty() ) @@ -562,7 +562,7 @@ void EmailClient::popError(int code, const QString & Msg) temp = tr("connection refused"); } else if (code == QSocket::ErrSocketRead) { temp = tr("socket packet error"); - } + } if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), tr("Receiving error"), temp, tr("OK\n")); @@ -570,7 +570,7 @@ void EmailClient::popError(int code, const QString & Msg) } else { status2Label->setText("Aborted by user"); } - + receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); @@ -580,7 +580,7 @@ void EmailClient::popError(int code, const QString & Msg) void EmailClient::inboxItemSelected() { //killTimer(timerID); - + item = (EmailListItem*) inboxView->selectedItem(); if (item != NULL) { emit viewEmail(inboxView, item->getMail()); @@ -590,7 +590,7 @@ void EmailClient::inboxItemSelected() void EmailClient::outboxItemSelected() { //killTimer(timerID); - + item = (EmailListItem*) outboxView->selectedItem(); if (item != NULL) { emit viewEmail(outboxView, item->getMail()); @@ -605,45 +605,45 @@ void EmailClient::readMail() QString s, del; QFile f(getPath(FALSE) + "inbox.txt"); - + if ( f.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &f ); // use a text stream s = t.read(); f.close(); - + start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); - + mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); mailArrived(mail, TRUE); } } - + QFile fo(getPath(FALSE) + "outbox.txt"); if ( fo.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &fo ); // use a text stream s = t.read(); fo.close(); - + start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); - + mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); emailHandler->parse(mail.rawMail, lineShift, &mail); mail.sent = false; mail.received = false; enqueMail(mail); - + } } } @@ -652,7 +652,7 @@ void EmailClient::saveMail(const QString &fileName, QListView *view) { QFile f(fileName); Email *mail; - + if (! f.open(IO_WriteOnly) ) { qWarning("could not open file"); return; @@ -662,10 +662,10 @@ void EmailClient::saveMail(const QString &fileName, QListView *view) while (item != NULL) { mail = item->getMail(); t << mail->rawMail; - + mailconf->setGroup(mail->id); mailconf->writeEntry("mailread", mail->read); - + item = (EmailListItem *) item->nextSibling(); } f.close(); @@ -676,19 +676,19 @@ QString EmailClient::getPath(bool enclosurePath) { QString basePath = "qtmail"; QString enclosures = "enclosures"; - + QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); if ( !dir.exists() ) dir.mkdir( dir.path() ); - + if (enclosurePath) { dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); - + if ( !dir.exists() ) dir.mkdir( dir.path() ); - + return (dir.path() + "/"); - + } return (dir.path() + "/"); } @@ -696,13 +696,13 @@ QString EmailClient::getPath(bool enclosurePath) void EmailClient::readSettings() { int y,acc_count; - + mailconf->setGroup("mailitglobal"); acc_count=mailconf->readNumEntry("Accounts",0); - - for (int accountPos = 0;accountPossetGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... + mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... account.accountName = mailconf->readEntry("AccName",""); account.name = mailconf->readEntry("UserName",""); account.emailAddress = mailconf->readEntry("Email",""); @@ -714,23 +714,23 @@ void EmailClient::readSettings() account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); account.lastServerMailCount = 0; account.synchronize = FALSE; - + account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); if (account.synchronize) { - mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); + mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); } - + accountList.append(&account); } - + mailconf->setGroup("mailitglobal"); - - if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) + + if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { mailIdCount = y; } - if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) + if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { accountIdCount = y; } @@ -741,15 +741,15 @@ void EmailClient::saveSettings() int acc_count=0; MailAccount *accountPtr; - - if (!mailconf) + + if (!mailconf) { qWarning("could not save settings"); return; } - + for (accountPtr = accountList.first(); accountPtr != 0; - accountPtr = accountList.next()) + accountPtr = accountList.next()) { mailconf->setGroup("Account_"+QString::number(++acc_count)); mailconf->writeEntry("AccName",accountPtr->accountName ); @@ -760,18 +760,18 @@ void EmailClient::saveSettings() mailconf->writeEntry("POPServer",accountPtr->popServer); mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); mailconf->writeEntry("AccountId",accountPtr->id); - if (accountPtr->synchronize) + if (accountPtr->synchronize) { mailconf->writeEntry("Synchronize","Yes"); mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); - } - else + } + else { mailconf->writeEntry("Synchronize", "No"); } } - + mailconf->setGroup("mailitglobal"); mailconf->writeEntry("Accounts",acc_count); mailconf->writeEntry("mailidcount", mailIdCount); @@ -785,14 +785,14 @@ void EmailClient::selectAccount(int id) emit newCaption("Mailit - " + currentAccount->accountName); getNewMail(); } else { - emit newCaption("Mailit ! No account defined"); + emit newCaption( tr("Mailit ! No account defined") ); } } void EmailClient::editAccount(int id) { MailAccount *newAccount; - + editAccountView = new EditAccount(this, "account", TRUE); if (id == newAccountId) { //new account newAccount = new MailAccount; @@ -801,10 +801,10 @@ void EmailClient::editAccount(int id) newAccount = accountList.at(id); editAccountView->setAccount(newAccount, FALSE); } - + editAccountView->showMaximized(); editAccountView->exec(); - + if (editAccountView->result() == QDialog::Accepted) { if (id == newAccountId) { newAccount->id = accountIdCount; @@ -815,7 +815,7 @@ void EmailClient::editAccount(int id) updateAccounts(); } } - + delete editAccountView; } @@ -823,12 +823,12 @@ void EmailClient::deleteAccount(int id) { MailAccount *newAccount; QString message; - + newAccount = accountList.at(id); - message = "Delete account:\n" + newAccount->accountName; + message = tr("Delete account:\n") + newAccount->accountName; switch( QMessageBox::warning( this, "Mailit", message, "Yes", "No", 0, 0, 1 ) ) { - + case 0: accountList.remove(id); updateAccounts(); break; @@ -840,20 +840,20 @@ void EmailClient::deleteAccount(int id) void EmailClient::updateAccounts() { MailAccount *accountPtr; - + //rebuild menus, clear all first editAccountMenu->clear(); selectAccountMenu->clear(); deleteAccountMenu->clear(); - newAccountId = editAccountMenu->insertItem("New", this, + newAccountId = editAccountMenu->insertItem( tr("New"), this, SLOT(editAccount(int)) ); editAccountMenu->insertSeparator(); - + idCount = 0; for (accountPtr = accountList.first(); accountPtr != 0; accountPtr = accountList.next()) { - + editAccountMenu->insertItem(accountPtr->accountName, this, SLOT(editAccount(int)), 0, idCount); selectAccountMenu->insertItem(accountPtr->accountName, @@ -868,21 +868,21 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) { Email *mPtr; Enclosure *ePtr; - - if (inbox) + + if (inbox) { mPtr = mailItem->getMail(); - + //if mail is in queue for download, remove it from //queue if possible if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { if ( !mPtr->downloaded ) mailDownloadList.remove(mPtr->serverId, mPtr->size); } - + mailconf->setGroup(mPtr->id); mailconf->clearGroup(); - + //delete any temporary attatchemnts storing for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { if (ePtr->saved) { @@ -890,8 +890,8 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) } } inboxView->takeItem(mailItem); - } - else + } + else { outboxView->takeItem(mailItem); } @@ -905,7 +905,7 @@ void EmailClient::setMailSize(int size) void EmailClient::setTotalSize(int /*size*/) { - + } void EmailClient::setDownloadedSize(int size) @@ -923,18 +923,18 @@ void EmailClient::deleteItem() { bool inbox=mailboxView->currentTab()==0; QListView* box; - + EmailListItem* eli; // int pos; - + inbox ? box=inboxView : box=outboxView; - + eli=(EmailListItem*)box->selectedItem(); - + if (eli) { box->setSelected(eli->itemBelow(),true); //select the previous item - + deleteMail(eli,(bool&)inbox); //remove mail entry } } @@ -952,21 +952,21 @@ void EmailClient::inboxItemReleased() /*void EmailClient::timerEvent(QTimerEvent *e) { //killTimer(timerID); - - + + QPopupMenu *action = new QPopupMenu(this); - + int reply=0; - + action->insertItem(tr( "Reply To" ),this,SLOT(reply())); action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); action->insertItem( tr( "Forward" ), this,SLOT(forward())); action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); - + action->exec(QCursor::pos()); - + if (action) delete action; - + }*/ Email* EmailClient::getCurrentMail() @@ -977,21 +977,21 @@ Email* EmailClient::getCurrentMail() else return NULL; } - + void EmailClient::download(Email* mail) { MailAccount* acc=0; - + tempMailDownloadList.clear(); tempMailDownloadList.sizeInsert(mail->serverId, mail->size); - + acc=accountList.at(mail->fromAccountId-1); if (acc) - { + { emailHandler->setAccount(*acc); emailHandler->getMailByList(&tempMailDownloadList); } - else + else QMessageBox::warning(qApp->activeWindow(), tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); } @@ -1002,9 +1002,9 @@ void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/) { //QDialog qd(qApp->activeWindow(),"Getting mail",true); QVBoxLayout *vbProg = new QVBoxLayout( &qd ); - + initStatusBar(&qd); - + if (statusBar==0) { qDebug("No Bar ..."); @@ -1018,23 +1018,23 @@ void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/) //qd.exec(); } else if (msg=="compose()") - { + { QDialog qd(qApp->activeWindow(),"Getting mail",true); - + WriteMail wm(&qd,"write new mail"); QVBoxLayout vbProg( &qd ); - + wm.showMaximized(); vbProg.addWidget(&wm); - + qd.showMaximized(); - + emit composeRequested(); qd.exec(); - + QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); } - + else if (msg=="dialog()") { QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); diff --git a/noncore/net/mailit/emaillistitem.cpp b/noncore/net/mailit/emaillistitem.cpp index fc9f766..a25f93a 100644 --- a/noncore/net/mailit/emaillistitem.cpp +++ b/noncore/net/mailit/emaillistitem.cpp @@ -25,9 +25,9 @@ EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) : QListViewItem(parent) { QString temp; - + mail = mailIn; - + if (inbox) { setText(0, mail.from); } else { @@ -38,13 +38,14 @@ EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) setText(0, temp); } setText(1, mail.subject); - setText(2,mail.date); - + // setText(2,mail.date); + setText(2,dateFromULCString(mail.date)); + if (mailIn.files.count()>0) { setPixmap(0, Resource::loadPixmap("mailit/attach")); } - + selected = FALSE; } @@ -82,7 +83,7 @@ void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, _cg.setColor( QColorGroup::Text, Qt::blue); if (!mail.downloaded) _cg.setColor( QColorGroup::Text, Qt::red); - + /* if (selected) { _cg.setColor(QColorGroup::Base, Qt::blue); _cg.setColor(QColorGroup::Text, Qt::yellow); @@ -92,8 +93,66 @@ void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, _cg.setColor(QColorGroup::Highlight, Qt::blue); } } -*/ +*/ QListViewItem::paintCell( p, _cg, column, width, alignment ); _cg.setColor( QColorGroup::Text, c ); } + +/* + * Converts an E-Mail date (ULC) RFC 2822 conform to a QDateTime. + * Returning a QString with formatting of "YYYY-MM-DD HH:MM:SS" + * (zodiac: This method was tested with more than 300 inbox mails, + * it didn't slow down the loading of mail-it.) + */ +QString EmailListItem::dateFromULCString( QString ulcDate ) +{ + QString sTemp, sTime; + int iPos, iDay, iMon=1, iYear; + + iPos=ulcDate.find(','); + if (iPos) { // it has a day-of-week + ulcDate=ulcDate.remove(0,++iPos); //.stripWhiteSpace(); + } + + QStringList dateEntries = QStringList::split(" ",ulcDate,FALSE); + QStringList::Iterator iter = dateEntries.begin(); + + // Get day as DD + iDay = (*iter++).toInt(); + + // Get month as string Mmm + sTemp = (*iter++); + if (sTemp =="Jan") {iMon=1;} else + if (sTemp =="Feb") {iMon=2;} else + if (sTemp =="Mar") {iMon=3;} else + if (sTemp =="Apr") {iMon=4;} else + if (sTemp =="May") {iMon=5;} else + if (sTemp =="Jun") {iMon=6;} else + if (sTemp =="Jul") {iMon=7;} else + if (sTemp =="Aug") {iMon=8;} else + if (sTemp =="Sep") {iMon=9;} else + if (sTemp =="Oct") {iMon=10;} else + if (sTemp =="Nov") {iMon=11;} else + if (sTemp =="Dec") {iMon=12;} + + // Get year as YYYY or YY + iYear = (*iter++).toInt(); + + QDate date = QDate(iYear, iMon, iDay); + + // Convert timestring into a QTime + QStringList timeEntries = QStringList::split(":",(*iter++),FALSE); + QStringList::Iterator iterTime = timeEntries.begin(); + iYear=(*iterTime++).toInt(); // var reuse.. *cough* + iMon=(*iterTime++).toInt(); + iDay=(*iterTime++).toInt(); + QTime time = QTime(iYear,iMon,iDay); + + return QString::number(date.year())+"-" + +QString::number(date.month()).rightJustify(2,'0')+"-" + +QString::number(date.day()).rightJustify(2,'0')+" " + +time.toString(); +} + + diff --git a/noncore/net/mailit/emaillistitem.h b/noncore/net/mailit/emaillistitem.h index 642932c..129a774 100644 --- a/noncore/net/mailit/emaillistitem.h +++ b/noncore/net/mailit/emaillistitem.h @@ -32,13 +32,14 @@ public: void setItemSelected(bool enable); bool isItemSelected(); bool itemSelected(); - + protected: void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); private: Email mail; bool selected; + QString dateFromULCString( QString ulc ); }; #endif diff --git a/noncore/net/mailit/mailit.pro b/noncore/net/mailit/mailit.pro index 5e9a83a..0224886 100644 --- a/noncore/net/mailit/mailit.pro +++ b/noncore/net/mailit/mailit.pro @@ -1,6 +1,5 @@ -TEMPLATE = app TARGET = mailit -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = emailclient.h \ emailhandler.h \ emaillistitem.h \ @@ -37,9 +36,6 @@ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie # -lssl -MOC_DIR=qpeobj -OBJECTS_DIR=qpeobj -DESTDIR=$(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/mailit.ts \ ../../../i18n/nl/mailit.ts \ diff --git a/noncore/net/mailit/mailitwindow.h b/noncore/net/mailit/mailitwindow.h index e818d32..11e56b9 100644 --- a/noncore/net/mailit/mailitwindow.h +++ b/noncore/net/mailit/mailitwindow.h @@ -33,6 +33,7 @@ class MailItWindow: public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("mailit"); } MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); ~MailItWindow(); diff --git a/noncore/net/mailit/main.cpp b/noncore/net/mailit/main.cpp index 3a3e1fc..71f8877 100644 --- a/noncore/net/mailit/main.cpp +++ b/noncore/net/mailit/main.cpp @@ -20,10 +20,6 @@ #include #include "mailitwindow.h" -int main(int argc, char* argv[]) -{ - QPEApplication a( argc, argv ); - MailItWindow mw(0, 0); - a.showMainDocumentWidget(&mw); - return a.exec(); -} +#include + +OPIE_EXPORT_APP( OApplicationFactory ) \ No newline at end of file diff --git a/noncore/net/opieftp/main.cpp b/noncore/net/opieftp/main.cpp index 4f5a7d4..0217e41 100644 --- a/noncore/net/opieftp/main.cpp +++ b/noncore/net/opieftp/main.cpp @@ -10,18 +10,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ -#include - - - +#include #include "opieftp.h" -int main(int argc, char *argv[]) -{ - QPEApplication a(argc, argv); - - OpieFtp opieftp; - a.showMainWidget( &opieftp); - return a.exec(); -} - +OPIE_EXPORT_APP( OApplicationFactory ) diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 269449e..ee7d32f 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp @@ -57,8 +57,8 @@ static int log_progress(netbuf *, int xfered, void *) return 1; } -OpieFtp::OpieFtp( ) - : QMainWindow( ) +OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) + : QMainWindow( parent, name, fl ) { setCaption( tr( "OpieFtp" ) ); fuckeduphack=FALSE; @@ -81,7 +81,7 @@ OpieFtp::OpieFtp( ) localMenu = new QPopupMenu( this ); remoteMenu = new QPopupMenu( this ); tabMenu = new QPopupMenu( this ); - + layout->addMultiCellWidget( menuBar, 0, 0, 0, 2 ); menuBar->insertItem( tr( "Connection" ), connectionMenu); @@ -269,18 +269,18 @@ OpieFtp::OpieFtp( ) connect( serverListView, SIGNAL( highlighted( const QString &)), this,SLOT( serverListClicked( const QString &) ) ); - - connectServerBtn = new QPushButton( "Connect", tab_3 , "ConnectButton" ); + + connectServerBtn = new QPushButton( tr("Connect"), tab_3 , "ConnectButton" ); tabLayout_3->addMultiCellWidget( connectServerBtn, 6, 6, 0, 1); connectServerBtn->setToggleButton(TRUE); connect(connectServerBtn,SIGNAL( toggled( bool)),SLOT( connectorBtnToggled(bool) )); - newServerButton= new QPushButton( "Add", tab_3 , "NewServerButton" ); + newServerButton= new QPushButton( tr("Add"), tab_3 , "NewServerButton" ); tabLayout_3->addMultiCellWidget( newServerButton, 6, 6, 2, 2); connect( newServerButton,SIGNAL( clicked()),SLOT( NewServer() )); QPushButton *deleteServerBtn; - deleteServerBtn = new QPushButton( "Delete", tab_3 , "OpenButton" ); + deleteServerBtn = new QPushButton( tr("Delete"), tab_3 , "OpenButton" ); tabLayout_3->addMultiCellWidget( deleteServerBtn, 6, 6, 3, 3); connect(deleteServerBtn,SIGNAL(clicked()),SLOT(deleteServer())); @@ -319,7 +319,7 @@ OpieFtp::OpieFtp( ) readConfig(); // ServerComboBox->setCurrentItem(currentServerConfig); - + TabWidget->setCurrentPage(2); } @@ -357,7 +357,7 @@ void OpieFtp::tabChanged(QWidget *) cdUpButton->show(); if(homeButton->isHidden()) homeButton->show(); - + } if (TabWidget->currentPageIndex() == 1) { currentPathCombo->lineEdit()->setText( currentRemoteDir ); @@ -449,7 +449,7 @@ void OpieFtp::connector() // if( ftp_user != cfg.readEntry("Username")) // currentServerConfig=-1; // if(ftp_pass != cfg.readEntry(cfg.readEntry("Username"))) -// currentServerConfig=-1; +// currentServerConfig=-1; if(ftp_host.find("ftp://",0, TRUE) != -1 ) @@ -593,7 +593,7 @@ void OpieFtp::remoteDownload() for ( ; it.current(); ++it ) { Remote_View->clearSelection(); } - Remote_View->setFocus(); + Remote_View->setFocus(); TabWidget->setCurrentPage(0); populateLocalView(); // QCopEnvelope ( "QPE/System", "notBusy()" ); @@ -669,7 +669,7 @@ void OpieFtp::populateLocalView() if(fileL !="./" && fi->exists()) { item = new QListViewItem( Local_View,fileL, fileDate, fileS ); QPixmap pm; - + if(isDir || fileL.find("/",0,TRUE) != -1) { if( !QDir( fi->filePath() ).isReadable()) pm = Resource::loadPixmap( "lockedfolder" ); @@ -729,7 +729,7 @@ bool OpieFtp::populateRemoteView( ) int len, month = monthRe.match(s, 0, &len); fileDate = s.mid(month + 1, len - 2); // minus spaces fileL = s.right(s.length() - month - len); - if(s.left(1) == "d") + if(s.left(1) == "d") fileL = fileL+"/"; fileS = s.mid(month - 8, 8); // FIXME fileS = fileS.stripWhiteSpace(); @@ -815,15 +815,15 @@ void OpieFtp::remoteListClicked(QListViewItem *selectedItem) currentPathCombo->lineEdit()->setText( currentRemoteDir); fillRemoteCombo( (const QString &)currentRemoteDir); // QCopEnvelope ( "QPE/System", "notBusy()" ); - Remote_View->ensureItemVisible(Remote_View->firstChild()); - + Remote_View->ensureItemVisible(Remote_View->firstChild()); + } } void OpieFtp::localListClicked(QListViewItem *selectedItem) { if(selectedItem!= NULL) { - + QString strItem=selectedItem->text(0); QString strSize=selectedItem->text(1); strSize=strSize.stripWhiteSpace(); @@ -836,7 +836,7 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem) } } else { // not a symlink if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { - + if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); currentDir.cd(strItem,FALSE); @@ -858,7 +858,7 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem) } //end not symlink chdir(strItem.latin1()); } - Local_View->ensureItemVisible(Local_View->firstChild()); + Local_View->ensureItemVisible(Local_View->firstChild()); } } @@ -972,7 +972,7 @@ void OpieFtp::localDelete() if ( it.current()->isSelected() ) { QString f = it.current()->text(0); it.current()->setSelected(FALSE); - + // QString f = Local_View->currentItem()->text(0); if(QDir(f).exists() ) { switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ @@ -997,7 +997,7 @@ void OpieFtp::localDelete() system( cmd.latin1()); } break; - case 1: + case 1: // exit break; }; @@ -1005,7 +1005,7 @@ void OpieFtp::localDelete() } } populateLocalView(); - + } void OpieFtp::remoteMakDir() @@ -1201,10 +1201,10 @@ void OpieFtp::readConfig() Config cfg("opieftp"); cfg.setGroup("Server"); currentServerConfig = cfg.readNumEntry("currentServer", -1); - + // qDebug("Reading %d", currentServerConfig); serverComboSelected( currentServerConfig-1); - + } void OpieFtp::writeConfig() @@ -1254,7 +1254,7 @@ void OpieFtp::writeConfig() cfg.setGroup("Server"); cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); - + } } @@ -1326,9 +1326,9 @@ void OpieFtp::serverComboSelected(int index) bool ok; int portInt = port.toInt(&ok,10); if( portInt == 0) portInt = 21; - + ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); - + PortSpinBox->setValue( portInt); remotePath->setText(cfg.readEntry("RemotePath", "/")); @@ -1340,7 +1340,7 @@ void OpieFtp::serverComboSelected(int index) PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); // UsernameComboBox // PasswordEdit - + cfg.setGroup("Server"); temp.sprintf("%d",currentServerConfig); cfg.writeEntry("currentServer", temp); @@ -1358,7 +1358,7 @@ void OpieFtp::deleteServer() remoteServerStr = ServerComboBox->currentText( ); username = UsernameComboBox->currentText(); servername=serverListView->currentText(); - + Config cfg("opieftp"); cfg.setGroup("Server"); QString tempname; @@ -1493,7 +1493,7 @@ void OpieFtp::NewServer() { } currentServerConfig =-1; writeConfig(); - serverListView->insertItem( newServerName ); + serverListView->insertItem( newServerName ); serverListView->setCurrentItem( serverListView->count()); } } diff --git a/noncore/net/opieftp/opieftp.h b/noncore/net/opieftp/opieftp.h index 9d5d211..7bd615a 100644 --- a/noncore/net/opieftp/opieftp.h +++ b/noncore/net/opieftp/opieftp.h @@ -47,9 +47,10 @@ class OpieFtp : public QMainWindow Q_OBJECT public: - OpieFtp( ); + OpieFtp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~OpieFtp(); + static QString appName() { return QString::fromLatin1("opieftp"); } QTabWidget *TabWidget; QWidget *tab, *tab_2, *tab_3; QListView *Local_View, *Remote_View; diff --git a/noncore/net/opieftp/opieftp.pro b/noncore/net/opieftp/opieftp.pro index ac16819..185c341 100644 --- a/noncore/net/opieftp/opieftp.pro +++ b/noncore/net/opieftp/opieftp.pro @@ -1,9 +1,7 @@ -TEMPLATE = app -CONFIG += qt warn_on release -HEADERS = opieftp.h inputDialog.h +CONFIG += qt warn_on release quick-app +HEADERS = opieftp.h inputDialog.h SOURCES = opieftp.cpp inputDialog.cpp main.cpp TARGET = opieftp -DESTDIR = $(OPIEDIR)/bin INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lftplib diff --git a/noncore/net/opieirc/.cvsignore b/noncore/net/opieirc/.cvsignore index 39391f4..d5423d6 100644 --- a/noncore/net/opieirc/.cvsignore +++ b/noncore/net/opieirc/.cvsignore @@ -1,3 +1,4 @@ Makefile Makefile.in moc_*.cpp +.moc \ No newline at end of file diff --git a/noncore/net/opieirc/main.cpp b/noncore/net/opieirc/main.cpp index 43e63af..39acfcc 100644 --- a/noncore/net/opieirc/main.cpp +++ b/noncore/net/opieirc/main.cpp @@ -1,10 +1,7 @@ #include #include "mainwindow.h" -int main(int argc, char **argv) { - QPEApplication a(argc, argv); - MainWindow mw; - a.showMainWidget(&mw); - return a.exec(); -} +#include + +OPIE_EXPORT_APP( OApplicationFactory ) diff --git a/noncore/net/opieirc/mainwindow.h b/noncore/net/opieirc/mainwindow.h index bd1a9ce..0f60855 100644 --- a/noncore/net/opieirc/mainwindow.h +++ b/noncore/net/opieirc/mainwindow.h @@ -35,6 +35,7 @@ public: // IRCTabWidget getTabWidget(); void addTab(IRCTab *tab); void killTab(IRCTab *tab); + static QString appName() { return QString::fromLatin1("opieirc"); } signals: void updateScroll(); protected slots: diff --git a/noncore/net/opieirc/opieirc.pro b/noncore/net/opieirc/opieirc.pro index 8b09e18..537f810 100644 --- a/noncore/net/opieirc/opieirc.pro +++ b/noncore/net/opieirc/opieirc.pro @@ -1,6 +1,4 @@ -TEMPLATE = app -CONFIG = qt warn_on release -DESTDIR = $(OPIEDIR)/bin +CONFIG = qt warn_on release quick-app HEADERS = ircchannel.h ircconnection.h \ ircmessage.h \ ircmessageparser.h ircoutput.h \ @@ -21,8 +19,7 @@ SOURCES = ircchannel.cpp ircconnection.cpp \ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie -TARGET = opieirc - +TARGET = opieirc include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/net/opietooth/blue-pin/blue-pin.pro b/noncore/net/opietooth/blue-pin/blue-pin.pro index 102a937..fbf9dbe 100644 --- a/noncore/net/opietooth/blue-pin/blue-pin.pro +++ b/noncore/net/opietooth/blue-pin/blue-pin.pro @@ -1,6 +1,4 @@ -TEMPLATE = app -#CONFIG = qt warn_on debug -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = pindlg.h SOURCES = main.cc pindlg.cc INCLUDEPATH += $(OPIEDIR)/include @@ -8,8 +6,7 @@ INCLUDEPATH += $(OPIEDIR)/noncore/opietooth/lib DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe INTERFACES = pindlgbase.ui -DESTDIR = $(OPIEDIR)/bin -TARGET = bluepin +TARGET = bluepin TRANSLATIONS = ../../../../i18n/de/bluepin.ts \ ../../../../i18n/nl/bluepin.ts \ @@ -30,5 +27,4 @@ TRANSLATIONS = ../../../../i18n/de/bluepin.ts \ ../../../../i18n/zh_TW/bluepin.ts - include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/net/opietooth/manager/.cvsignore b/noncore/net/opietooth/manager/.cvsignore index 3fb67fe..19c03a7 100644 --- a/noncore/net/opietooth/manager/.cvsignore +++ b/noncore/net/opietooth/manager/.cvsignore @@ -7,3 +7,7 @@ devicedialog.h moc_* scandialog.cpp scandialog.h +rfcommassigndialogbase.cpp +rfcommassigndialogbase.h +rfcommdialogitembase.cpp +rfcommdialogitembase.h diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 54808fa..2e68984 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -20,6 +20,7 @@ #include "hciconfwrapper.h" #include "devicehandler.h" #include "btconnectionitem.h" +#include "rfcommassigndialogimpl.h" #include #include @@ -59,7 +60,9 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); - // not good since lib is async + + connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); +// not good since lib is async // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); connect( ListView2, SIGNAL( clicked( QListViewItem* )), @@ -222,7 +225,7 @@ void BlueBase::initGui() { QString BlueBase::status()const{ QString infoString = tr( "Device name : Ipaq" ); infoString += QString( "
" + tr( "MAC adress: " ) +" No idea" ); - infoString += QString( "
" + tr( "Class" ) + " PDA" ); + infoString += QString( "
" + tr( "Class" ) + " PDA" ); return (infoString); } @@ -245,6 +248,20 @@ void BlueBase::applyConfigChanges() { } /** + * Launch Rfcomm Bind dialog + * + */ +void BlueBase::rfcommDialog() { + RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); + + rfcommAssign.showMaximized(); + + if ( rfcommAssign.exec() == QDialog::Accepted ) { + rfcommAssign.saveConfig(); + } +} + +/** * Add fresh found devices from scan dialog to the listing * */ diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 743062c..a8ab3db 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h @@ -40,13 +40,16 @@ namespace OpieTooth { public: BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~BlueBase(); + + static QString appName() { return QString::fromLatin1("bluetooth-manager"); } protected: private slots: void startScan(); - + + private: bool find( const RemoteDevice& device ); void readConfig(); @@ -89,6 +92,7 @@ namespace OpieTooth { void applyConfigChanges(); void addSignalStrength(); void addSignalStrength( const QString& mac, const QString& strengh ); + void rfcommDialog(); }; diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index 9ff970f..bb906a1 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui @@ -11,8 +11,8 @@ 0 0 - 224 - 320 + 258 + 407 @@ -25,371 +25,419 @@ layoutSpacing - + + QTabWidget - margin - 0 + name + Status - spacing - 0 + geometry + + 1 + 1 + 245 + 289 + + + + layoutMargin + + + layoutSpacing - QTabWidget + QWidget name - Status - - - layoutMargin - - - layoutSpacing + tab - - QWidget + + title + Devices + + - name - tab + margin + 2 - - title - Devices - - + + spacing + 2 + + + QListView + + + text + Device Name + + + clickable + true + + + resizeable + true + + + + + text + Online + + + clickable + true + + + resizeable + true + + - margin - 2 + name + ListView2 + + + QPushButton - spacing - 2 + name + PushButton2 - - QListView - - - text - Device Name - - - clickable - true - - - resizeable - true - - - - - text - Online - - - clickable - true - - - resizeable - true - - - - name - ListView2 + + sizePolicy + + 0 + 0 + + + + text + Scan for Devices + + + + + + QWidget + + name + tab + + + title + Connections + + + + margin + 2 + + + spacing + 2 + + + QListView + + + text + Device Name - - - QPushButton - - name - PushButton2 + + clickable + true - - sizePolicy - - 0 - 0 - + + resizeable + true - + + + text - Scan for Devices + Connection type - - - - - QWidget - - name - tab - - - title - Connections - - - - margin - 2 - + + clickable + true + + + resizeable + true + + + + + text + Signal + + + clickable + true + + + resizeable + true + + - spacing - 2 + name + ListView4 - - QListView - - - text - Device Name - - - clickable - true - - - resizeable - true - - - - - text - Connection type - - - clickable - true - - - resizeable - true - - - - - text - Signal - - - clickable - true - - - resizeable - true - - - - name - ListView4 - - - - - - QWidget + + + + + QWidget + + name + tab + + + title + Config + + + + margin + 11 + - name - tab + spacing + 6 - - title - Config - - + + QGroupBox - margin - 2 + name + GroupBox1 - spacing - 2 + title + Bluetooh Basic Config - - QLayoutWidget + - name - Layout2 + margin + 11 - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - deviceNameLabel - - - text - Device Name - - - - QLineEdit - - name - deviceNameLine - - - - - - QLayoutWidget - name - Layout3 + spacing + 6 - - - margin - 0 - + + QLayoutWidget - spacing - 6 + name + Layout7 - - QLabel + - name - passkeyLabel + margin + 0 - text - Default Passkey + spacing + 6 - - - QLineEdit + + QLayoutWidget + + name + Layout6 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + deviceNameLabel + + + text + Device Name + + + + QLabel + + name + passkeyLabel + + + text + Default Passkey + + + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + QLineEdit + + name + deviceNameLine + + + + QLineEdit + + name + passkeyLine + + + echoMode + Password + + + + + + + + QLayoutWidget + + name + Layout5 + + - name - passkeyLine + margin + 0 - echoMode - Password + spacing + 6 - - - - - QLayoutWidget - - name - Layout5 - - + + QCheckBox + + name + authCheckBox + + + text + enable authentification + + + + QCheckBox + + name + cryptCheckBox + + + text + enable encryption + + + + QCheckBox + + name + pagescanCheckBox + + + text + Enable Page scan + + + + QCheckBox + + name + inquiryscanCheckBox + + + text + Enable Inquiry scan + + + + + + QPushButton - margin - 0 + name + configApplyButton - spacing - 6 + text + Apply - - QCheckBox - - name - authCheckBox - - - text - enable authentification - - - - QCheckBox - - name - cryptCheckBox - - - text - enable encryption - - - - QCheckBox - - name - pagescanCheckBox - - - text - Enable Page scan - - - - QCheckBox - - name - inquiryscanCheckBox - - - text - Enable Inquiry scan - - - - - - QPushButton - - name - configApplyButton - - - text - Apply - - - - - - QWidget + + + + + QPushButton + + name + rfcommBindButton + + + text + Rfcomm Bind Table + + + + + + QWidget + + name + tab + + + title + Status + + - name - tab + margin + 2 - - title - Status - - + + spacing + 2 + + + QLabel - margin - 2 + name + StatusLabel - spacing - 2 + text + Status Label - - QLabel - - name - StatusLabel - - - text - Status Label - - - - + + - + diff --git a/noncore/net/opietooth/manager/main.cpp b/noncore/net/opietooth/manager/main.cpp index a86e36d..82aeebd 100644 --- a/noncore/net/opietooth/manager/main.cpp +++ b/noncore/net/opietooth/manager/main.cpp @@ -19,20 +19,7 @@ #include "bluebase.h" #include +#include - -QPEApplication *BluetoothApp; - -int main( int argc, char ** argv ) { - QPEApplication a(argc, argv); - BluetoothApp=&a; - - OpieTooth::BlueBase t; - - // t.setCaption( OpieTooth::BlueBase::tr("Bluetooth Manager") ); - a.showMainWidget(&t); - - return a.exec(); -} - +OPIE_EXPORT_APP( OApplicationFactory ) diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index 9841740..6ff4ebb 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro @@ -1,14 +1,13 @@ -TEMPLATE = app -CONFIG = qt warn_on debug -#CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = btconnectionitem.h btdeviceitem.h \ btserviceitem.h stdpopups.h \ popuphelper.h bluebase.h \ scandialog.h btlistitem.h \ hciconfwrapper.h bticonloader.h \ pppdialog.h obexdialog.h \ + rfcommassigndialogimpl.h rfcommassigndialogitem.h \ devicehandler.h rfcpopup.h obexpopup.h \ - rfcommhelper.h panpopup.h dunpopup.h + rfcommhelper.h panpopup.h dunpopup.h rfcommconfhandler.h SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ btserviceitem.cpp stdpopups.cpp \ @@ -16,16 +15,17 @@ SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ bluebase.cpp scandialog.cpp \ btlistitem.cpp hciconfwrapper.cpp \ bticonloader.cpp pppdialog.cpp \ + rfcommassigndialogimpl.cpp rfcommassigndialogitem.cpp \ obexdialog.cpp devicehandler.cpp \ rfcpopup.cpp obexpopup.cpp \ - rfcommhelper.cpp panpopup.cpp dunpopup.cpp + rfcommhelper.cpp panpopup.cpp dunpopup.cpp rfcommconfhandler.cpp INCLUDEPATH += $(OPIEDIR)/include INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopietooth -lopie -INTERFACES = bluetoothbase.ui devicedialog.ui -DESTDIR = $(OPIEDIR)/bin -TARGET = bluetooth-manager +INTERFACES = bluetoothbase.ui devicedialog.ui rfcommassigndialogbase.ui rfcommdialogitembase.ui + +TARGET = bluetooth-manager TRANSLATIONS = ../../../../i18n/de/bluetooth-manager.ts \ ../../../../i18n/nl/bluetooth-manager.ts \ diff --git a/noncore/net/opietooth/manager/rfcommassigndialogbase.ui b/noncore/net/opietooth/manager/rfcommassigndialogbase.ui new file mode 100644 index 0000000..aefa698 --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommassigndialogbase.ui @@ -0,0 +1,44 @@ + +RfcommAssignDialogBase + + QDialog + + name + RfcommAssignDialogBase + + + geometry + + 0 + 0 + 444 + 343 + + + + caption + Rfcomm Bind + + + + margin + 11 + + + spacing + 6 + + + QLabel + + name + TextLabel1 + + + text + Bind device to a interface + + + + + diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp new file mode 100644 index 0000000..b5cc074 --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp @@ -0,0 +1,120 @@ + +#include "rfcommassigndialogimpl.h" +#include "rfcommassigndialogitem.h" +#include "rfcommconfhandler.h" + +#include + +#include + +using namespace OpieTooth; + +// TODO: write only the file in bluebase? +// muss rfcommd dann neu gestartet werden +// sollte rfcomm bind all nicht eh default config sein ( polled das? - d.h. sobald nen gerät in der nähe ist bindet es? + + +RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) + : RfcommAssignDialogBase( parent, name, modal, fl ) { + + m_range = 5; + + m_scrollView = new QScrollView( this ); + m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); + m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff ); + + RfcommAssignDialogBaseLayout->addWidget( m_scrollView ); + + m_box = new QVBox( m_scrollView->viewport() ); + m_scrollView->addChild( m_box ); + + confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" ); + + loadConfig(); +} + +RfcommAssignDialog::~RfcommAssignDialog() { + if ( confHandler ) { + delete confHandler; + } +} + + +void RfcommAssignDialog::newDevice( const QString & mac ) { + + for ( int i = 0 ; i < m_range; i++ ) { + + QMap::Iterator it; + it = confHandler->foundEntries().find( QString("%1").arg( i ) ); + // make sure that rfcommX is not assigned yet + if ( it == confHandler->foundEntries().end() ) { + QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); + dialog.showMaximized(); + RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); + newDev->setIdent( i ); + newDev->setMac( mac ); + + if ( dialog.exec() == QDialog::Accepted ) { + RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); + m_itemList.insert( i , rfcomm ); + rfcomm->setIdent( i ); + rfcomm->setMac( mac ); + rfcomm->setChannel( newDev->channel() ); + rfcomm->setComment( newDev->comment() ); + qDebug( "New device set up" ); + } + } + } +} + +void RfcommAssignDialog::loadConfig() { + + //Config cfg( "bluetoothmanager-rfcommbind" ); + + for ( int i = 0 ; i < m_range; i++ ) { + // cfg.setGroup( QString("%1").arg( i ) ); + RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); + m_itemList.insert( i , rfcomm ); + rfcomm->setIdent( i ); + QMap::Iterator it; + it = confHandler->foundEntries().find( QString("%1").arg( i ) ); + if ( it != confHandler->foundEntries().end() ) { + qDebug( "Found key in foundEntries() " ); + rfcomm->setMac( it.data()->mac() ); + rfcomm->setChannel( it.data()->channel() ); + rfcomm->setComment( it.data()->comment() ); + } + /* Use rfcomm.conf directly for now + * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); + * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); + * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); + */ + } +} + + +void RfcommAssignDialog::saveConfig() { + + //Config cfg( "bluetoothmanager-rfcommbind" ); + + QMap< int, RfcommDialogItem*>::Iterator it; + + QMap< QString, RfCommConfObject*> outMap; + + for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) { + + //cfg.setGroup( QString("%1").arg( it.key() ) ); + RfcommDialogItem *rfcomm = it.data(); + + + outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); + + + //cfg.writeEntry( "mac", rfcomm->mac() ); + //cfg.writeEntry( "channel", rfcomm->channel() ); + //cfg.writeEntry( "comment", rfcomm->comment() ); + } + + confHandler->save( outMap ); + +} diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.h b/noncore/net/opietooth/manager/rfcommassigndialogimpl.h new file mode 100644 index 0000000..9983632 --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.h @@ -0,0 +1,39 @@ +#ifndef RFCOMMASSIGN +#define RFCOMMASSIGN + +#include "rfcommassigndialogbase.h" +#include "rfcommassigndialogitem.h" +#include "rfcommconfhandler.h" + +#include +#include +#include + +namespace OpieTooth { + + class RfcommAssignDialog: public RfcommAssignDialogBase { + + Q_OBJECT + + public: + + RfcommAssignDialog( QWidget* parent = 0, const char* name = 0,bool modal = 0, WFlags fl = 0 ); + ~RfcommAssignDialog(); + + void loadConfig(); + void saveConfig(); + + void newDevice( const QString & mac ); + + private: + QScrollView *m_scrollView; + // how many rfcomm devices are possible + int m_range; + QMap< int, RfcommDialogItem* > m_itemList; + QVBox *m_box; + RfCommConfHandler *confHandler; +}; + +} + +#endif diff --git a/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp b/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp new file mode 100644 index 0000000..1e7130f --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp @@ -0,0 +1,54 @@ + +#include "rfcommassigndialogitem.h" + +#include +#include +#include +#include + +using namespace OpieTooth; + + +RfcommDialogItem::RfcommDialogItem( QWidget* parent, const char* name, WFlags fl ) + : RfcommDialogItemBase( parent, name, fl ) { + +} + +RfcommDialogItem::~RfcommDialogItem() { +} + + +int RfcommDialogItem::ident() { + return m_ident; +} + +QString RfcommDialogItem::mac() { + return m_macAddress->text(); +} + +int RfcommDialogItem::channel() { + return m_channelDropdown->currentItem(); +} + +QString RfcommDialogItem::comment() { + return m_commentLine->text(); +} + +void RfcommDialogItem::setIdent( int ident ) { + m_ident = ident; + m_identLabel->setTitle( QString( "rfcomm%1").arg( ident ) ); +} + +void RfcommDialogItem::setMac( const QString &mac ) { + m_macAddress->setText( mac ); +} + +void RfcommDialogItem::setChannel( int channel ) { + m_channelDropdown->setCurrentItem( channel ); +} + +void RfcommDialogItem::setComment( const QString &comment ) { + m_commentLine->setText( comment ); +} + + diff --git a/noncore/net/opietooth/manager/rfcommassigndialogitem.h b/noncore/net/opietooth/manager/rfcommassigndialogitem.h new file mode 100644 index 0000000..34a794f --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommassigndialogitem.h @@ -0,0 +1,40 @@ +#ifndef RFCOMMDIALOGITEM +#define RFCOMMDIALOGITEM + +#include "rfcommdialogitembase.h" + +#include + +namespace OpieTooth { + + class RfcommDialogItem : public RfcommDialogItemBase { + + Q_OBJECT + + public: + RfcommDialogItem( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~RfcommDialogItem(); + + // number if the rfcomm device + int ident(); + // devices mac address + QString mac(); + int channel(); + QString comment(); + + void setIdent( int ident ); + void setMac( const QString& mac ); + void setChannel( int channel ); + void setComment( const QString& comment ); + + private: + + + int m_ident; + +}; + + +} + +#endif diff --git a/noncore/net/opietooth/manager/rfcommconfhandler.cpp b/noncore/net/opietooth/manager/rfcommconfhandler.cpp new file mode 100644 index 0000000..20453e8 --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommconfhandler.cpp @@ -0,0 +1,114 @@ + +#include + +#include "rfcommconfhandler.h" + + +using namespace OpieTooth; + +// move to lib + + +RfCommConfObject::RfCommConfObject( int number, QString mac, int channel, QString comment ) { + m_number = number; + m_mac = mac; + m_channel = channel; + m_comment = comment; + // m_foundEntries = 0; +} + +void RfCommConfObject::setNumber( int number ) { + m_number = number; +} + +void RfCommConfObject::setMac( QString mac ) { + m_mac = mac; +} + +void RfCommConfObject::setChannel( int channel ) { + m_channel = channel; +} + +void RfCommConfObject::setComment( QString comment ) { + m_comment = comment; +} + + +RfCommConfObject::~RfCommConfObject() { +} + + +RfCommConfHandler::RfCommConfHandler( const QString & filename ) { + + m_filename = filename; + load(); +} + +RfCommConfHandler::~RfCommConfHandler() { + +} + +void RfCommConfHandler::save( QMap devices ) { + + QFile rfCommConf( "/tmp/test" ); + QTextStream outStream( &rfCommConf ); + if ( rfCommConf.open( IO_WriteOnly ) ) { + + QMap::Iterator it; + for( it = devices.begin(); it != devices.end(); ++it ) { + outStream << "rfcomm" + QString("%1").arg( it.data()->number() ) + " {\n"; + outStream << " device " + it.data()->mac() + ";\n"; + outStream << " channel " + QString( "%1" ).arg( it.data()->channel() ) + ";\n"; + outStream << " comment \"" + it.data()->comment() + "\";\n"; + outStream << "}\n\n"; + } + + rfCommConf.close(); + } +} + + +QMap RfCommConfHandler::foundEntries() { + return m_foundEntries; +} + +void RfCommConfHandler::load() { + + QFile rfCommConf( m_filename ); + if ( rfCommConf.open( IO_ReadOnly ) ) { + + QStringList list; + QTextStream inStream( &rfCommConf ); + list = QStringList::split( "\n", inStream.read() ); + + QString number; + QString mac; + QString channel; + QString comment; + + for ( QStringList::Iterator line=list.begin(); line != list.end(); line++ ) { + + QString tmpLine = ( *line ).stripWhiteSpace(); + + if ( tmpLine.startsWith("rfcomm") ) { + QString number = tmpLine.mid( 6,1 ); + qDebug( tmpLine ); + qDebug( "TEST " + number ); + } else if ( tmpLine.startsWith( "}" ) ) { + m_foundEntries.insert( number, new RfCommConfObject( number.toInt(), mac, channel.toInt(), comment ) ); + } else if ( tmpLine.startsWith( "device" ) ) { + mac = tmpLine.mid( 7, 17 ); + qDebug( "mac" + mac ); + } else if ( tmpLine.startsWith( "channel" ) ) { + channel = tmpLine.mid( 8, 1 ); + qDebug ( "Channel :" + channel ); + } else if ( tmpLine.startsWith( "comment" ) ) { + comment = tmpLine.mid( 9, tmpLine.find( ';' ) - 9 - 1 ); + qDebug( "Comment: " + comment ); + } + } + rfCommConf.close(); + } + save( m_foundEntries ); + qDebug( QString( "ENTries: %1").arg( m_foundEntries.count() ) ); +} diff --git a/noncore/net/opietooth/manager/rfcommconfhandler.h b/noncore/net/opietooth/manager/rfcommconfhandler.h new file mode 100644 index 0000000..e13c833 --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommconfhandler.h @@ -0,0 +1,54 @@ +#ifndef RFCOMMCONFHANDLER +#define RFCOMMCONFHANDLER + +#include +#include +#include +#include + +namespace OpieTooth { + + class RfCommConfObject { + + public: + RfCommConfObject( int number, QString mac, int channel, QString comment ); + ~RfCommConfObject(); + + void setNumber( int number ); + int number() { return m_number; }; + void setMac( QString mac ); + QString mac() { return m_mac; }; + void setChannel( int channel ); + int channel() { return m_channel; }; + void setComment( QString comment ); + QString comment() { return m_comment; }; + + + private: + int m_number; + QString m_mac; + int m_channel; + QString m_comment; + + }; + + class RfCommConfHandler { + + public: + RfCommConfHandler( const QString & filename ); + ~RfCommConfHandler(); + + void save( QMap devices ); + + QMap foundEntries(); + + private: + void load(); + + QString m_filename; + QMap m_foundEntries; + }; + +} + +#endif diff --git a/noncore/net/opietooth/manager/rfcommdialogitembase.ui b/noncore/net/opietooth/manager/rfcommdialogitembase.ui new file mode 100644 index 0000000..dafca52 --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommdialogitembase.ui @@ -0,0 +1,216 @@ + +RfcommDialogItemBase + + QWidget + + name + RfcommDialogItemBase + + + geometry + + 0 + 0 + 345 + 95 + + + + caption + Form2 + + + layoutMargin + + + layoutSpacing + + + + margin + 0 + + + spacing + 0 + + + QGroupBox + + name + m_identLabel + + + layoutMargin + + + layoutSpacing + + + + margin + 5 + + + spacing + 5 + + + QLayoutWidget + + name + Layout3 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel4 + + + text + Mac + + + + QLineEdit + + name + m_macAddress + + + + QLabel + + name + TextLabel5 + + + text + Channel + + + + QComboBox + + + text + 0 + + + + + text + 1 + + + + + text + 2 + + + + + text + 3 + + + + + text + 4 + + + + + text + 5 + + + + + text + 6 + + + + + text + 7 + + + + + text + 8 + + + + + text + 9 + + + + + text + 10 + + + + name + m_channelDropdown + + + + + + QLayoutWidget + + name + Layout4 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + TextLabel3 + + + text + Comment: + + + + QLineEdit + + name + m_commentLine + + + + + + + + + diff --git a/noncore/net/opietooth/manager/rfcpopup.cpp b/noncore/net/opietooth/manager/rfcpopup.cpp index cc87b6c..d95f14b 100644 --- a/noncore/net/opietooth/manager/rfcpopup.cpp +++ b/noncore/net/opietooth/manager/rfcpopup.cpp @@ -3,18 +3,22 @@ #include "pppdialog.h" #include "rfcpopup.h" +#include "rfcommassigndialogimpl.h" using namespace OpieTooth; /* * c'tor init the QAction */ -RfcCommPopup::RfcCommPopup() +RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item ) : QPopupMenu() { qWarning("RfcCommPopup c'tor"); QAction* a; + + m_item = item; + /* connect action */ a = new QAction( ); // so it's get deleted a->setText("Connect"); @@ -33,10 +37,10 @@ RfcCommPopup::RfcCommPopup() /* foo action */ a = new QAction( ); - a->setText("Foo"); + a->setText("Bind table"); a->addTo( this ); connect( a, SIGNAL( activated() ), - this, SLOT( slotFoo() ) ); + this, SLOT( slotBind() ) ); /* bar action */ @@ -74,8 +78,15 @@ void RfcCommPopup::slotDisconnect() { } -void RfcCommPopup::slotFoo() { - qWarning("slotFoo"); +void RfcCommPopup::slotBind() { + RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); + + rfcommAssign.showMaximized(); + rfcommAssign.newDevice( m_item->mac() ); + + if ( rfcommAssign.exec() == QDialog::Accepted ) { + rfcommAssign.saveConfig(); + } } diff --git a/noncore/net/opietooth/manager/rfcpopup.h b/noncore/net/opietooth/manager/rfcpopup.h index c388f65..74b9117 100644 --- a/noncore/net/opietooth/manager/rfcpopup.h +++ b/noncore/net/opietooth/manager/rfcpopup.h @@ -4,6 +4,8 @@ #include #include +#include "btdeviceitem.h" + namespace OpieTooth { /** * A simple reference implementation for @@ -16,19 +18,20 @@ namespace OpieTooth { class RfcCommPopup : public QPopupMenu { Q_OBJECT public: - RfcCommPopup(); + RfcCommPopup( OpieTooth::BTDeviceItem* ); ~RfcCommPopup(); private: QAction* m_con; QAction* m_dis; - QAction* m_foo; + QAction* m_bind; QAction* m_bar; + OpieTooth::BTDeviceItem *m_item; private slots: void slotConnect(); void slotDisconnect(); - void slotFoo(); + void slotBind(); void slotBar(); }; }; diff --git a/noncore/net/opietooth/manager/stdpopups.cpp b/noncore/net/opietooth/manager/stdpopups.cpp index 38b8ee7..e1f8396 100644 --- a/noncore/net/opietooth/manager/stdpopups.cpp +++ b/noncore/net/opietooth/manager/stdpopups.cpp @@ -9,7 +9,7 @@ extern "C" { QPopupMenu* newRfcComPopup( const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item ) { - return new OpieTooth::RfcCommPopup(/* servive, item*/ ); // fix spellin RfComm vs. RfcComm and paramaters + return new OpieTooth::RfcCommPopup(/* servive,*/ item ); // fix spellin RfComm vs. RfcComm and paramaters //return 0l; } QPopupMenu* newObexPushPopup( const OpieTooth::Services&, OpieTooth::BTDeviceItem* ) { diff --git a/noncore/net/ubrowser/main.cpp b/noncore/net/ubrowser/main.cpp index e4a873d..0488cfd 100644 --- a/noncore/net/ubrowser/main.cpp +++ b/noncore/net/ubrowser/main.cpp @@ -18,12 +18,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "mainview.h" -int main( int argc, char **argv ) -{ - QPEApplication a( argc, argv ); - MainView w; - -// a.setMainWidget( &w ); - a.showMainDocumentWidget( &w ); - return a.exec(); -} +#include + +OPIE_EXPORT_APP( OApplicationFactory ) + diff --git a/noncore/net/ubrowser/mainview.cpp b/noncore/net/ubrowser/mainview.cpp index 9302f05..0d3f171 100644 --- a/noncore/net/ubrowser/mainview.cpp +++ b/noncore/net/ubrowser/mainview.cpp @@ -17,7 +17,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "mainview.h" -MainView::MainView(QWidget *parent, const char *name) : QMainWindow(parent, name) +MainView::MainView(QWidget *parent, const char *name, WFlags fl) : QMainWindow(parent, name, fl) { setIcon( Resource::loadPixmap( "remote" ) ); setCaption(tr("uBrowser")); diff --git a/noncore/net/ubrowser/mainview.h b/noncore/net/ubrowser/mainview.h index 20e2c70..cc63729 100644 --- a/noncore/net/ubrowser/mainview.h +++ b/noncore/net/ubrowser/mainview.h @@ -36,7 +36,8 @@ class MainView : public QMainWindow { Q_OBJECT public: - MainView(QWidget *parent=0, const char *name=0); + static QString appName() { return QString::fromLatin1("ubrowser"); } + MainView(QWidget *parent=0, const char *name=0, WFlags fl = 0); public slots: void goClicked(); void textChanged(); diff --git a/noncore/net/ubrowser/ubrowser.pro b/noncore/net/ubrowser/ubrowser.pro index a6943dd..ed00047 100644 --- a/noncore/net/ubrowser/ubrowser.pro +++ b/noncore/net/ubrowser/ubrowser.pro @@ -1,6 +1,4 @@ -TEMPLATE =app -CONFIG +=qt warn_on release -DESTDIR =../../../bin +CONFIG +=qt warn_on release quick-app HEADERS = mainview.h httpfactory.h SOURCES = main.cpp mainview.cpp httpfactory.cpp INCLUDEPATH +=../../../include diff --git a/noncore/unsupported/mailit/emailclient.cpp b/noncore/unsupported/mailit/emailclient.cpp index 90664bb..8359acf 100644 --- a/noncore/unsupported/mailit/emailclient.cpp +++ b/noncore/unsupported/mailit/emailclient.cpp @@ -42,31 +42,31 @@ MailAccount* AccountList::dupl(MailAccount *in) EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) -{ +{ emailHandler = new EmailHandler(); addressList = new AddressList(); - + sending = FALSE; receiving = FALSE; previewingMail = FALSE; mailIdCount = 1; accountIdCount = 1; allAccounts = FALSE; - + init(); - - - + + + connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); - + connect(emailHandler, SIGNAL(smtpError(int,const QString &)), this, SLOT(smtpError(int,const QString &)) ); connect(emailHandler, SIGNAL(popError(int,const QString &)), this, SLOT(popError(int,const QString &)) ); - + connect(inboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); connect(outboxView, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); - + connect(inboxView, SIGNAL(pressed(QListViewItem *)), this, SLOT(inboxItemPressed()) ); connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemReleased()) ); @@ -74,20 +74,20 @@ EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) SLOT(mailArrived(const Email &, bool)) ); connect(emailHandler, SIGNAL(mailTransfered(int)), this, SLOT(allMailArrived(int)) ); - + mailconf = new Config("mailit"); //In case Synchronize is not defined in settings.txt readSettings(); - + updateAccounts(); - + lineShift = "\n"; readMail(); lineShift = "\r\n"; - + mailboxView->setCurrentTab(0); //ensure that inbox has focus - + /*channel = new QCopChannel( "QPE/Application/mailit", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );*/ @@ -104,18 +104,18 @@ EmailClient::~EmailClient() //different properties saveMail(getPath(FALSE) + "outbox.txt", outboxView); saveSettings(); - + mailconf->write(); delete mailconf; - + } void EmailClient::init() { initStatusBar(this); - + setToolBarsMovable(FALSE); - + bar = new QToolBar(this); QWhatsThis::add(bar,tr("Main operation toolbar")); bar->setHorizontalStretchable( TRUE ); @@ -127,7 +127,7 @@ void EmailClient::init() QPopupMenu *configure = new QPopupMenu(mb); mb->insertItem( tr( "Accounts" ), configure); - + selectAccountMenu = new QPopupMenu(mb); editAccountMenu = new QPopupMenu(mb); deleteAccountMenu = new QPopupMenu(mb); @@ -142,32 +142,32 @@ void EmailClient::init() QWhatsThis::add(getMailButton,tr("Click to download mail via all available accounts.\n Press and hold to select the desired account.")); getMailButton->setPopup(selectAccountMenu); - + sendMailButton = new QAction(tr("Send mail"), Resource::loadPixmap("mailit/sendqueue"), QString::null, 0, this, 0); connect(sendMailButton, SIGNAL(activated()), this, SLOT(sendQuedMail()) ); sendMailButton->addTo(bar); sendMailButton->addTo(mail); sendMailButton->setWhatsThis("Send mail queued in the outbox"); - + composeButton = new QAction(tr("Compose"), Resource::loadPixmap("new"), QString::null, 0, this, 0); connect(composeButton, SIGNAL(activated()), this, SLOT(compose()) ); composeButton->addTo(bar); composeButton->addTo(mail); composeButton->setWhatsThis("Compose a new mail"); - + cancelButton = new QAction(tr("Cancel transfer"), Resource::loadPixmap("close"), QString::null, 0, this, 0); connect(cancelButton, SIGNAL(activated()), this, SLOT(cancel()) ); cancelButton->addTo(mail); cancelButton->addTo(bar); cancelButton->setEnabled(FALSE); cancelButton->setWhatsThis("Stop the currently active mail transfer"); - - + + deleteButton = new QAction( tr( "Delete" ), Resource::loadPixmap( "trash" ), QString::null, 0, this, 0 ); connect( deleteButton, SIGNAL( activated() ), this, SLOT( deleteItem() ) ); deleteButton->addTo(bar); deleteButton->setWhatsThis("Remove the currently selected eMail(s)"); - + mailboxView = new OTabWidget( this, "mailboxView" ); QWidget* widget = new QWidget( mailboxView, "widget" ); @@ -205,23 +205,23 @@ void EmailClient::init() "reviewed by double clicking the entry.")); grid_3->addWidget( outboxView, 0, 0 ); mailboxView->addTab( widget_2,"mailit/outbox", tr( "Outbox" ) ); - + setCentralWidget(mailboxView); - + } void EmailClient::initStatusBar(QWidget* parent) { statusBar = new QStatusBar(parent); statusBar->setSizeGripEnabled(FALSE); - + status1Label = new QLabel( tr("Idle"), statusBar); status2Label = new QLabel("", statusBar); connect(emailHandler, SIGNAL(updatePopStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); connect(emailHandler, SIGNAL(updateSmtpStatus(const QString &)), status2Label, SLOT(setText(const QString &)) ); - + progressBar = new QProgressBar(statusBar); connect(emailHandler, SIGNAL(mailboxSize(int)), @@ -260,20 +260,20 @@ void EmailClient::enqueMail(const Email &mail) tr("No account selected"), tr("You must create an account"), "OK\n"); return; } - + if (accountList.count() > 0) { currentAccount = accountList.first(); qWarning("using account " + currentAccount->name); } - + Email addMail = mail; addMail.from = currentAccount->name; addMail.fromMail = currentAccount->emailAddress; addMail.rawMail.prepend("From: \"" + addMail.from + "\" <" + addMail.fromMail + ">\n"); item = new EmailListItem(outboxView, addMail, false); - + mailboxView->setCurrentTab(1); - + } void EmailClient::sendQuedMail() @@ -281,7 +281,7 @@ void EmailClient::sendQuedMail() int count = 0; if (accountList.count() == 0) { - QMessageBox::warning(qApp->activeWindow(), "No account selected", "You must create an account", "OK\n"); + QMessageBox::warning(qApp->activeWindow(), tr("No account selected"), tr("You must create an account"), "OK\n"); return; } //traverse listview, find messages to send @@ -313,30 +313,30 @@ void EmailClient::mailSent() { sending = FALSE; sendMailButton->setEnabled(TRUE); - + quedMessages.clear(); outboxView->clear(); //should be moved to an sentBox } void EmailClient::getNewMail() { - + if (accountList.count() == 0) { - QMessageBox::warning(qApp->activeWindow(),"No account selected", - "You must create an account", "OK\n"); + QMessageBox::warning(qApp->activeWindow(),tr("No account selected"), + tr("You must create an account"), "OK\n"); return; } - + setMailAccount(); - + receiving = TRUE; previewingMail = TRUE; getMailButton->setEnabled(FALSE); cancelButton->setEnabled(TRUE); selectAccountMenu->setEnabled(FALSE); - + status1Label->setText(currentAccount->accountName + " headers"); progressBar->reset(); - + //get any previous mails not downloaded and add to queue /*mailDownloadList.clear(); Email *mailPtr; @@ -348,16 +348,16 @@ void EmailClient::getNewMail() { } item = (EmailListItem *) item->nextSibling(); }*/ - + emailHandler->getMailHeaders(); - + } void EmailClient::getAllNewMail() { allAccounts = TRUE; currentAccount = accountList.first(); - getNewMail(); + getNewMail(); } void EmailClient::mailArrived(const Email &mail, bool fromDisk) @@ -367,57 +367,57 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) int thisMailId; emailHandler->parse( mail.rawMail, lineShift, &newMail); mailconf->setGroup(newMail.id); - - if (fromDisk) + + if (fromDisk) { - + newMail.downloaded = mailconf->readBoolEntry("downloaded"); newMail.size = mailconf->readNumEntry("size"); newMail.serverId = mailconf->readNumEntry("serverid"); newMail.fromAccountId = mailconf->readNumEntry("fromaccountid"); - } - else + } + else { //mail arrived from server - + newMail.serverId = mail.serverId; newMail.size = mail.size; newMail.downloaded = mail.downloaded; - + newMail.fromAccountId = emailHandler->getAccount()->id; mailconf->writeEntry("fromaccountid", newMail.fromAccountId); } - + //add if read or not newMail.read = mailconf->readBoolEntry("mailread"); - + //check if new mail if ( (thisMailId = mailconf->readNumEntry("internalmailid", -1)) == -1) { thisMailId = mailIdCount; mailIdCount++; - + //set server count, so that if the user aborts, the new //header is not reloaded if ((currentAccount)&&(currentAccount->synchronize)) currentAccount->lastServerMailCount++; - + mailconf->writeEntry("internalmailid", thisMailId); mailconf->writeEntry("downloaded", newMail.downloaded); mailconf->writeEntry("size", (int) newMail.size); mailconf->writeEntry("serverid", newMail.serverId); - + //addressList->addContact(newMail.fromMail, newMail.from); } - + mailconf->writeEntry("downloaded", newMail.downloaded); - + QString stringMailId; stringMailId.setNum(thisMailId); //see if any attatchments needs to be stored - + for ( ePtr=newMail.files.first(); ePtr != 0; ePtr=newMail.files.next() ) { QString stringId; stringId.setNum(ePtr->id); - + int id = mailconf->readNumEntry("enclosureid_" + stringId); if (id != ePtr->id) { //new entry mailconf->writeEntry("enclosureid_" + stringId, ePtr->id); @@ -426,7 +426,7 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) mailconf->writeEntry("contentattribute_" + stringId, ePtr->contentAttribute); mailconf->writeEntry("saved_" + stringId, ePtr->saved); mailconf->writeEntry("installed_" + stringId, FALSE); - + ePtr->name = stringMailId + "_" + stringId; ePtr->path = getPath(TRUE); if (emailHandler->getEnclosure(ePtr)) { //file saved @@ -444,18 +444,18 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) if (ePtr->saved) { ePtr->name = mailconf->readEntry("filename_" + stringId); ePtr->path = mailconf->readEntry("path_" + stringId); - } + } } } bool found=false; - - if (!fromDisk) + + if (!fromDisk) { - + Email *mailPtr; item = (EmailListItem *) inboxView->firstChild(); - while ((item != NULL)&&(!found)) + while ((item != NULL)&&(!found)) { mailPtr = item->getMail(); if (mailPtr->id == newMail.id) { @@ -472,12 +472,12 @@ void EmailClient::mailArrived(const Email &mail, bool fromDisk) // if (item->getMail()->files.count()>0) // { // item->setPixmap(0, Resource::loadPixmap("mailit/attach")); -// } +// } /*if (!newMail.downloaded) mailDownloadList.sizeInsert(newMail.serverId, newMail.size);*/ - + mailboxView->setCurrentTab(0); - + } void EmailClient::allMailArrived(int /*count*/) @@ -495,18 +495,18 @@ void EmailClient::allMailArrived(int /*count*/) cancelButton->setEnabled(FALSE); selectAccountMenu->setEnabled(TRUE); status1Label->setText("Idle"); - + progressBar->reset(); return; } //} - + // all headers downloaded from server, start downloading remaining mails previewingMail = FALSE; status1Label->setText(currentAccount->accountName); progressBar->reset(); - + mailboxView->setCurrentTab(0); } @@ -521,7 +521,7 @@ void EmailClient::moveMailFront(Email *mailPtr) void EmailClient::smtpError(int code, const QString & Msg) { QString temp; - + if (code == ErrUnknownResponse) { temp = tr("Unknown response from server"); if( ! Msg.isEmpty() ) @@ -533,13 +533,13 @@ void EmailClient::smtpError(int code, const QString & Msg) } else if (code == QSocket::ErrSocketRead) { temp = tr("socket packet error"); } - + if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n"); } else { status2Label->setText("Aborted by user"); } - + sending = FALSE; sendMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); @@ -549,7 +549,7 @@ void EmailClient::smtpError(int code, const QString & Msg) void EmailClient::popError(int code, const QString & Msg) { QString temp; - + if (code == ErrUnknownResponse) { temp = tr("Unknown response from server"); if( ! Msg.isEmpty() ) @@ -562,7 +562,7 @@ void EmailClient::popError(int code, const QString & Msg) temp = tr("connection refused"); } else if (code == QSocket::ErrSocketRead) { temp = tr("socket packet error"); - } + } if (code != ErrCancel) { QMessageBox::warning(qApp->activeWindow(), tr("Receiving error"), temp, tr("OK\n")); @@ -570,7 +570,7 @@ void EmailClient::popError(int code, const QString & Msg) } else { status2Label->setText("Aborted by user"); } - + receiving = FALSE; getMailButton->setEnabled(TRUE); cancelButton->setEnabled(FALSE); @@ -580,7 +580,7 @@ void EmailClient::popError(int code, const QString & Msg) void EmailClient::inboxItemSelected() { //killTimer(timerID); - + item = (EmailListItem*) inboxView->selectedItem(); if (item != NULL) { emit viewEmail(inboxView, item->getMail()); @@ -590,7 +590,7 @@ void EmailClient::inboxItemSelected() void EmailClient::outboxItemSelected() { //killTimer(timerID); - + item = (EmailListItem*) outboxView->selectedItem(); if (item != NULL) { emit viewEmail(outboxView, item->getMail()); @@ -605,45 +605,45 @@ void EmailClient::readMail() QString s, del; QFile f(getPath(FALSE) + "inbox.txt"); - + if ( f.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &f ); // use a text stream s = t.read(); f.close(); - + start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); - + mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); mailArrived(mail, TRUE); } } - + QFile fo(getPath(FALSE) + "outbox.txt"); if ( fo.open(IO_ReadOnly) ) { // file opened successfully QTextStream t( &fo ); // use a text stream s = t.read(); fo.close(); - + start = 0; del = "\n.\n"; while ((uint) start < s.length()) { stop = s.find(del, start); if (stop == -1) stop = s.length() - del.length(); - + mail.rawMail = s.mid(start, stop + del.length() - start ); start = stop + del.length(); emailHandler->parse(mail.rawMail, lineShift, &mail); mail.sent = false; mail.received = false; enqueMail(mail); - + } } } @@ -652,7 +652,7 @@ void EmailClient::saveMail(const QString &fileName, QListView *view) { QFile f(fileName); Email *mail; - + if (! f.open(IO_WriteOnly) ) { qWarning("could not open file"); return; @@ -662,10 +662,10 @@ void EmailClient::saveMail(const QString &fileName, QListView *view) while (item != NULL) { mail = item->getMail(); t << mail->rawMail; - + mailconf->setGroup(mail->id); mailconf->writeEntry("mailread", mail->read); - + item = (EmailListItem *) item->nextSibling(); } f.close(); @@ -676,19 +676,19 @@ QString EmailClient::getPath(bool enclosurePath) { QString basePath = "qtmail"; QString enclosures = "enclosures"; - + QDir dir = (QString(getenv("HOME")) + "/Applications/" + basePath); if ( !dir.exists() ) dir.mkdir( dir.path() ); - + if (enclosurePath) { dir = (QString(getenv("HOME")) + "/Applications/" + basePath + "/" + enclosures); - + if ( !dir.exists() ) dir.mkdir( dir.path() ); - + return (dir.path() + "/"); - + } return (dir.path() + "/"); } @@ -696,13 +696,13 @@ QString EmailClient::getPath(bool enclosurePath) void EmailClient::readSettings() { int y,acc_count; - + mailconf->setGroup("mailitglobal"); acc_count=mailconf->readNumEntry("Accounts",0); - - for (int accountPos = 0;accountPossetGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... + mailconf->setGroup("Account_"+QString::number(accountPos+1)); //Account numbers start at 1 ... account.accountName = mailconf->readEntry("AccName",""); account.name = mailconf->readEntry("UserName",""); account.emailAddress = mailconf->readEntry("Email",""); @@ -714,23 +714,23 @@ void EmailClient::readSettings() account.syncLimit = mailconf->readNumEntry("HeaderLimit",0); account.lastServerMailCount = 0; account.synchronize = FALSE; - + account.synchronize = (mailconf->readEntry("Synchronize","No")=="Yes"); if (account.synchronize) { - mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); + mailconf->readNumEntry("LASTSERVERMAILCOUNT",0); } - + accountList.append(&account); } - + mailconf->setGroup("mailitglobal"); - - if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) + + if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { mailIdCount = y; } - if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) + if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { accountIdCount = y; } @@ -741,15 +741,15 @@ void EmailClient::saveSettings() int acc_count=0; MailAccount *accountPtr; - - if (!mailconf) + + if (!mailconf) { qWarning("could not save settings"); return; } - + for (accountPtr = accountList.first(); accountPtr != 0; - accountPtr = accountList.next()) + accountPtr = accountList.next()) { mailconf->setGroup("Account_"+QString::number(++acc_count)); mailconf->writeEntry("AccName",accountPtr->accountName ); @@ -760,18 +760,18 @@ void EmailClient::saveSettings() mailconf->writeEntry("POPServer",accountPtr->popServer); mailconf->writeEntry("SMTPServer",accountPtr->smtpServer); mailconf->writeEntry("AccountId",accountPtr->id); - if (accountPtr->synchronize) + if (accountPtr->synchronize) { mailconf->writeEntry("Synchronize","Yes"); mailconf->writeEntry("HeaderLimit",accountPtr->syncLimit); mailconf->writeEntry("LastServerMailCount",accountPtr->lastServerMailCount); - } - else + } + else { mailconf->writeEntry("Synchronize", "No"); } } - + mailconf->setGroup("mailitglobal"); mailconf->writeEntry("Accounts",acc_count); mailconf->writeEntry("mailidcount", mailIdCount); @@ -785,14 +785,14 @@ void EmailClient::selectAccount(int id) emit newCaption("Mailit - " + currentAccount->accountName); getNewMail(); } else { - emit newCaption("Mailit ! No account defined"); + emit newCaption( tr("Mailit ! No account defined") ); } } void EmailClient::editAccount(int id) { MailAccount *newAccount; - + editAccountView = new EditAccount(this, "account", TRUE); if (id == newAccountId) { //new account newAccount = new MailAccount; @@ -801,10 +801,10 @@ void EmailClient::editAccount(int id) newAccount = accountList.at(id); editAccountView->setAccount(newAccount, FALSE); } - + editAccountView->showMaximized(); editAccountView->exec(); - + if (editAccountView->result() == QDialog::Accepted) { if (id == newAccountId) { newAccount->id = accountIdCount; @@ -815,7 +815,7 @@ void EmailClient::editAccount(int id) updateAccounts(); } } - + delete editAccountView; } @@ -823,12 +823,12 @@ void EmailClient::deleteAccount(int id) { MailAccount *newAccount; QString message; - + newAccount = accountList.at(id); - message = "Delete account:\n" + newAccount->accountName; + message = tr("Delete account:\n") + newAccount->accountName; switch( QMessageBox::warning( this, "Mailit", message, "Yes", "No", 0, 0, 1 ) ) { - + case 0: accountList.remove(id); updateAccounts(); break; @@ -840,20 +840,20 @@ void EmailClient::deleteAccount(int id) void EmailClient::updateAccounts() { MailAccount *accountPtr; - + //rebuild menus, clear all first editAccountMenu->clear(); selectAccountMenu->clear(); deleteAccountMenu->clear(); - newAccountId = editAccountMenu->insertItem("New", this, + newAccountId = editAccountMenu->insertItem( tr("New"), this, SLOT(editAccount(int)) ); editAccountMenu->insertSeparator(); - + idCount = 0; for (accountPtr = accountList.first(); accountPtr != 0; accountPtr = accountList.next()) { - + editAccountMenu->insertItem(accountPtr->accountName, this, SLOT(editAccount(int)), 0, idCount); selectAccountMenu->insertItem(accountPtr->accountName, @@ -868,21 +868,21 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) { Email *mPtr; Enclosure *ePtr; - - if (inbox) + + if (inbox) { mPtr = mailItem->getMail(); - + //if mail is in queue for download, remove it from //queue if possible if ( (receiving) && (mPtr->fromAccountId == currentAccount->id) ) { if ( !mPtr->downloaded ) mailDownloadList.remove(mPtr->serverId, mPtr->size); } - + mailconf->setGroup(mPtr->id); mailconf->clearGroup(); - + //delete any temporary attatchemnts storing for ( ePtr=mPtr->files.first(); ePtr != 0; ePtr=mPtr->files.next() ) { if (ePtr->saved) { @@ -890,8 +890,8 @@ void EmailClient::deleteMail(EmailListItem *mailItem, bool &inbox) } } inboxView->takeItem(mailItem); - } - else + } + else { outboxView->takeItem(mailItem); } @@ -905,7 +905,7 @@ void EmailClient::setMailSize(int size) void EmailClient::setTotalSize(int /*size*/) { - + } void EmailClient::setDownloadedSize(int size) @@ -923,18 +923,18 @@ void EmailClient::deleteItem() { bool inbox=mailboxView->currentTab()==0; QListView* box; - + EmailListItem* eli; // int pos; - + inbox ? box=inboxView : box=outboxView; - + eli=(EmailListItem*)box->selectedItem(); - + if (eli) { box->setSelected(eli->itemBelow(),true); //select the previous item - + deleteMail(eli,(bool&)inbox); //remove mail entry } } @@ -952,21 +952,21 @@ void EmailClient::inboxItemReleased() /*void EmailClient::timerEvent(QTimerEvent *e) { //killTimer(timerID); - - + + QPopupMenu *action = new QPopupMenu(this); - + int reply=0; - + action->insertItem(tr( "Reply To" ),this,SLOT(reply())); action->insertItem( tr( "Reply All" ),this,SLOT(replyAll())); action->insertItem( tr( "Forward" ), this,SLOT(forward())); action->insertItem( tr( "Remove Mail" ), this,SLOT(remove())); - + action->exec(QCursor::pos()); - + if (action) delete action; - + }*/ Email* EmailClient::getCurrentMail() @@ -977,21 +977,21 @@ Email* EmailClient::getCurrentMail() else return NULL; } - + void EmailClient::download(Email* mail) { MailAccount* acc=0; - + tempMailDownloadList.clear(); tempMailDownloadList.sizeInsert(mail->serverId, mail->size); - + acc=accountList.at(mail->fromAccountId-1); if (acc) - { + { emailHandler->setAccount(*acc); emailHandler->getMailByList(&tempMailDownloadList); } - else + else QMessageBox::warning(qApp->activeWindow(), tr("No account associated"), tr("There is no active account \nassociated to this mail\n it can not be downloaded"), "Abort\n"); } @@ -1002,9 +1002,9 @@ void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/) { //QDialog qd(qApp->activeWindow(),"Getting mail",true); QVBoxLayout *vbProg = new QVBoxLayout( &qd ); - + initStatusBar(&qd); - + if (statusBar==0) { qDebug("No Bar ..."); @@ -1018,23 +1018,23 @@ void EmailClient::receive(const QCString& /*msg*/, const QByteArray& /*data*/) //qd.exec(); } else if (msg=="compose()") - { + { QDialog qd(qApp->activeWindow(),"Getting mail",true); - + WriteMail wm(&qd,"write new mail"); QVBoxLayout vbProg( &qd ); - + wm.showMaximized(); vbProg.addWidget(&wm); - + qd.showMaximized(); - + emit composeRequested(); qd.exec(); - + QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); } - + else if (msg=="dialog()") { QMessageBox::warning(qApp->activeWindow(),tr("Info"), tr("Info"), "OK\n"); diff --git a/noncore/unsupported/mailit/emaillistitem.cpp b/noncore/unsupported/mailit/emaillistitem.cpp index fc9f766..a25f93a 100644 --- a/noncore/unsupported/mailit/emaillistitem.cpp +++ b/noncore/unsupported/mailit/emaillistitem.cpp @@ -25,9 +25,9 @@ EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) : QListViewItem(parent) { QString temp; - + mail = mailIn; - + if (inbox) { setText(0, mail.from); } else { @@ -38,13 +38,14 @@ EmailListItem::EmailListItem(QListView *parent, Email mailIn, bool inbox) setText(0, temp); } setText(1, mail.subject); - setText(2,mail.date); - + // setText(2,mail.date); + setText(2,dateFromULCString(mail.date)); + if (mailIn.files.count()>0) { setPixmap(0, Resource::loadPixmap("mailit/attach")); } - + selected = FALSE; } @@ -82,7 +83,7 @@ void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, _cg.setColor( QColorGroup::Text, Qt::blue); if (!mail.downloaded) _cg.setColor( QColorGroup::Text, Qt::red); - + /* if (selected) { _cg.setColor(QColorGroup::Base, Qt::blue); _cg.setColor(QColorGroup::Text, Qt::yellow); @@ -92,8 +93,66 @@ void EmailListItem::paintCell( QPainter *p, const QColorGroup &cg, _cg.setColor(QColorGroup::Highlight, Qt::blue); } } -*/ +*/ QListViewItem::paintCell( p, _cg, column, width, alignment ); _cg.setColor( QColorGroup::Text, c ); } + +/* + * Converts an E-Mail date (ULC) RFC 2822 conform to a QDateTime. + * Returning a QString with formatting of "YYYY-MM-DD HH:MM:SS" + * (zodiac: This method was tested with more than 300 inbox mails, + * it didn't slow down the loading of mail-it.) + */ +QString EmailListItem::dateFromULCString( QString ulcDate ) +{ + QString sTemp, sTime; + int iPos, iDay, iMon=1, iYear; + + iPos=ulcDate.find(','); + if (iPos) { // it has a day-of-week + ulcDate=ulcDate.remove(0,++iPos); //.stripWhiteSpace(); + } + + QStringList dateEntries = QStringList::split(" ",ulcDate,FALSE); + QStringList::Iterator iter = dateEntries.begin(); + + // Get day as DD + iDay = (*iter++).toInt(); + + // Get month as string Mmm + sTemp = (*iter++); + if (sTemp =="Jan") {iMon=1;} else + if (sTemp =="Feb") {iMon=2;} else + if (sTemp =="Mar") {iMon=3;} else + if (sTemp =="Apr") {iMon=4;} else + if (sTemp =="May") {iMon=5;} else + if (sTemp =="Jun") {iMon=6;} else + if (sTemp =="Jul") {iMon=7;} else + if (sTemp =="Aug") {iMon=8;} else + if (sTemp =="Sep") {iMon=9;} else + if (sTemp =="Oct") {iMon=10;} else + if (sTemp =="Nov") {iMon=11;} else + if (sTemp =="Dec") {iMon=12;} + + // Get year as YYYY or YY + iYear = (*iter++).toInt(); + + QDate date = QDate(iYear, iMon, iDay); + + // Convert timestring into a QTime + QStringList timeEntries = QStringList::split(":",(*iter++),FALSE); + QStringList::Iterator iterTime = timeEntries.begin(); + iYear=(*iterTime++).toInt(); // var reuse.. *cough* + iMon=(*iterTime++).toInt(); + iDay=(*iterTime++).toInt(); + QTime time = QTime(iYear,iMon,iDay); + + return QString::number(date.year())+"-" + +QString::number(date.month()).rightJustify(2,'0')+"-" + +QString::number(date.day()).rightJustify(2,'0')+" " + +time.toString(); +} + + diff --git a/noncore/unsupported/mailit/emaillistitem.h b/noncore/unsupported/mailit/emaillistitem.h index 642932c..129a774 100644 --- a/noncore/unsupported/mailit/emaillistitem.h +++ b/noncore/unsupported/mailit/emaillistitem.h @@ -32,13 +32,14 @@ public: void setItemSelected(bool enable); bool isItemSelected(); bool itemSelected(); - + protected: void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); private: Email mail; bool selected; + QString dateFromULCString( QString ulc ); }; #endif diff --git a/noncore/unsupported/mailit/mailit.pro b/noncore/unsupported/mailit/mailit.pro index 5e9a83a..0224886 100644 --- a/noncore/unsupported/mailit/mailit.pro +++ b/noncore/unsupported/mailit/mailit.pro @@ -1,6 +1,5 @@ -TEMPLATE = app TARGET = mailit -CONFIG = qt warn_on release +CONFIG = qt warn_on release quick-app HEADERS = emailclient.h \ emailhandler.h \ emaillistitem.h \ @@ -37,9 +36,6 @@ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopie # -lssl -MOC_DIR=qpeobj -OBJECTS_DIR=qpeobj -DESTDIR=$(OPIEDIR)/bin TRANSLATIONS = ../../../i18n/de/mailit.ts \ ../../../i18n/nl/mailit.ts \ diff --git a/noncore/unsupported/mailit/mailitwindow.h b/noncore/unsupported/mailit/mailitwindow.h index e818d32..11e56b9 100644 --- a/noncore/unsupported/mailit/mailitwindow.h +++ b/noncore/unsupported/mailit/mailitwindow.h @@ -33,6 +33,7 @@ class MailItWindow: public QMainWindow { Q_OBJECT public: + static QString appName() { return QString::fromLatin1("mailit"); } MailItWindow(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); ~MailItWindow(); diff --git a/noncore/unsupported/mailit/main.cpp b/noncore/unsupported/mailit/main.cpp index 3a3e1fc..71f8877 100644 --- a/noncore/unsupported/mailit/main.cpp +++ b/noncore/unsupported/mailit/main.cpp @@ -20,10 +20,6 @@ #include #include "mailitwindow.h" -int main(int argc, char* argv[]) -{ - QPEApplication a( argc, argv ); - MailItWindow mw(0, 0); - a.showMainDocumentWidget(&mw); - return a.exec(); -} +#include + +OPIE_EXPORT_APP( OApplicationFactory ) \ No newline at end of file -- cgit v0.9.0.2