summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp6
-rw-r--r--korganizer/koeventviewer.cpp24
-rw-r--r--libkcal/person.cpp8
-rw-r--r--libkcal/person.h1
-rw-r--r--libkdepim/externalapphandler.cpp111
5 files changed, 125 insertions, 25 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index aae923c..5c24acf 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -119,63 +119,65 @@ void AddresseeView::setSource(const QString& n)
119 ExternalAppHandler::instance()->callBySMS( n.mid(6) ); 119 ExternalAppHandler::instance()->callBySMS( n.mid(6) );
120 else if ( n.left( 7 ) == "pagerto" ) 120 else if ( n.left( 7 ) == "pagerto" )
121 ExternalAppHandler::instance()->callByPager( n.mid(8) ); 121 ExternalAppHandler::instance()->callByPager( n.mid(8) );
122 else if ( n.left( 5 ) == "sipto" ) 122 else if ( n.left( 5 ) == "sipto" )
123 ExternalAppHandler::instance()->callBySIP( n.mid(6) ); 123 ExternalAppHandler::instance()->callBySIP( n.mid(6) );
124 124
125} 125}
126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) 126void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
127{ 127{
128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable(); 128 bool kemailAvail = ExternalAppHandler::instance()->isEmailAppAvailable();
129 // mAddressee = addr; 129 // mAddressee = addr;
130 // clear view 130 // clear view
131 //setText( QString::null ); 131 //setText( QString::null );
132 mCurrentContact = mAddressee; 132 mCurrentContact = mAddressee;
133 if ( mAddressee.isEmpty() ) { 133 if ( mAddressee.isEmpty() ) {
134 setText( QString::null); 134 setText( QString::null);
135 return; 135 return;
136 } 136 }
137#if 0 137#if 0
138 QString name = ( mAddressee.assembledName().isEmpty() ? 138 QString name = ( mAddressee.assembledName().isEmpty() ?
139 mAddressee.formattedName() : mAddressee.assembledName() ); 139 mAddressee.formattedName() : mAddressee.assembledName() );
140#endif 140#endif
141 141
142 QString name = mAddressee.realName(); 142 QString name = mAddressee.realName();
143 143 QString assName = mAddressee.assembledName();
144 if ( assName.isEmpty() )
145 assName = name;
144 QString dynamicPart; 146 QString dynamicPart;
145 147
146 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true ); 148 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(),true );
147 QStringList emails = mAddressee.emails(); 149 QStringList emails = mAddressee.emails();
148 QStringList::ConstIterator emailIt; 150 QStringList::ConstIterator emailIt;
149 QString type = i18n( "Email" ); 151 QString type = i18n( "Email" );
150 emailIt = emails.begin(); 152 emailIt = emails.begin();
151 if ( emailIt != emails.end() ) { 153 if ( emailIt != emails.end() ) {
152 if ( kemailAvail ) { 154 if ( kemailAvail ) {
153 dynamicPart += QString( 155 dynamicPart += QString(
154 "<tr><td align=\"right\"><b>%1</b></td>" 156 "<tr><td align=\"right\"><b>%1</b></td>"
155 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 157 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
156 .arg( type ) 158 .arg( type )
157 .arg( name ) 159 .arg( assName )
158 .arg( *emailIt ) 160 .arg( *emailIt )
159 .arg( *emailIt ); 161 .arg( *emailIt );
160 ++emailIt; 162 ++emailIt;
161 } else { 163 } else {
162 dynamicPart += QString( 164 dynamicPart += QString(
163 "<tr><td align=\"right\"><b>%1</b></td>" 165 "<tr><td align=\"right\"><b>%1</b></td>"
164 "<td align=\"left\">%2</td></tr>" ) 166 "<td align=\"left\">%2</td></tr>" )
165 .arg( type ) 167 .arg( type )
166 .arg( *emailIt ); 168 .arg( *emailIt );
167 ++emailIt; 169 ++emailIt;
168 } 170 }
169 } 171 }
170 if ( mAddressee.birthday().date().isValid() ) { 172 if ( mAddressee.birthday().date().isValid() ) {
171 dynamicPart += QString( 173 dynamicPart += QString(
172 "<tr><td align=\"right\"><b>%1</b></td>" 174 "<tr><td align=\"right\"><b>%1</b></td>"
173 "<td align=\"left\">%2</td></tr>" ) 175 "<td align=\"left\">%2</td></tr>" )
174 .arg( i18n ("Birthday") ) 176 .arg( i18n ("Birthday") )
175 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 177 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
176 } 178 }
177 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); 179 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false );
178 180
179 for ( ; emailIt != emails.end(); ++emailIt ) { 181 for ( ; emailIt != emails.end(); ++emailIt ) {
180 if ( kemailAvail ) { 182 if ( kemailAvail ) {
181 dynamicPart += QString( 183 dynamicPart += QString(
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index 976ee2c..02b54da 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -36,51 +36,51 @@
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <kabc/stdaddressbook.h> 38#include <kabc/stdaddressbook.h>
39 39
40#ifndef KORG_NODCOP 40#ifndef KORG_NODCOP
41#include <dcopclient.h> 41#include <dcopclient.h>
42#include "korganizer.h" 42#include "korganizer.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#include "actionmanager.h" 44#include "actionmanager.h"
45#endif 45#endif
46 46
47#include "koeventviewer.h" 47#include "koeventviewer.h"
48//#ifndef KORG_NOKABC 48//#ifndef KORG_NOKABC
49//#include <kabc/stdaddressbook.h> 49//#include <kabc/stdaddressbook.h>
50//#define size count 50//#define size count
51//#endif 51//#endif
52 52
53#ifdef DESKTOP_VERSION 53#ifdef DESKTOP_VERSION
54#include <kabc/addresseedialog.h> 54#include <kabc/addresseedialog.h>
55#include <kabc/addresseeview.h> 55#include <kabc/addresseeview.h>
56#include <qprinter.h> 56#include <qprinter.h>
57#include <qpainter.h> 57#include <qpainter.h>
58#include <qpaintdevicemetrics.h> 58#include <qpaintdevicemetrics.h>
59#else //DESKTOP_VERSION 59#else //DESKTOP_VERSION
60#include <externalapphandler.h>
61#include <qtopia/qcopenvelope_qws.h> 60#include <qtopia/qcopenvelope_qws.h>
62#endif //DESKTOP_VERSION 61#endif //DESKTOP_VERSION
62#include <externalapphandler.h>
63 63
64KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 64KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
65 : QTextBrowser(parent,name) 65 : QTextBrowser(parent,name)
66{ 66{
67 mSyncMode = false; 67 mSyncMode = false;
68 mColorMode = 0; 68 mColorMode = 0;
69} 69}
70 70
71KOEventViewer::~KOEventViewer() 71KOEventViewer::~KOEventViewer()
72{ 72{
73} 73}
74 74
75void KOEventViewer::printMe() 75void KOEventViewer::printMe()
76{ 76{
77#ifdef DESKTOP_VERSION 77#ifdef DESKTOP_VERSION
78 78
79 KOPrintPrefs pp ( this ); 79 KOPrintPrefs pp ( this );
80 if (!pp.exec() ) 80 if (!pp.exec() )
81 return; 81 return;
82 int scaleval = pp.printMode() ; 82 int scaleval = pp.printMode() ;
83 83
84 QPrinter printer; 84 QPrinter printer;
85 if (!printer.setup() ) 85 if (!printer.setup() )
86 return; 86 return;
@@ -152,58 +152,59 @@ void KOEventViewer::setSource(const QString& n)
152#else 152#else
153 { 153 {
154 if ( "uid:organizer" == n ) { 154 if ( "uid:organizer" == n ) {
155 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),""); 155 ExternalAppHandler::instance()->requestDetailsFromKAPI("", mCurrentIncidence->organizer(),"");
156 return; 156 return;
157 } 157 }
158 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 158 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
159 if (attendees.count()) { 159 if (attendees.count()) {
160 Attendee *a; 160 Attendee *a;
161 for(a=attendees.first();a;a=attendees.next()) { 161 for(a=attendees.first();a;a=attendees.next()) {
162 if ( "uid:"+a->uid() == n ) { 162 if ( "uid:"+a->uid() == n ) {
163 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid()); 163 bool res = ExternalAppHandler::instance()->requestDetailsFromKAPI(a->name(), a->email(), a->uid());
164 return; 164 return;
165 } 165 }
166 } 166 }
167 } 167 }
168 return; 168 return;
169 } 169 }
170 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 170 //requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
171 // the result should now arrive through method insertAttendees 171 // the result should now arrive through method insertAttendees
172 //QString uid = "uid:"+(*it).uid(); 172 //QString uid = "uid:"+(*it).uid();
173#endif 173#endif
174 if ( n.left(6) == "mailto" ) { 174 if ( n.left(6) == "mailto" ) {
175 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1()); 175 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
176#ifndef DESKTOP_VERSION 176 //#ifndef DESKTOP_VERSION
177 if ( n.mid(7,3) == "ALL" ) { 177 if ( n.mid(7,3) == "ALL" ) {
178 mailToAttendees( true ); 178 mailToAttendees( true );
179 } else if ( n.mid(7,4) == "RSVP" ) { 179 } else if ( n.mid(7,4) == "RSVP" ) {
180 mailToAttendees( false ); 180 mailToAttendees( false );
181 } else { 181 } else {
182 QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" ); 182 ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
183 e << n.mid(7); 183 //QCopEnvelope e("QPE/Application/ompi", "newMail(QString)" );
184 //e << n.mid(7);
184 } 185 }
185#endif 186 //#endif
186 187
187 } 188 }
188 189
189 190
190#ifndef KORG_NODCOP 191#ifndef KORG_NODCOP
191 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 192 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
192 QString tmpStr; 193 QString tmpStr;
193 if (n.startsWith("mailto:")) { 194 if (n.startsWith("mailto:")) {
194 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 195 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
195 //emit showIncidence(n); 196 //emit showIncidence(n);
196 return; 197 return;
197 } else if (n.startsWith("uid:")) { 198 } else if (n.startsWith("uid:")) {
198 DCOPClient *client = KApplication::kApplication()->dcopClient(); 199 DCOPClient *client = KApplication::kApplication()->dcopClient();
199 const QByteArray noParamData; 200 const QByteArray noParamData;
200 const QByteArray paramData; 201 const QByteArray paramData;
201 QByteArray replyData; 202 QByteArray replyData;
202 QCString replyTypeStr; 203 QCString replyTypeStr;
203#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 204#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
204 bool foundAbbrowser = PING_ABBROWSER; 205 bool foundAbbrowser = PING_ABBROWSER;
205 206
206 if (foundAbbrowser) { 207 if (foundAbbrowser) {
207 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 208 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
208 //client->send("kaddressbook","KAddressBookIface", 209 //client->send("kaddressbook","KAddressBookIface",
209 QDataStream arg(paramData, IO_WriteOnly); 210 QDataStream arg(paramData, IO_WriteOnly);
@@ -218,56 +219,63 @@ void KOEventViewer::setSource(const QString& n)
218 KIconLoader* iconLoader = new KIconLoader(); 219 KIconLoader* iconLoader = new KIconLoader();
219 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 220 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
220 ActionManager::setStartedKAddressBook(true); 221 ActionManager::setStartedKAddressBook(true);
221 tmpStr = "kaddressbook --editor-only --uid "; 222 tmpStr = "kaddressbook --editor-only --uid ";
222 tmpStr += KProcess::quote(n.mid(6)); 223 tmpStr += KProcess::quote(n.mid(6));
223 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 224 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
224 return; 225 return;
225 } 226 }
226 } else { 227 } else {
227 //QTextBrowser::setSource(n); 228 //QTextBrowser::setSource(n);
228 } 229 }
229#endif 230#endif
230} 231}
231void KOEventViewer::mailToAttendees( bool all ) 232void KOEventViewer::mailToAttendees( bool all )
232{ 233{
233 QPtrList<Attendee> attendees = mCurrentIncidence->attendees(); 234 QPtrList<Attendee> attendees = mCurrentIncidence->attendees();
234 if (attendees.count() == 0) return; 235 if (attendees.count() == 0) return;
235 QStringList nameList; 236 QStringList nameList;
236 QStringList emailList; 237 QStringList emailList;
237 QStringList uidList; 238 QStringList uidList;
238 Attendee* a; 239 Attendee* a;
239 for(a=attendees.first();a;a=attendees.next()) { 240 for(a=attendees.first();a;a=attendees.next()) {
240 if ( !all && !a->RSVP() ) continue; 241 if ( !all && !a->RSVP() ) continue;
241 if (!a->email().isEmpty()) { 242 if (!a->email().isEmpty()) {
242 nameList.append (a->name() ); 243#ifndef DESKTOP_VERSION
244 nameList.append (a->realName() );
243 emailList.append (a->email() ); 245 emailList.append (a->email() );
244 uidList.append (a->uid() ); 246 uidList.append (a->uid() );
247#else
248 emailList.append(a->realName() +" <" + a->email() +">");
249#endif
245 } 250 }
246 } 251 }
247 QString uid = "ComposeMailUIpick2"+mMailSubject;
248#ifndef DESKTOP_VERSION 252#ifndef DESKTOP_VERSION
253 QString uid = "ComposeMailUIpick2"+mMailSubject;
249 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 254 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
255
256#else
257 ExternalAppHandler::instance()->mailToMultipleContacts( emailList.join(","), mMailSubject );
250#endif 258#endif
251 259
252} 260}
253void KOEventViewer::addTag(const QString & tag,const QString & text) 261void KOEventViewer::addTag(const QString & tag,const QString & text)
254{ 262{
255 int number=text.contains("\n"); 263 int number=text.contains("\n");
256 QString str = "<" + tag + ">"; 264 QString str = "<" + tag + ">";
257 QString tmpText=text; 265 QString tmpText=text;
258 QString tmpStr=str; 266 QString tmpStr=str;
259 if(number !=-1) 267 if(number !=-1)
260 { 268 {
261 if (number > 0) { 269 if (number > 0) {
262 int pos=0; 270 int pos=0;
263 QString tmp; 271 QString tmp;
264 for(int i=0;i<=number;i++) { 272 for(int i=0;i<=number;i++) {
265 pos=tmpText.find("\n"); 273 pos=tmpText.find("\n");
266 tmp=tmpText.left(pos); 274 tmp=tmpText.left(pos);
267 tmpText=tmpText.right(tmpText.length()-pos-1); 275 tmpText=tmpText.right(tmpText.length()-pos-1);
268 tmpStr+=tmp+"<br>"; 276 tmpStr+=tmp+"<br>";
269 } 277 }
270 } 278 }
271 else tmpStr += tmpText; 279 else tmpStr += tmpText;
272 tmpStr+="</" + tag + ">"; 280 tmpStr+="</" + tag + ">";
273 mText.append(tmpStr); 281 mText.append(tmpStr);
@@ -649,49 +657,49 @@ void KOEventViewer::formatAttendees(Incidence *event)
649 } 657 }
650 } else { 658 } else {
651 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 659 mText += "<li><a href=\"uid:" + a->uid() + "\">";
652 if (!a->name().isEmpty()) mText += a->name(); 660 if (!a->name().isEmpty()) mText += a->name();
653 else mText += a->email(); 661 else mText += a->email();
654 mText += "</a>\n"; 662 mText += "</a>\n";
655 } 663 }
656#else //DESKTOP_VERSION 664#else //DESKTOP_VERSION
657 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 665 mText += "<li><a href=\"uid:" + a->uid() + "\">";
658 if (!a->name().isEmpty()) mText += a->name(); 666 if (!a->name().isEmpty()) mText += a->name();
659 else mText += a->email(); 667 else mText += a->email();
660 mText += "</a>\n"; 668 mText += "</a>\n";
661#endif //DESKTOP_VERSION 669#endif //DESKTOP_VERSION
662#else 670#else
663 //qDebug("nokabc "); 671 //qDebug("nokabc ");
664 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 672 mText += "<li><a href=\"uid:" + a->uid() + "\">";
665 if (!a->name().isEmpty()) mText += a->name(); 673 if (!a->name().isEmpty()) mText += a->name();
666 else mText += a->email(); 674 else mText += a->email();
667 mText += "</a>\n"; 675 mText += "</a>\n";
668#endif 676#endif
669 677
670 678
671 if (!a->email().isEmpty()) { 679 if (!a->email().isEmpty()) {
672 if (iconPath) { 680 if (iconPath) {
673 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">"; 681 mText += "<a href=\"mailto:" + a->realName() +" <" + a->email() + ">:" + mMailSubject + "\">";
674 if ( a->RSVP() ) { 682 if ( a->RSVP() ) {
675 ++a_count_nr; 683 ++a_count_nr;
676 mText += "<IMG src=\"" + iconPath + "\">"; 684 mText += "<IMG src=\"" + iconPath + "\">";
677 } 685 }
678 else { 686 else {
679 ++a_count; 687 ++a_count;
680 mText += "<IMG src=\"" + NOiconPath + "\">"; 688 mText += "<IMG src=\"" + NOiconPath + "\">";
681 } 689 }
682 mText += "</a>\n"; 690 mText += "</a>\n";
683 } 691 }
684 } 692 }
685 if (a->status() != Attendee::NeedsAction ) 693 if (a->status() != Attendee::NeedsAction )
686 mText +="[" + a->statusStr() + "] "; 694 mText +="[" + a->statusStr() + "] ";
687 if (a->role() == Attendee::Chair ) 695 if (a->role() == Attendee::Chair )
688 mText +="(" + a->roleStr().left(1) + ".)"; 696 mText +="(" + a->roleStr().left(1) + ".)";
689 } 697 }
690 mText.append("</li></ul>"); 698 mText.append("</li></ul>");
691 if ( (a_count+a_count_nr) > 1 ) { 699 if ( (a_count+a_count_nr) > 1 ) {
692 mText += "<a href=\"mailto:ALL\">"; 700 mText += "<a href=\"mailto:ALL\">";
693 mText += i18n( "Mail to all" ); 701 mText += i18n( "Mail to all" );
694 mText += "</a> ( "; 702 mText += "</a> ( ";
695 mText += "<IMG src=\"" + iconPath + "\">"; 703 mText += "<IMG src=\"" + iconPath + "\">";
696 mText += i18n( " and " ); 704 mText += i18n( " and " );
697 mText += "<IMG src=\"" + NOiconPath + "\"> )"; 705 mText += "<IMG src=\"" + NOiconPath + "\"> )";
diff --git a/libkcal/person.cpp b/libkcal/person.cpp
index aca28c2..858805d 100644
--- a/libkcal/person.cpp
+++ b/libkcal/person.cpp
@@ -28,49 +28,55 @@ using namespace KCal;
28Person::Person( const QString &fullName ) 28Person::Person( const QString &fullName )
29{ 29{
30 int emailPos = fullName.find( '<' ); 30 int emailPos = fullName.find( '<' );
31 if ( emailPos < 0 ) { 31 if ( emailPos < 0 ) {
32 setEmail(fullName); 32 setEmail(fullName);
33 } else { 33 } else {
34 setEmail(fullName.mid( emailPos + 1, fullName.length() - 1 )); 34 setEmail(fullName.mid( emailPos + 1, fullName.length() - 1 ));
35 setName(fullName.left( emailPos - 2 )); 35 setName(fullName.left( emailPos - 2 ));
36 } 36 }
37} 37}
38 38
39Person::Person( const QString &name, const QString &email ) 39Person::Person( const QString &name, const QString &email )
40{ 40{
41 setName(name); 41 setName(name);
42 setEmail(email); 42 setEmail(email);
43} 43}
44 44
45 45
46bool KCal::operator==( const Person& p1, const Person& p2 ) 46bool KCal::operator==( const Person& p1, const Person& p2 )
47{ 47{
48 return ( p1.name() == p2.name() && 48 return ( p1.name() == p2.name() &&
49 p1.email() == p2.email() ); 49 p1.email() == p2.email() );
50} 50}
51 51
52 52QString Person::realName() const
53{
54 int ccc = mName.find (',');
55 if ( ccc < 0 )
56 return mName;
57 return mName.mid( ccc+1 ).stripWhiteSpace() + " " + mName.left( ccc ).stripWhiteSpace();
58}
53QString Person::fullName() const 59QString Person::fullName() const
54{ 60{
55 if( mName.isEmpty() ) { 61 if( mName.isEmpty() ) {
56 return mEmail; 62 return mEmail;
57 } else { 63 } else {
58 if( mEmail.isEmpty() ) 64 if( mEmail.isEmpty() )
59 return mName; 65 return mName;
60 else 66 else
61 return mName + " <" + mEmail + ">"; 67 return mName + " <" + mEmail + ">";
62 } 68 }
63} 69}
64 70
65void Person::setName(const QString &name) 71void Person::setName(const QString &name)
66{ 72{
67 mName = name; 73 mName = name;
68} 74}
69 75
70void Person::setEmail(const QString &email) 76void Person::setEmail(const QString &email)
71{ 77{
72 if (email.left(7).lower() == "mailto:") { 78 if (email.left(7).lower() == "mailto:") {
73 mEmail = email.mid(7); 79 mEmail = email.mid(7);
74 } else { 80 } else {
75 mEmail = email; 81 mEmail = email;
76 } 82 }
diff --git a/libkcal/person.h b/libkcal/person.h
index c46c5f0..3cec153 100644
--- a/libkcal/person.h
+++ b/libkcal/person.h
@@ -14,37 +14,38 @@
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_PERSON_H 20#ifndef KCAL_PERSON_H
21#define KCAL_PERSON_H 21#define KCAL_PERSON_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24 24
25namespace KCal { 25namespace KCal {
26 26
27class Person 27class Person
28{ 28{
29 public: 29 public:
30 Person() {} 30 Person() {}
31 Person( const QString &fullName ); 31 Person( const QString &fullName );
32 Person( const QString &name, const QString &email ); 32 Person( const QString &name, const QString &email );
33 33
34 QString fullName( ) const; 34 QString fullName( ) const;
35 35
36 void setName(const QString &); 36 void setName(const QString &);
37 QString name() const { return mName; } 37 QString name() const { return mName; }
38 QString realName() const;
38 39
39 void setEmail(const QString &); 40 void setEmail(const QString &);
40 QString email() const { return mEmail; } 41 QString email() const { return mEmail; }
41 42
42 private: 43 private:
43 QString mName; 44 QString mName;
44 QString mEmail; 45 QString mEmail;
45}; 46};
46 47
47 bool operator==( const Person& p1, const Person& p2 ); 48 bool operator==( const Person& p1, const Person& p2 );
48} 49}
49 50
50#endif 51#endif
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 2ce6926..edefda4 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -18,48 +18,49 @@
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30#include <stdlib.h> 30#include <stdlib.h>
31 31
32#include <qfile.h> 32#include <qfile.h>
33#include <qtimer.h> 33#include <qtimer.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qregexp.h> 35#include <qregexp.h>
36 36
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
39#include <qtopia/qcopenvelope_qws.h> 39#include <qtopia/qcopenvelope_qws.h>
40#else 40#else
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qprocess.h>
42#endif 43#endif
43 44
44#include <kstaticdeleter.h> 45#include <kstaticdeleter.h>
45#include <kmessagebox.h> 46#include <kmessagebox.h>
46 47
47 48
48#include "externalapphandler.h" 49#include "externalapphandler.h"
49 50
50#include "kpimglobalprefs.h" 51#include "kpimglobalprefs.h"
51 52
52//uncomment line to get debug output 53//uncomment line to get debug output
53//#define DEBUG_EXT_APP_HANDLER 54//#define DEBUG_EXT_APP_HANDLER
54 55
55/********************************************************************************* 56/*********************************************************************************
56 * 57 *
57 ********************************************************************************/ 58 ********************************************************************************/
58 59
59 60
60QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) 61QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
61 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage) 62 : _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
62{ 63{
63 //sourceMessage passes later three parameters: sourceChannel, uid, param1 64 //sourceMessage passes later three parameters: sourceChannel, uid, param1
64 if (_usedSourceParameters == 0) 65 if (_usedSourceParameters == 0)
65 _sourceMessageParameters = "QString,QString)"; 66 _sourceMessageParameters = "QString,QString)";
@@ -413,63 +414,82 @@ void ExternalAppHandler::loadConfig()
413 414
414 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); 415 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
415 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); 416 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
416 QString qtpath = QString::fromLatin1( getenv("QTDIR") ); 417 QString qtpath = QString::fromLatin1( getenv("QTDIR") );
417 418
418 //if qtopiapath is not set, fallback to qt 419 //if qtopiapath is not set, fallback to qt
419 if (qtopiapath.isEmpty()) 420 if (qtopiapath.isEmpty())
420 qtopiapath = qtpath; 421 qtopiapath = qtpath;
421 422
422 //if opiepath is not set, fallback to qtopia 423 //if opiepath is not set, fallback to qtopia
423 if (opiepath.isEmpty()) 424 if (opiepath.isEmpty())
424 opiepath = qtopiapath; 425 opiepath = qtopiapath;
425 426
426 427
427 428
428 //mailclients 429 //mailclients
429 QString mailmsg1 = "writeMail(QString,QString)"; 430 QString mailmsg1 = "writeMail(QString,QString)";
430 QString mailmsg2 = "writeMail(QMap(QString,QString))"; 431 QString mailmsg2 = "writeMail(QMap(QString,QString))";
431 432
432 QString undefined = ""; 433 QString undefined = "";
433 434
434 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); 435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined);
435 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); 436 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined);
436 437
438#ifdef DESKTOP_VERSION
439 QString appPath;
440#ifdef _WIN32_
441 appPath = "C:\\Programme\\Mozilla Thunderbird\\thunderbird.exe";
442#else
443 appPath = "/usr/bin/thunderbird";
444#endif
445 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "Mozilla Thunderbird", appPath, "-compose", "to=%1 <%2>", ",", "subject=%1");
446
447#ifdef _WIN32_
448 appPath = "C:\\Programme\\Mozilla\\mozilla.exe";
449#else
450 appPath = "/usr/bin/mozilla";
451#endif
452 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Mozilla Suite", appPath, "-mail -compose", "to=%1 <%2>", ",", "subject=%1");
453
454
455
456#else
437 if (( QFile::exists( qtopiapath + "/bin/ompi" )) || 457 if (( QFile::exists( qtopiapath + "/bin/ompi" )) ||
438 ( QFile::exists( opiepath + "/bin/ompi" )) || 458 ( QFile::exists( opiepath + "/bin/ompi" )) ||
439 ( QFile::exists( qtpath + "/bin/ompi" ))) 459 ( QFile::exists( qtpath + "/bin/ompi" )))
440 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 460 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
441 461
442 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) || 462 if (( QFile::exists( qtopiapath + "/bin/qtmail" )) ||
443 ( QFile::exists( qtpath + "/bin/qtmail" ))) 463 ( QFile::exists( qtpath + "/bin/qtmail" )))
444 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 464 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
445 465
446 if ( QFile::exists( opiepath + "/bin/opiemail" )) 466 if ( QFile::exists( opiepath + "/bin/opiemail" ))
447 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 467 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
448 468
449 if ( QFile::exists( opiepath + "/bin/mailit" )) 469 if ( QFile::exists( opiepath + "/bin/mailit" ))
450 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); 470 addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_MAILIT_EMC, "Opie mailit email client", "QPE/Application/mailit", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2");
451 471#endif
452 472
453 473
454 //phoneclients 474 //phoneclients
455 475
456 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined); 476 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
457 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined); 477 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
458 if (( QFile::exists( qtopiapath + "/bin/kppi" )) || 478 if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
459 ( QFile::exists( opiepath + "/bin/kppi" ))) 479 ( QFile::exists( opiepath + "/bin/kppi" )))
460 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined); 480 addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
461 481
462 //faxclients 482 //faxclients
463 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined); 483 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
464 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined); 484 addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
465 485
466 //smsclients 486 //smsclients
467 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined); 487 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
468 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined); 488 addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
469 489
470 //pagerclients 490 //pagerclients
471 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined); 491 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
472 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined); 492 addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, undefined, undefined);
473 493
474 //sipclients 494 //sipclients
475 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined); 495 addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No SIP client installed", undefined, undefined, undefined, undefined, undefined);
@@ -507,62 +527,59 @@ QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
507 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 527 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
508 { 528 {
509 if (dai->_type == type) 529 if (dai->_type == type)
510 list.append(dai); 530 list.append(dai);
511 } 531 }
512 532
513 return list; 533 return list;
514} 534}
515 535
516DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid) 536DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
517{ 537{
518 DefaultAppItem* dai; 538 DefaultAppItem* dai;
519 539
520 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() ) 540 for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
521 { 541 {
522 if (dai->_type == type && dai->_id == clientid) 542 if (dai->_type == type && dai->_id == clientid)
523 return dai; 543 return dai;
524 } 544 }
525 545
526 return 0; 546 return 0;
527} 547}
528 548
529bool ExternalAppHandler::isEmailAppAvailable() 549bool ExternalAppHandler::isEmailAppAvailable()
530{ 550{
531#ifndef DESKTOP_VERSION 551
532 if (mEmailAppAvailable == UNDEFINED) 552 if (mEmailAppAvailable == UNDEFINED)
533 { 553 {
534 int client = KPimGlobalPrefs::instance()->mEmailClient; 554 int client = KPimGlobalPrefs::instance()->mEmailClient;
535 if (client == KPimGlobalPrefs::NONE_EMC) 555 if (client == KPimGlobalPrefs::NONE_EMC)
536 mEmailAppAvailable = UNAVAILABLE; 556 mEmailAppAvailable = UNAVAILABLE;
537 else 557 else
538 mEmailAppAvailable = AVAILABLE; 558 mEmailAppAvailable = AVAILABLE;
539 } 559 }
540 return (mEmailAppAvailable == AVAILABLE); 560 return (mEmailAppAvailable == AVAILABLE);
541 561
542#else //DESKTOP_VERSION
543 return false;
544#endif //DESKTOP_VERSION
545} 562}
546 563
547bool ExternalAppHandler::isSMSAppAvailable() 564bool ExternalAppHandler::isSMSAppAvailable()
548{ 565{
549#ifndef DESKTOP_VERSION 566#ifndef DESKTOP_VERSION
550 if (mSMSAppAvailable == UNDEFINED) 567 if (mSMSAppAvailable == UNDEFINED)
551 { 568 {
552 int client = KPimGlobalPrefs::instance()->mSMSClient; 569 int client = KPimGlobalPrefs::instance()->mSMSClient;
553 if (client == KPimGlobalPrefs::NONE_SMC) 570 if (client == KPimGlobalPrefs::NONE_SMC)
554 mSMSAppAvailable = UNAVAILABLE; 571 mSMSAppAvailable = UNAVAILABLE;
555 else 572 else
556 mSMSAppAvailable = AVAILABLE; 573 mSMSAppAvailable = AVAILABLE;
557 } 574 }
558 575
559 return (mSMSAppAvailable == AVAILABLE); 576 return (mSMSAppAvailable == AVAILABLE);
560#else //DESKTOP_VERSION 577#else //DESKTOP_VERSION
561 return false; 578 return false;
562#endif //DESKTOP_VERSION 579#endif //DESKTOP_VERSION
563} 580}
564 581
565bool ExternalAppHandler::isPhoneAppAvailable() 582bool ExternalAppHandler::isPhoneAppAvailable()
566{ 583{
567#ifndef DESKTOP_VERSION 584#ifndef DESKTOP_VERSION
568 if (mPhoneAppAvailable == UNDEFINED) 585 if (mPhoneAppAvailable == UNDEFINED)
@@ -667,109 +684,175 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS
667 } 684 }
668 channel = dai->_channel; 685 channel = dai->_channel;
669 message2 = dai->_message2; 686 message2 = dai->_message2;
670 parameters2 = dai->_parameters2; 687 parameters2 = dai->_parameters2;
671 } 688 }
672 689
673 //first check if one of the mailers need the emails right in the message. 690 //first check if one of the mailers need the emails right in the message.
674 message2 = translateMessage(message2, emails, urls); 691 message2 = translateMessage(message2, emails, urls);
675 692
676 693
677#ifdef DEBUG_EXT_APP_HANDLER 694#ifdef DEBUG_EXT_APP_HANDLER
678 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1()); 695 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
679 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1()); 696 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
680#endif 697#endif
681 698
682 699
683 QCopEnvelope e(channel.latin1(), message2.latin1()); 700 QCopEnvelope e(channel.latin1(), message2.latin1());
684 //US we need no names in the To field. The emailadresses are enough 701 //US we need no names in the To field. The emailadresses are enough
685 702
686 passParameters(&e, parameters2, emails, urls); 703 passParameters(&e, parameters2, emails, urls);
687 704
688 705
689 706
690#else 707#else
691 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 708 //qDebug("mtmc %s %s ", emails.latin1(), urls.latin1());
709
710 QString channel;
711 QString message2;
712 QString parameters2;
713 QString message;
714 QString parameters;
715
716
717 int client = KPimGlobalPrefs::instance()->mEmailClient;
718 if (client == KPimGlobalPrefs::OTHER_EMC)
719 {
720 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
721 message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
722 parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
723 }
724 else
725 {
726 DefaultAppItem* dai = getDefaultItem(EMAIL, client);
727 if (!dai)
728 {
729 qDebug("could not find configured email application.");
730 return false;
731 }
732 channel = dai->_channel;
733 message2 = dai->_message2;
734 parameters2 = dai->_parameters2;
735 message = dai->_message;
736 parameters = dai->_parameters;
737 }
738
739 //first check if one of the mailers need the emails right in the message.
740 message2 = translateMessage(message2, emails, urls);
741#ifdef DEBUG_EXT_APP_HANDLER
742 qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
743 qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
744#endif
745 qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
746 //KMessageBox::sorry( 0, message2 );
747 QProcess * proc = new QProcess( this );
748 QStringList list = QStringList::split( " ", message );
749 int i = 0;
750 proc->addArgument( channel );
751 while ( i < list.count ( ) ) {
752 //qDebug("add%sdd ",list[i].stripWhiteSpace().latin1() );
753 proc->addArgument( list[i].stripWhiteSpace() );
754 ++i;
755 }
756 parameters2 = translateMessage(parameters2, urls, "" );
757 QString arg = "to='%1'";
758 arg = arg.arg( emails ) + ","+parameters2;;
759
760 //qDebug("2add%sdd ",arg.latin1() );
761 proc->addArgument( arg);
762 proc->launch("");
692#endif 763#endif
693 764
694 return true; 765 return true;
695} 766}
696 767
697/************************************************************************** 768/**************************************************************************
698 * 769 *
699 **************************************************************************/ 770 **************************************************************************/
700 771
701 772
702//calls the emailapplication and creates a mail with parameter emails as recipients 773//calls the emailapplication and creates a mail with parameter emails as recipients
703bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress ) 774bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
704{ 775{
705#ifndef DESKTOP_VERSION 776
706 QString channel; 777 QString channel;
707 QString message; 778 QString message;
708 QString parameters; 779 QString parameters;
709 780
710 781
711 int client = KPimGlobalPrefs::instance()->mEmailClient; 782 int client = KPimGlobalPrefs::instance()->mEmailClient;
712 if (client == KPimGlobalPrefs::OTHER_EMC) 783 if (client == KPimGlobalPrefs::OTHER_EMC)
713 { 784 {
714 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel; 785 channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
715 message = KPimGlobalPrefs::instance()->mEmailOtherMessage; 786 message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
716 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters; 787 parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
717 } 788 }
718 else 789 else
719 { 790 {
720 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client); 791 DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
721 if (!dai) 792 if (!dai)
722 { 793 {
723 qDebug("could not find configured email application."); 794 qDebug("could not find configured email application.");
724 return false; 795 return false;
725 } 796 }
726 channel = dai->_channel; 797 channel = dai->_channel;
727 message = dai->_message; 798 message = dai->_message;
728 parameters = dai->_parameters; 799 parameters = dai->_parameters;
729 } 800 }
730 801
731 802#ifdef DESKTOP_VERSION
803 //message = channel + " " +message + " \""+ parameters + "\"";
804#endif
732 //first check if one of the mailers need the emails right in the message. 805 //first check if one of the mailers need the emails right in the message.
733 message = translateMessage(message, name, emailadress); 806 message = translateMessage(message, name, emailadress);
734 807
735
736#ifdef DEBUG_EXT_APP_HANDLER 808#ifdef DEBUG_EXT_APP_HANDLER
737 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1()); 809 qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
738 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1()); 810 qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
739#endif 811#endif
740 812
813#ifndef DESKTOP_VERSION
741 QCopEnvelope e(channel.latin1(), message.latin1()); 814 QCopEnvelope e(channel.latin1(), message.latin1());
742 //US we need no names in the To field. The emailadresses are enough 815 //US we need no names in the To field. The emailadresses are enough
743 816
744 passParameters(&e, parameters, name, emailadress); 817 passParameters(&e, parameters, name, emailadress);
745 818#else // DESKTOP_VERSION
746 819
747#else 820 //KMessageBox::sorry( 0, message );
748 KMessageBox::sorry( 0, i18n( "This version does not support the sending of emails." ) ); 821 QProcess * proc = new QProcess( this );
822 QStringList list = QStringList::split( " ", message );
823 int i = 0;
824 proc->addArgument( channel );
825 while ( i < list.count ( ) ) {
826 //qDebug("add%sdd ",list[i].latin1() );
827 proc->addArgument( list[i] );
828 ++i;
829 }
830 parameters = translateMessage(parameters, name, emailadress);
831 proc->addArgument( parameters );
832 proc->launch("");
749#endif 833#endif
750 834
751
752 return true; 835 return true;
753} 836}
754 837
755/************************************************************************** 838/**************************************************************************
756 * 839 *
757 **************************************************************************/ 840 **************************************************************************/
758 841
759//calls the emailapplication and creates a mail with parameter as recipients 842//calls the emailapplication and creates a mail with parameter as recipients
760// parameters format is 843// parameters format is
761// NAME <EMAIL>:SUBJECT 844// NAME <EMAIL>:SUBJECT
762bool ExternalAppHandler::mailToOneContact( const QString& adressline ) 845bool ExternalAppHandler::mailToOneContact( const QString& adressline )
763{ 846{
764 QString line = adressline; 847 QString line = adressline;
765 848
766 int first = line.find( "<"); 849 int first = line.find( "<");
767 int last = line.find( ">"); 850 int last = line.find( ">");
768 QString name = line.left(first); 851 QString name = line.left(first);
769 QString emailadress = line.mid(first+1, last-first-1); 852 QString emailadress = line.mid(first+1, last-first-1);
770 853
771 //Subject can not be handled right now. 854 //Subject can not be handled right now.
772 return mailToOneContact( name, emailadress ); 855 return mailToOneContact( name, emailadress );
773 856
774} 857}
775 858