summaryrefslogtreecommitdiff
path: root/noncore/net/mailit/emailclient.cpp
Side-by-side diff
Diffstat (limited to 'noncore/net/mailit/emailclient.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mailit/emailclient.cpp65
1 files changed, 26 insertions, 39 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp
index 23059cf..dff1888 100644
--- a/noncore/net/mailit/emailclient.cpp
+++ b/noncore/net/mailit/emailclient.cpp
@@ -341,49 +341,49 @@ void EmailClient::getAllNewMail()
getNewMail();
}
void EmailClient::mailArrived(const Email &mail, bool fromDisk)
{
Enclosure *ePtr;
Email newMail;
int thisMailId;
emailHandler->parse(mail.rawMail, lineShift, &newMail);
mailconf->setGroup(newMail.id);
if (fromDisk)
{
newMail.downloaded = mailconf->readBoolEntry("downloaded");
newMail.size = mailconf->readNumEntry("size");
newMail.serverId = mailconf->readNumEntry("serverid");
newMail.fromAccountId = mailconf->readNumEntry("fromaccountid");
}
else
{ //mail arrived from server
newMail.serverId = mail.serverId;
newMail.size = mail.size;
newMail.downloaded = mail.downloaded;
- newMail.fromAccountId = currentAccount->id;
+ 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);
}
@@ -459,53 +459,53 @@ void EmailClient::allMailArrived(int count)
// not previewing means all mailtransfer has been done
/*if (!previewingMail) {*/
if ( (allAccounts) && ( (currentAccount = accountList.next()) !=0 ) ) {
emit newCaption("Mailit - " + currentAccount->accountName);
getNewMail();
return;
} else {
allAccounts = FALSE;
receiving = FALSE;
getMailButton->setEnabled(TRUE);
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();
- //emailHandler->getMailByList(&mailDownloadList);
mailboxView->setCurrentTab(0);
}
+
void EmailClient::moveMailFront(Email *mailPtr)
{
if ( (receiving) && (mailPtr->fromAccountId == currentAccount->id) ) {
mailDownloadList.moveFront(mailPtr->serverId, mailPtr->size);
}
}
void EmailClient::smtpError(int code)
{
QString temp;
if (code == ErrUnknownResponse)
temp = "Unknown response from server";
if (code == QSocket::ErrHostNotFound)
temp = "host not found";
if (code == QSocket::ErrConnectionRefused)
temp = "connection refused";
if (code == QSocket::ErrSocketRead)
temp = "socket packet error";
if (code != ErrCancel) {
QMessageBox::warning(qApp->activeWindow(), "Sending error", temp, "OK\n");
} else {
@@ -643,49 +643,49 @@ void EmailClient::saveMail(QString fileName, QListView *view)
//paths for mailit, is settings, inbox, enclosures
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() + "/");
}
void EmailClient::readSettings()
{
- int y,acc_count, accountPos=0;
+ int y,acc_count;
mailconf->setGroup("mailitglobal");
acc_count=mailconf->readNumEntry("Accounts",0);
for (int accountPos = 0;accountPos<acc_count ; accountPos++)
{
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","");
account.popUserName = mailconf->readEntry("POPUser","");
account.popPasswd = mailconf->readEntryCrypt("POPPassword","");
account.popServer = mailconf->readEntry("POPServer","");
account.smtpServer = mailconf->readEntry("SMTPServer","");
account.id = mailconf->readNumEntry("AccountId",0);
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);
}
@@ -870,112 +870,99 @@ void EmailClient::setMailSize(int size)
{
progressBar->reset();
progressBar->setTotalSteps(size);
}
void EmailClient::setTotalSize(int size)
{
}
void EmailClient::setDownloadedSize(int size)
{
int total = progressBar->totalSteps();
if (size < total) {
progressBar->setProgress(size);
} else {
progressBar->setProgress(total);
}
}
void EmailClient::deleteItem()
{
bool inbox=mailboxView->currentTab()==0;
+ QListView* box;
EmailListItem* eli;
+ int pos;
+
+ inbox ? box=inboxView : box=outboxView;
- inbox ? eli=(EmailListItem*)inboxView->selectedItem():eli=(EmailListItem*)outboxView->selectedItem();
+ eli=(EmailListItem*)box->selectedItem();
if (eli)
- deleteMail(eli,(bool&)inbox);
+ {
+ box->setSelected(eli->itemBelow(),true); //select the previous item
+
+ deleteMail(eli,(bool&)inbox); //remove mail entry
+ }
}
void EmailClient::inboxItemPressed()
{
// timerID=startTimer(500);
}
void EmailClient::inboxItemReleased()
{
// killTimer(timerID);
}
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()
{
EmailListItem *eli=(EmailListItem* ) (inboxView->selectedItem());
if (eli!=NULL)
return eli->getMail();
else
return NULL;
}
-/*
-void EmailClient::reply()
-{
- Email* mail=getCurrentMail();
-
- if (mail!=NULL)
+void EmailClient::download(Email* mail)
{
- emit reply(*mail);
- }
-}
+ MailAccount* acc=0;
-void EmailClient::replyAll()
-{
- Email* mail=getCurrentMail();
+ tempMailDownloadList.clear();
+ tempMailDownloadList.sizeInsert(mail->serverId, mail->size);
+ if (accountList.count()>0)
+ qDebug("Accounts present");
- if (mail!=NULL)
+ acc=accountList.at(mail->fromAccountId-1);
+ if (acc)
{
- emit replyAll(*mail);
- }
+ emailHandler->setAccount(*acc);
+ emailHandler->getMailByList(&tempMailDownloadList);
}
-
-void EmailClient::forward()
-{
- Email* mail=getCurrentMail();
-
- if (mail!=NULL)
- {
- emit reply(*mail);
- }
-}
-
-void EmailClient::remove()
-{
- Email* mail=getCurrentMail();
-
- if (mail!=NULL)
- {
- emit remove(*mail);
+ 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");
}
-}*/