summaryrefslogtreecommitdiff
authorzecke <zecke>2004-10-23 13:36:29 (UTC)
committer zecke <zecke>2004-10-23 13:36:29 (UTC)
commitb5d111eb79896d02aa13d41a04ce6aa4dbc4aa49 (patch) (unidiff)
tree6f350aa52697c9ed9ecf7bed6796c4138cb70f68
parentaac8188fde70fc5cfa9f44c6a80a907e44f0f1eb (diff)
downloadopie-b5d111eb79896d02aa13d41a04ce6aa4dbc4aa49.zip
opie-b5d111eb79896d02aa13d41a04ce6aa4dbc4aa49.tar.gz
opie-b5d111eb79896d02aa13d41a04ce6aa4dbc4aa49.tar.bz2
Integrate opiemail with Konqueror. When now clicking on a mailto link
in Konqueror OpieMail can get asked to send a mail to the persopn
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/opiemail.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp
index 2f87e44..b153292 100644
--- a/noncore/net/mail/opiemail.cpp
+++ b/noncore/net/mail/opiemail.cpp
@@ -1,162 +1,174 @@
1 1
2#include "settingsdialog.h" 2#include "settingsdialog.h"
3#include "opiemail.h" 3#include "opiemail.h"
4#include "editaccounts.h" 4#include "editaccounts.h"
5#include "composemail.h" 5#include "composemail.h"
6#include "mailistviewitem.h" 6#include "mailistviewitem.h"
7#include "viewmail.h" 7#include "viewmail.h"
8#include "selectstore.h" 8#include "selectstore.h"
9#include "selectsmtp.h" 9#include "selectsmtp.h"
10 10
11#include <libmailwrapper/smtpwrapper.h> 11#include <libmailwrapper/smtpwrapper.h>
12#include <libmailwrapper/mailtypes.h> 12#include <libmailwrapper/mailtypes.h>
13#include <libmailwrapper/abstractmail.h> 13#include <libmailwrapper/abstractmail.h>
14/* OPIE */ 14/* OPIE */
15#include <opie2/odebug.h> 15#include <opie2/odebug.h>
16#include <qpe/resource.h> 16#include <qpe/resource.h>
17#include <qpe/qpeapplication.h> 17#include <qpe/qpeapplication.h>
18 18
19/* QT */ 19/* QT */
20 20
21/* UNIX */ 21/* UNIX */
22#include <signal.h> 22#include <signal.h>
23 23
24using namespace Opie::Core; 24using namespace Opie::Core;
25 25
26OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) 26OpieMail::OpieMail( QWidget *parent, const char *name, WFlags )
27 : MainWindow( parent, name, WStyle_ContextHelp ) 27 : MainWindow( parent, name, WStyle_ContextHelp )
28{ 28{
29 setup_signalblocking(); 29 setup_signalblocking();
30 settings = new Settings(); 30 settings = new Settings();
31 31
32 folderView->populate( settings->getAccounts() ); 32 folderView->populate( settings->getAccounts() );
33} 33}
34 34
35OpieMail::~OpieMail() 35OpieMail::~OpieMail()
36{ 36{
37 if (settings) delete settings; 37 if (settings) delete settings;
38} 38}
39 39
40void OpieMail::setup_signalblocking() 40void OpieMail::setup_signalblocking()
41{ 41{
42 /* for networking we must block SIGPIPE and Co. */ 42 /* for networking we must block SIGPIPE and Co. */
43 struct sigaction blocking_action,temp_action; 43 struct sigaction blocking_action,temp_action;
44 blocking_action.sa_handler = SIG_IGN; 44 blocking_action.sa_handler = SIG_IGN;
45 sigemptyset(&(blocking_action.sa_mask)); 45 sigemptyset(&(blocking_action.sa_mask));
46 blocking_action.sa_flags = 0; 46 blocking_action.sa_flags = 0;
47 sigaction(SIGPIPE,&blocking_action,&temp_action); 47 sigaction(SIGPIPE,&blocking_action,&temp_action);
48} 48}
49 49
50void OpieMail::appMessage(const QCString &msg, const QByteArray &data) 50void OpieMail::appMessage(const QCString &msg, const QByteArray &data)
51{ 51{
52 // copied from old mail2 52 // copied from old mail2
53 if (msg == "writeMail(QString,QString)") 53 if (msg == "writeMail(QString,QString)")
54 { 54 {
55 QDataStream stream(data,IO_ReadOnly); 55 QDataStream stream(data,IO_ReadOnly);
56 QString name, email; 56 QString name, email;
57 stream >> name >> email; 57 stream >> name >> email;
58 // removing the whitespaces at beginning and end is needed! 58 // removing the whitespaces at beginning and end is needed!
59 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace()); 59 slotwriteMail(name.stripWhiteSpace(),email.stripWhiteSpace());
60 } 60 }
61 else if (msg == "newMail()") 61 else if (msg == "newMail()")
62 { 62 {
63 slotComposeMail(); 63 slotComposeMail();
64 } 64 }
65} 65}
66 66
67/**
68 * Konqueror calls us with the mailto:name@address
69 */
70void OpieMail::setDocument(const QString& mail)
71{
72 /*
73 * It looks like a mailto address, lets try it
74 */
75 if( mail.startsWith(QString::fromLatin1("mailto:")) )
76 slotwriteMail(QString::null, mail.mid(7));
77}
78
67void OpieMail::slotwriteMail(const QString&name,const QString&email) 79void OpieMail::slotwriteMail(const QString&name,const QString&email)
68{ 80{
69 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); 81 ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp );
70 if (!email.isEmpty()) 82 if (!email.isEmpty())
71 { 83 {
72 if (!name.isEmpty()) 84 if (!name.isEmpty())
73 { 85 {
74 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">"); 86 compose.setTo("\"" + name + "\"" + " " + "<"+ email + ">");
75 } 87 }
76 else 88 else
77 { 89 {
78 compose.setTo(email); 90 compose.setTo(email);
79 } 91 }
80 } 92 }
81 compose.slotAdjustColumns(); 93 compose.slotAdjustColumns();
82 QPEApplication::execDialog( &compose ); 94 QPEApplication::execDialog( &compose );
83} 95}
84 96
85void OpieMail::slotComposeMail() 97void OpieMail::slotComposeMail()
86{ 98{
87 odebug << "Compose Mail" << oendl; 99 odebug << "Compose Mail" << oendl;
88 slotwriteMail(0l,0l); 100 slotwriteMail(0l,0l);
89} 101}
90 102
91void OpieMail::slotSendQueued() 103void OpieMail::slotSendQueued()
92{ 104{
93 odebug << "Send Queued" << oendl; 105 odebug << "Send Queued" << oendl;
94 SMTPaccount *smtp = 0; 106 SMTPaccount *smtp = 0;
95 107
96 QList<Account> list = settings->getAccounts(); 108 QList<Account> list = settings->getAccounts();
97 QList<SMTPaccount> smtpList; 109 QList<SMTPaccount> smtpList;
98 smtpList.setAutoDelete(false); 110 smtpList.setAutoDelete(false);
99 Account *it; 111 Account *it;
100 for ( it = list.first(); it; it = list.next() ) 112 for ( it = list.first(); it; it = list.next() )
101 { 113 {
102 if ( it->getType() == MAILLIB::A_SMTP ) 114 if ( it->getType() == MAILLIB::A_SMTP )
103 { 115 {
104 smtp = static_cast<SMTPaccount *>(it); 116 smtp = static_cast<SMTPaccount *>(it);
105 smtpList.append(smtp); 117 smtpList.append(smtp);
106 } 118 }
107 } 119 }
108 if (smtpList.count()==0) 120 if (smtpList.count()==0)
109 { 121 {
110 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first")); 122 QMessageBox::information(0,tr("Info"),tr("Define a smtp account first"));
111 return; 123 return;
112 } 124 }
113 if (smtpList.count()==1) 125 if (smtpList.count()==1)
114 { 126 {
115 smtp = smtpList.at(0); 127 smtp = smtpList.at(0);
116 } 128 }
117 else 129 else
118 { 130 {
119 smtp = 0; 131 smtp = 0;
120 selectsmtp selsmtp; 132 selectsmtp selsmtp;
121 selsmtp.setSelectionlist(&smtpList); 133 selsmtp.setSelectionlist(&smtpList);
122 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted ) 134 if ( QPEApplication::execDialog( &selsmtp ) == QDialog::Accepted )
123 { 135 {
124 smtp = selsmtp.selected_smtp(); 136 smtp = selsmtp.selected_smtp();
125 } 137 }
126 } 138 }
127 if (smtp) 139 if (smtp)
128 { 140 {
129 SMTPwrapper * wrap = new SMTPwrapper(smtp); 141 SMTPwrapper * wrap = new SMTPwrapper(smtp);
130 if ( wrap->flushOutbox() ) 142 if ( wrap->flushOutbox() )
131 { 143 {
132 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed")); 144 QMessageBox::information(0,tr("Info"),tr("Mail queue flushed"));
133 } 145 }
134 delete wrap; 146 delete wrap;
135 } 147 }
136} 148}
137 149
138void OpieMail::slotSearchMails() 150void OpieMail::slotSearchMails()
139{ 151{
140 odebug << "Search Mails" << oendl; 152 odebug << "Search Mails" << oendl;
141} 153}
142 154
143void OpieMail::slotEditSettings() 155void OpieMail::slotEditSettings()
144{ 156{
145 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp ); 157 SettingsDialog settingsDialog( this, 0, true, WStyle_ContextHelp );
146 QPEApplication::execDialog( &settingsDialog ); 158 QPEApplication::execDialog( &settingsDialog );
147} 159}
148 160
149void OpieMail::slotEditAccounts() 161void OpieMail::slotEditAccounts()
150{ 162{
151 odebug << "Edit Accounts" << oendl; 163 odebug << "Edit Accounts" << oendl;
152 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp ); 164 EditAccounts eaDialog( settings, this, 0, true, WStyle_ContextHelp );
153 eaDialog.slotAdjustColumns(); 165 eaDialog.slotAdjustColumns();
154 QPEApplication::execDialog( &eaDialog ); 166 QPEApplication::execDialog( &eaDialog );
155 if ( settings ) delete settings; 167 if ( settings ) delete settings;
156 settings = new Settings(); 168 settings = new Settings();
157 169
158 folderView->populate( settings->getAccounts() ); 170 folderView->populate( settings->getAccounts() );
159} 171}
160 172
161void OpieMail::displayMail() 173void OpieMail::displayMail()
162{ 174{