-rw-r--r-- | kmicromail/composemail.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 14feeee..01dd406 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -1,170 +1,170 @@ | |||
1 | // CHANGED 2004-08-06 Lutz Rogowski | 1 | // CHANGED 2004-08-06 Lutz Rogowski |
2 | 2 | ||
3 | #include "composemail.h" | 3 | #include "composemail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/smtpwrapper.h> | 5 | #include <libmailwrapper/smtpwrapper.h> |
6 | #include <libmailwrapper/storemail.h> | 6 | #include <libmailwrapper/storemail.h> |
7 | #include <libmailwrapper/abstractmail.h> | 7 | #include <libmailwrapper/abstractmail.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/ofiledialog.h> | 11 | //#include <opie2/ofiledialog.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | #include <kfiledialog.h> | 13 | #include <kfiledialog.h> |
14 | //#include <qpe/resource.h> | 14 | //#include <qpe/resource.h> |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/global.h> | 16 | #include <qpe/global.h> |
17 | //#include <qpe/contact.h> | 17 | //#include <qpe/contact.h> |
18 | 18 | ||
19 | 19 | ||
20 | #include <qcombobox.h> | 20 | #include <qcombobox.h> |
21 | #include <qcheckbox.h> | 21 | #include <qcheckbox.h> |
22 | #include <qtimer.h> | 22 | #include <qtimer.h> |
23 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qmultilineedit.h> | 25 | #include <qmultilineedit.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qtabwidget.h> | 27 | #include <qtabwidget.h> |
28 | #include <qlistview.h> | 28 | #include <qlistview.h> |
29 | #include <kabc/addresseedialog.h> | 29 | #include <kabc/addresseedialog.h> |
30 | #include <kabc/stdaddressbook.h> | 30 | #include <kabc/stdaddressbook.h> |
31 | #include <kabc/addressee.h> | 31 | #include <kabc/addressee.h> |
32 | #ifdef DESKTOP_VERSION | 32 | #ifdef DESKTOP_VERSION |
33 | #include <kabc/addresseedialog.h> | 33 | #include <kabc/addresseedialog.h> |
34 | #else //DESKTOP_VERSION | 34 | #else //DESKTOP_VERSION |
35 | #include <libkdepim/externalapphandler.h> | 35 | #include <libkdepim/externalapphandler.h> |
36 | #endif //DESKTOP_VERSION | 36 | #endif //DESKTOP_VERSION |
37 | 37 | ||
38 | 38 | ||
39 | //using namespace Opie::Core; | 39 | //using namespace Opie::Core; |
40 | //using namespace Opie::Ui; | 40 | //using namespace Opie::Ui; |
41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal, WFlags flags ) | 41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) |
42 | : ComposeMailUI( parent, name, modal, flags ) | 42 | : ComposeMailUI( parent, name, modal ) |
43 | { | 43 | { |
44 | 44 | ||
45 | mPickLineEdit = 0; | 45 | mPickLineEdit = 0; |
46 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 46 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
47 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 47 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
48 | settings = s; | 48 | settings = s; |
49 | m_replyid = ""; | 49 | m_replyid = ""; |
50 | KConfig config( locateLocal("config", "kabcrc") ); | 50 | KConfig config( locateLocal("config", "kabcrc") ); |
51 | config.setGroup( "General" ); | 51 | config.setGroup( "General" ); |
52 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 52 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
53 | if ( whoami_uid.isEmpty() ) { | 53 | if ( whoami_uid.isEmpty() ) { |
54 | QMessageBox::information( 0, tr( "Hint" ), | 54 | QMessageBox::information( 0, tr( "Hint" ), |
55 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 55 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
56 | tr( "Ok" ) ); | 56 | tr( "Ok" ) ); |
57 | 57 | ||
58 | } else | 58 | } else |
59 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 59 | bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
60 | #ifdef DESKTOP_VERSION | 60 | #ifdef DESKTOP_VERSION |
61 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 61 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
62 | QStringList mails = con.emails(); | 62 | QStringList mails = con.emails(); |
63 | QString defmail = con.preferredEmail(); | 63 | QString defmail = con.preferredEmail(); |
64 | if ( mails.count() == 0) | 64 | if ( mails.count() == 0) |
65 | QMessageBox::information( 0, tr( "Hint" ), | 65 | QMessageBox::information( 0, tr( "Hint" ), |
66 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 66 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
67 | tr( "Ok" ) ); | 67 | tr( "Ok" ) ); |
68 | if (defmail.length()!=0) { | 68 | if (defmail.length()!=0) { |
69 | fromBox->insertItem(defmail); | 69 | fromBox->insertItem(defmail); |
70 | } | 70 | } |
71 | QStringList::ConstIterator sit = mails.begin(); | 71 | QStringList::ConstIterator sit = mails.begin(); |
72 | for (;sit!=mails.end();++sit) { | 72 | for (;sit!=mails.end();++sit) { |
73 | if ( (*sit)==defmail) | 73 | if ( (*sit)==defmail) |
74 | continue; | 74 | continue; |
75 | fromBox->insertItem((*sit)); | 75 | fromBox->insertItem((*sit)); |
76 | } | 76 | } |
77 | senderNameEdit->setText(con.formattedName()); | 77 | senderNameEdit->setText(con.formattedName()); |
78 | #endif | 78 | #endif |
79 | Config cfg( "mail" ); | 79 | Config cfg( "mail" ); |
80 | cfg.setGroup( "Compose" ); | 80 | cfg.setGroup( "Compose" ); |
81 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 81 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); |
82 | 82 | ||
83 | attList->addColumn( tr( "Name" ) ); | 83 | attList->addColumn( tr( "Name" ) ); |
84 | attList->addColumn( tr( "Size" ) ); | 84 | attList->addColumn( tr( "Size" ) ); |
85 | 85 | ||
86 | QList<Account> accounts = settings->getAccounts(); | 86 | QList<Account> accounts = settings->getAccounts(); |
87 | 87 | ||
88 | Account *it; | 88 | Account *it; |
89 | for ( it = accounts.first(); it; it = accounts.next() ) { | 89 | for ( it = accounts.first(); it; it = accounts.next() ) { |
90 | if ( it->getType()==MAILLIB::A_SMTP ) { | 90 | if ( it->getType()==MAILLIB::A_SMTP ) { |
91 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 91 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
92 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 92 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
93 | smtpAccounts.append( smtp ); | 93 | smtpAccounts.append( smtp ); |
94 | } | 94 | } |
95 | } | 95 | } |
96 | if ( smtpAccounts.count() > 0 ) { | 96 | if ( smtpAccounts.count() > 0 ) { |
97 | fillValues( smtpAccountBox->currentItem() ); | 97 | fillValues( smtpAccountBox->currentItem() ); |
98 | } else { | 98 | } else { |
99 | QMessageBox::information( 0, tr( "Problem" ), | 99 | QMessageBox::information( 0, tr( "Problem" ), |
100 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | 100 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), |
101 | tr( "Ok" ) ); | 101 | tr( "Ok" ) ); |
102 | return; | 102 | return; |
103 | } | 103 | } |
104 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 104 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
105 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 105 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
106 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 106 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
107 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 107 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
108 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 108 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
109 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 109 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
110 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 110 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
111 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 111 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
112 | mMail = 0; | 112 | mMail = 0; |
113 | warnAttach = true; | 113 | warnAttach = true; |
114 | 114 | ||
115 | } | 115 | } |
116 | 116 | ||
117 | 117 | ||
118 | 118 | ||
119 | void ComposeMail::saveAsDraft() | 119 | void ComposeMail::saveAsDraft() |
120 | { | 120 | { |
121 | 121 | ||
122 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 122 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
123 | mail->setMail(fromBox->currentText()); | 123 | mail->setMail(fromBox->currentText()); |
124 | mail->setTo( toLine->text() ); | 124 | mail->setTo( toLine->text() ); |
125 | mail->setName(senderNameEdit->text()); | 125 | mail->setName(senderNameEdit->text()); |
126 | mail->setCC( ccLine->text() ); | 126 | mail->setCC( ccLine->text() ); |
127 | mail->setBCC( bccLine->text() ); | 127 | mail->setBCC( bccLine->text() ); |
128 | mail->setReply( replyLine->text() ); | 128 | mail->setReply( replyLine->text() ); |
129 | mail->setSubject( subjectLine->text() ); | 129 | mail->setSubject( subjectLine->text() ); |
130 | if (!m_replyid.isEmpty()) { | 130 | if (!m_replyid.isEmpty()) { |
131 | QStringList ids; | 131 | QStringList ids; |
132 | ids.append(m_replyid); | 132 | ids.append(m_replyid); |
133 | mail->setInreply(ids); | 133 | mail->setInreply(ids); |
134 | } | 134 | } |
135 | QString txt = message->text(); | 135 | QString txt = message->text(); |
136 | if ( !sigMultiLine->text().isEmpty() ) { | 136 | if ( !sigMultiLine->text().isEmpty() ) { |
137 | txt.append( "\n--\n" ); | 137 | txt.append( "\n--\n" ); |
138 | txt.append( sigMultiLine->text() ); | 138 | txt.append( sigMultiLine->text() ); |
139 | } | 139 | } |
140 | mail->setMessage( txt ); | 140 | mail->setMessage( txt ); |
141 | 141 | ||
142 | /* only use the default drafts folder name! */ | 142 | /* only use the default drafts folder name! */ |
143 | Storemail wrapper(AbstractMail::draftFolder()); | 143 | Storemail wrapper(AbstractMail::draftFolder()); |
144 | wrapper.storeMail(mail); | 144 | wrapper.storeMail(mail); |
145 | 145 | ||
146 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 146 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
147 | /* attachments we will ignore! */ | 147 | /* attachments we will ignore! */ |
148 | if ( it != 0 ) { | 148 | if ( it != 0 ) { |
149 | if ( warnAttach ) | 149 | if ( warnAttach ) |
150 | QMessageBox::warning(0,tr("Store message"), | 150 | QMessageBox::warning(0,tr("Store message"), |
151 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); | 151 | tr("<center>Attachments will not be stored in \"Draft\" folder</center>")); |
152 | warnAttach = false; | 152 | warnAttach = false; |
153 | } | 153 | } |
154 | setStatus( tr("Mail saved as draft!") ); | 154 | setStatus( tr("Mail saved as draft!") ); |
155 | } | 155 | } |
156 | void ComposeMail::clearStatus() | 156 | void ComposeMail::clearStatus() |
157 | { | 157 | { |
158 | topLevelWidget()->setCaption( tr("Compose mail") ); | 158 | topLevelWidget()->setCaption( tr("Compose mail") ); |
159 | } | 159 | } |
160 | void ComposeMail::setStatus( QString status ) | 160 | void ComposeMail::setStatus( QString status ) |
161 | { | 161 | { |
162 | topLevelWidget()->setCaption( status ); | 162 | topLevelWidget()->setCaption( status ); |
163 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; | 163 | QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; |
164 | } | 164 | } |
165 | void ComposeMail::pickAddress( ) | 165 | void ComposeMail::pickAddress( ) |
166 | { | 166 | { |
167 | 167 | ||
168 | QLineEdit *line = mPickLineEdit; | 168 | QLineEdit *line = mPickLineEdit; |
169 | if ( line == 0 ) | 169 | if ( line == 0 ) |
170 | return; | 170 | return; |