Diffstat (limited to 'noncore/net/mailit/emailclient.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/mailit/emailclient.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/noncore/net/mailit/emailclient.cpp b/noncore/net/mailit/emailclient.cpp index 2943986..6612541 100644 --- a/noncore/net/mailit/emailclient.cpp +++ b/noncore/net/mailit/emailclient.cpp | |||
@@ -2,67 +2,67 @@ | |||
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | #include <qfile.h> | 22 | #include <qfile.h> |
23 | #include <qcheckbox.h> | 23 | #include <qcheckbox.h> |
24 | #include <qmenubar.h> | 24 | #include <qmenubar.h> |
25 | #include <qaction.h> | 25 | #include <qaction.h> |
26 | #include "resource.h" | 26 | #include <qpe/resource.h> |
27 | #include "emailclient.h" | 27 | #include "emailclient.h" |
28 | 28 | ||
29 | QCollection::Item AccountList::newItem(QCollection::Item d) | 29 | QCollection::Item AccountList::newItem(QCollection::Item d) |
30 | { | 30 | { |
31 | return dupl( (MailAccount *) d); | 31 | return dupl( (MailAccount *) d); |
32 | } | 32 | } |
33 | 33 | ||
34 | MailAccount* AccountList::dupl(MailAccount *in) | 34 | MailAccount* AccountList::dupl(MailAccount *in) |
35 | { | 35 | { |
36 | ac = new MailAccount(*in); | 36 | ac = new MailAccount(*in); |
37 | return ac; | 37 | return ac; |
38 | } | 38 | } |
39 | 39 | ||
40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) | 40 | EmailClient::EmailClient( QWidget* parent, const char* name, WFlags fl ) |
41 | : QMainWindow( parent, name, fl ) | 41 | : QMainWindow( parent, name, fl ) |
42 | { | 42 | { |
43 | emailHandler = new EmailHandler(); | 43 | emailHandler = new EmailHandler(); |
44 | addressList = new AddressList( getPath(FALSE) + "mail_adr"); | 44 | addressList = new AddressList(); |
45 | 45 | ||
46 | sending = FALSE; | 46 | sending = FALSE; |
47 | receiving = FALSE; | 47 | receiving = FALSE; |
48 | previewingMail = FALSE; | 48 | previewingMail = FALSE; |
49 | mailIdCount = 1; | 49 | mailIdCount = 1; |
50 | accountIdCount = 1; | 50 | accountIdCount = 1; |
51 | allAccounts = FALSE; | 51 | allAccounts = FALSE; |
52 | 52 | ||
53 | init(); | 53 | init(); |
54 | 54 | ||
55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); | 55 | connect(emailHandler, SIGNAL(mailSent()), this, SLOT(mailSent()) ); |
56 | 56 | ||
57 | connect(emailHandler, SIGNAL(smtpError(int)), this, | 57 | connect(emailHandler, SIGNAL(smtpError(int)), this, |
58 | SLOT(smtpError(int)) ); | 58 | SLOT(smtpError(int)) ); |
59 | connect(emailHandler, SIGNAL(popError(int)), this, | 59 | connect(emailHandler, SIGNAL(popError(int)), this, |
60 | SLOT(popError(int)) ); | 60 | SLOT(popError(int)) ); |
61 | 61 | ||
62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); | 62 | connect(inboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(inboxItemSelected()) ); |
63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); | 63 | connect(outboxView, SIGNAL(clicked(QListViewItem *)), this, SLOT(outboxItemSelected()) ); |
64 | 64 | ||
65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, | 65 | connect(emailHandler, SIGNAL(mailArrived(const Email &, bool)), this, |
66 | SLOT(mailArrived(const Email &, bool)) ); | 66 | SLOT(mailArrived(const Email &, bool)) ); |
67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, | 67 | connect(emailHandler, SIGNAL(mailTransfered(int)), this, |
68 | SLOT(allMailArrived(int)) ); | 68 | SLOT(allMailArrived(int)) ); |
@@ -650,93 +650,101 @@ void EmailClient::readSettings() | |||
650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) | 650 | if ( (pos = p->find("POPUSER",':', accountPos, TRUE)) != -1) |
651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); | 651 | account.popUserName = p->getString(& ++pos, 'z', TRUE); |
652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) | 652 | if ( (pos = p->find("POPPASSWORD",':', accountPos, TRUE)) != -1) |
653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); | 653 | account.popPasswd = p->getString(& ++pos, 'z', TRUE); |
654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) | 654 | if ( (pos = p->find("POPSERVER",':', accountPos, TRUE)) != -1) |
655 | account.popServer = p->getString(& ++pos, 'z', TRUE); | 655 | account.popServer = p->getString(& ++pos, 'z', TRUE); |
656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) | 656 | if ( (pos = p->find("SMTPSERVER",':', accountPos, TRUE)) != -1) |
657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); | 657 | account.smtpServer = p->getString(& ++pos, 'z', TRUE); |
658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { | 658 | if ( (pos = p->find("ACCOUNTID",':', accountPos, TRUE)) != -1) { |
659 | s = p->getString(& ++pos, 'z', TRUE); | 659 | s = p->getString(& ++pos, 'z', TRUE); |
660 | account.id = s.toInt(); | 660 | account.id = s.toInt(); |
661 | } | 661 | } |
662 | 662 | ||
663 | account.lastServerMailCount = 0; | 663 | account.lastServerMailCount = 0; |
664 | account.synchronize = FALSE; | 664 | account.synchronize = FALSE; |
665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { | 665 | if ( (pos = p->find("SYNCHRONIZE",':', accountPos, TRUE)) != -1) { |
666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { | 666 | if (p->getString(& ++pos, 'z', TRUE).upper() == "YES") { |
667 | account.synchronize = TRUE; | 667 | account.synchronize = TRUE; |
668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { | 668 | if ( (pos = p->find("LASTSERVERMAILCOUNT",':', accountPos, TRUE)) != -1) { |
669 | s = p->getString(& ++pos, 'z', TRUE); | 669 | s = p->getString(& ++pos, 'z', TRUE); |
670 | account.lastServerMailCount = s.toInt(); | 670 | account.lastServerMailCount = s.toInt(); |
671 | } | 671 | } |
672 | } | 672 | } |
673 | } | 673 | } |
674 | |||
675 | if ( (pos = p->find("SYNCLIMIT",':', accountPos, TRUE)) != -1) { | ||
676 | account.syncLimit = p->getString(& ++pos, 'z', TRUE).toInt(); | ||
677 | } | ||
678 | |||
679 | |||
674 | accountList.append(&account); | 680 | accountList.append(&account); |
675 | } | 681 | } |
676 | delete p; | 682 | delete p; |
677 | } | 683 | } |
678 | mailconf->setGroup("mailitglobal"); | 684 | mailconf->setGroup("mailitglobal"); |
679 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { | 685 | if ( (y = mailconf->readNumEntry("mailidcount", -1)) != -1) { |
680 | mailIdCount = y; | 686 | mailIdCount = y; |
681 | } | 687 | } |
682 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { | 688 | if ( (y = mailconf->readNumEntry("accountidcount", -1)) != -1) { |
683 | accountIdCount = y; | 689 | accountIdCount = y; |
684 | } | 690 | } |
685 | } | 691 | } |
686 | 692 | ||
687 | void EmailClient::saveSettings() | 693 | void EmailClient::saveSettings() |
688 | { | 694 | { |
689 | QString temp; | 695 | QString temp; |
690 | QFile f( getPath(FALSE) + "settings.txt"); | 696 | QFile f( getPath(FALSE) + "settings.txt"); |
691 | MailAccount *accountPtr; | 697 | MailAccount *accountPtr; |
692 | 698 | ||
693 | if (! f.open(IO_WriteOnly) ) { | 699 | if (! f.open(IO_WriteOnly) ) { |
694 | qWarning("could not save settings file"); | 700 | qWarning("could not save settings file"); |
695 | return; | 701 | return; |
696 | } | 702 | } |
697 | QTextStream t(&f); | 703 | QTextStream t(&f); |
698 | t << "#Settings for QPE Mailit program\n"; | 704 | t << "#Settings for QPE Mailit program\n"; |
699 | 705 | ||
700 | for (accountPtr = accountList.first(); accountPtr != 0; | 706 | for (accountPtr = accountList.first(); accountPtr != 0; |
701 | accountPtr = accountList.next()) { | 707 | accountPtr = accountList.next()) { |
702 | 708 | ||
703 | t << "accountStart;\n"; | 709 | t << "accountStart;\n"; |
704 | t << "AccountName: " + accountPtr->accountName + "\n"; | 710 | t << "AccountName: " + accountPtr->accountName + "\n"; |
705 | t << "Name: " + accountPtr->name + "\n"; | 711 | t << "Name: " + accountPtr->name + "\n"; |
706 | t << "Email: " + accountPtr->emailAddress + "\n"; | 712 | t << "Email: " + accountPtr->emailAddress + "\n"; |
707 | t << "POPUser: " + accountPtr->popUserName + "\n"; | 713 | t << "POPUser: " + accountPtr->popUserName + "\n"; |
708 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; | 714 | t << "POPPAssword: " + accountPtr->popPasswd + "\n"; |
709 | t << "POPServer: " + accountPtr->popServer + "\n"; | 715 | t << "POPServer: " + accountPtr->popServer + "\n"; |
710 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; | 716 | t << "SMTPServer: " + accountPtr->smtpServer + "\n"; |
711 | t << "AccountId: " << accountPtr->id << "\n"; | 717 | t << "AccountId: " << accountPtr->id << "\n"; |
712 | if (accountPtr->synchronize) { | 718 | if (accountPtr->synchronize) { |
713 | t << "Synchronize: Yes\n"; | 719 | t << "Synchronize: Yes\n"; |
714 | t << "LastServerMailCount: "; | 720 | t << "LastServerMailCount: "; |
715 | t << accountPtr->lastServerMailCount << "\n"; | 721 | t << accountPtr->lastServerMailCount << "\n"; |
716 | } else { | 722 | } else { |
717 | t << "Synchronize: No\n"; | 723 | t << "Synchronize: No\n"; |
718 | } | 724 | } |
725 | t << "SyncLimit: "; | ||
726 | t << accountPtr->syncLimit << "\n"; | ||
719 | t << "accountEnd;\n"; | 727 | t << "accountEnd;\n"; |
720 | } | 728 | } |
721 | f.close(); | 729 | f.close(); |
722 | 730 | ||
723 | mailconf->setGroup("mailitglobal"); | 731 | mailconf->setGroup("mailitglobal"); |
724 | mailconf->writeEntry("mailidcount", mailIdCount); | 732 | mailconf->writeEntry("mailidcount", mailIdCount); |
725 | mailconf->writeEntry("accountidcount", accountIdCount); | 733 | mailconf->writeEntry("accountidcount", accountIdCount); |
726 | } | 734 | } |
727 | 735 | ||
728 | void EmailClient::selectAccount(int id) | 736 | void EmailClient::selectAccount(int id) |
729 | { | 737 | { |
730 | if (accountList.count() > 0) { | 738 | if (accountList.count() > 0) { |
731 | currentAccount = accountList.at(id); | 739 | currentAccount = accountList.at(id); |
732 | emit newCaption("Mailit - " + currentAccount->accountName); | 740 | emit newCaption("Mailit - " + currentAccount->accountName); |
733 | getNewMail(); | 741 | getNewMail(); |
734 | } else { | 742 | } else { |
735 | emit newCaption("Mailit ! No account defined"); | 743 | emit newCaption("Mailit ! No account defined"); |
736 | } | 744 | } |
737 | } | 745 | } |
738 | 746 | ||
739 | void EmailClient::editAccount(int id) | 747 | void EmailClient::editAccount(int id) |
740 | { | 748 | { |
741 | MailAccount *newAccount; | 749 | MailAccount *newAccount; |
742 | 750 | ||