-rw-r--r-- | kmicromail/libmailwrapper/genericwrapper.cpp | 18 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 2 |
2 files changed, 2 insertions, 18 deletions
diff --git a/kmicromail/libmailwrapper/genericwrapper.cpp b/kmicromail/libmailwrapper/genericwrapper.cpp index 09a6447..e691082 100644 --- a/kmicromail/libmailwrapper/genericwrapper.cpp +++ b/kmicromail/libmailwrapper/genericwrapper.cpp | |||
@@ -1,146 +1,128 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | #include "genericwrapper.h" | 2 | #include "genericwrapper.h" |
3 | #include <libetpan/libetpan.h> | 3 | #include <libetpan/libetpan.h> |
4 | #include "mailtypes.h" | 4 | #include "mailtypes.h" |
5 | 5 | ||
6 | #include <kconfig.h> | 6 | #include <kconfig.h> |
7 | #include <kglobal.h> | 7 | #include <kglobal.h> |
8 | #include <kstandarddirs.h> | 8 | #include <kstandarddirs.h> |
9 | 9 | ||
10 | 10 | ||
11 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
12 | Genericwrapper::Genericwrapper() | 12 | Genericwrapper::Genericwrapper() |
13 | : AbstractMail() | 13 | : AbstractMail() |
14 | { | 14 | { |
15 | bodyCache.clear(); | 15 | bodyCache.clear(); |
16 | m_storage = 0; | 16 | m_storage = 0; |
17 | m_folder = 0; | 17 | m_folder = 0; |
18 | } | 18 | } |
19 | 19 | ||
20 | Genericwrapper::~Genericwrapper() | 20 | Genericwrapper::~Genericwrapper() |
21 | { | 21 | { |
22 | if (m_folder) { | 22 | if (m_folder) { |
23 | mailfolder_free(m_folder); | 23 | mailfolder_free(m_folder); |
24 | } | 24 | } |
25 | if (m_storage) { | 25 | if (m_storage) { |
26 | mailstorage_free(m_storage); | 26 | mailstorage_free(m_storage); |
27 | } | 27 | } |
28 | cleanMimeCache(); | 28 | cleanMimeCache(); |
29 | } | 29 | } |
30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) | 30 | const QDateTime Genericwrapper::parseDateTime( mailimf_date_time *date ) |
31 | { | 31 | { |
32 | static bool init = false ; | ||
33 | if ( ! init ) { | ||
34 | KConfig kon ( locateLocal( "config", "korganizerrc" ) ); | ||
35 | kon.setGroup("Locale"); | ||
36 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)kon.readNumEntry( "PreferredDate",0) ); | ||
37 | QString dummy = kon.readEntry( "UserDateFormatShort","%aK %d.%m.%y" );// kon.readEntry( ""); | ||
38 | KGlobal::locale()->setHore24Format( !kon.readNumEntry( "PreferredTime",0 ) ); | ||
39 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | ||
40 | dummy = kon.readEntry( "UserDateFormatLong","%A %d %b %y" ); | ||
41 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | ||
42 | kon.setGroup("Time & Date"); | ||
43 | KGlobal::locale()->setDaylightSaving( kon.readBoolEntry( "UseDaylightsaving", true ), | ||
44 | kon.readNumEntry( "DaylightsavingStart", 90), | ||
45 | kon.readNumEntry( "DaylightsavingEnd",304) ); | ||
46 | KGlobal::locale()->setTimezone( kon.readEntry( "TimeZoneName" ," 00:00 Europe/London(UTC)") ); | ||
47 | |||
48 | init = true; | ||
49 | 32 | ||
50 | } | ||
51 | QDate da (date->dt_year,date->dt_month, date->dt_day ); | 33 | QDate da (date->dt_year,date->dt_month, date->dt_day ); |
52 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); | 34 | QTime ti ( date->dt_hour, date->dt_min, date->dt_sec ); |
53 | QDateTime dt ( da ,ti ); | 35 | QDateTime dt ( da ,ti ); |
54 | int addsec = -date->dt_zone*36; | 36 | int addsec = -date->dt_zone*36; |
55 | //qDebug("adsec1 %d ",addsec ); | 37 | //qDebug("adsec1 %d ",addsec ); |
56 | dt = dt.addSecs( addsec ); | 38 | dt = dt.addSecs( addsec ); |
57 | int off = KGlobal::locale()->localTimeOffset( dt ); | 39 | int off = KGlobal::locale()->localTimeOffset( dt ); |
58 | //qDebug("adsec2 %d ",off*60 ); | 40 | //qDebug("adsec2 %d ",off*60 ); |
59 | 41 | ||
60 | dt = dt.addSecs( off*60 ); | 42 | dt = dt.addSecs( off*60 ); |
61 | return dt; | 43 | return dt; |
62 | #if 0 | 44 | #if 0 |
63 | QString ret; | 45 | QString ret; |
64 | if ( dt.date() == QDate::currentDate () ) | 46 | if ( dt.date() == QDate::currentDate () ) |
65 | ret = KGlobal::locale()->formatTime( dt.time(),true); | 47 | ret = KGlobal::locale()->formatTime( dt.time(),true); |
66 | 48 | ||
67 | else { | 49 | else { |
68 | ret = KGlobal::locale()->formatDateTime( dt,true,true); | 50 | ret = KGlobal::locale()->formatDateTime( dt,true,true); |
69 | } | 51 | } |
70 | #endif | 52 | #endif |
71 | #if 0 | 53 | #if 0 |
72 | if ( off < 0 ) | 54 | if ( off < 0 ) |
73 | ret += " -"; | 55 | ret += " -"; |
74 | else | 56 | else |
75 | ret += " +"; | 57 | ret += " +"; |
76 | ret += QString::number( off / 60 ); | 58 | ret += QString::number( off / 60 ); |
77 | ret += "h"; | 59 | ret += "h"; |
78 | #endif | 60 | #endif |
79 | #if 0 | 61 | #if 0 |
80 | char tmp[23]; | 62 | char tmp[23]; |
81 | 63 | ||
82 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", | 64 | // snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i", |
83 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 65 | // date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
84 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", | 66 | snprintf( tmp, 23, "%04i-%02i-%02i %02i:%02i:%02i %+05i", |
85 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); | 67 | date->dt_year,date->dt_month, date->dt_day, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone ); |
86 | 68 | ||
87 | 69 | ||
88 | return QString( tmp ); | 70 | return QString( tmp ); |
89 | #endif | 71 | #endif |
90 | //return ret; | 72 | //return ret; |
91 | } | 73 | } |
92 | 74 | ||
93 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) | 75 | void Genericwrapper::fillSingleBody(RecPartP&target,mailmessage*,mailmime*mime) |
94 | { | 76 | { |
95 | if (!mime) { | 77 | if (!mime) { |
96 | return; | 78 | return; |
97 | } | 79 | } |
98 | mailmime_field*field = 0; | 80 | mailmime_field*field = 0; |
99 | mailmime_single_fields fields; | 81 | mailmime_single_fields fields; |
100 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); | 82 | memset(&fields, 0, sizeof(struct mailmime_single_fields)); |
101 | if (mime->mm_mime_fields != NULL) { | 83 | if (mime->mm_mime_fields != NULL) { |
102 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, | 84 | mailmime_single_fields_init(&fields, mime->mm_mime_fields, |
103 | mime->mm_content_type); | 85 | mime->mm_content_type); |
104 | } | 86 | } |
105 | 87 | ||
106 | mailmime_content*type = fields.fld_content; | 88 | mailmime_content*type = fields.fld_content; |
107 | clistcell*current; | 89 | clistcell*current; |
108 | if (!type) { | 90 | if (!type) { |
109 | target->setType("text"); | 91 | target->setType("text"); |
110 | target->setSubtype("plain"); | 92 | target->setSubtype("plain"); |
111 | } else { | 93 | } else { |
112 | target->setSubtype(type->ct_subtype); | 94 | target->setSubtype(type->ct_subtype); |
113 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { | 95 | switch(type->ct_type->tp_data.tp_discrete_type->dt_type) { |
114 | case MAILMIME_DISCRETE_TYPE_TEXT: | 96 | case MAILMIME_DISCRETE_TYPE_TEXT: |
115 | target->setType("text"); | 97 | target->setType("text"); |
116 | break; | 98 | break; |
117 | case MAILMIME_DISCRETE_TYPE_IMAGE: | 99 | case MAILMIME_DISCRETE_TYPE_IMAGE: |
118 | target->setType("image"); | 100 | target->setType("image"); |
119 | break; | 101 | break; |
120 | case MAILMIME_DISCRETE_TYPE_AUDIO: | 102 | case MAILMIME_DISCRETE_TYPE_AUDIO: |
121 | target->setType("audio"); | 103 | target->setType("audio"); |
122 | break; | 104 | break; |
123 | case MAILMIME_DISCRETE_TYPE_VIDEO: | 105 | case MAILMIME_DISCRETE_TYPE_VIDEO: |
124 | target->setType("video"); | 106 | target->setType("video"); |
125 | break; | 107 | break; |
126 | case MAILMIME_DISCRETE_TYPE_APPLICATION: | 108 | case MAILMIME_DISCRETE_TYPE_APPLICATION: |
127 | target->setType("application"); | 109 | target->setType("application"); |
128 | break; | 110 | break; |
129 | case MAILMIME_DISCRETE_TYPE_EXTENSION: | 111 | case MAILMIME_DISCRETE_TYPE_EXTENSION: |
130 | default: | 112 | default: |
131 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { | 113 | if (type->ct_type->tp_data.tp_discrete_type->dt_extension) { |
132 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); | 114 | target->setType(type->ct_type->tp_data.tp_discrete_type->dt_extension); |
133 | } | 115 | } |
134 | break; | 116 | break; |
135 | } | 117 | } |
136 | if (type->ct_parameters) { | 118 | if (type->ct_parameters) { |
137 | fillParameters(target,type->ct_parameters); | 119 | fillParameters(target,type->ct_parameters); |
138 | } | 120 | } |
139 | } | 121 | } |
140 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { | 122 | if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) { |
141 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { | 123 | for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) { |
142 | field = (mailmime_field*)current->data; | 124 | field = (mailmime_field*)current->data; |
143 | switch(field->fld_type) { | 125 | switch(field->fld_type) { |
144 | case MAILMIME_FIELD_TRANSFER_ENCODING: | 126 | case MAILMIME_FIELD_TRANSFER_ENCODING: |
145 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); | 127 | target->setEncoding(getencoding(field->fld_data.fld_encoding)); |
146 | break; | 128 | break; |
diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index 9a1a750..164988c 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp | |||
@@ -1,130 +1,132 @@ | |||
1 | // CHANGED 2004-09-31 Lutz Rogowski | 1 | // CHANGED 2004-09-31 Lutz Rogowski |
2 | // CHANGED 2004-08-06 Lutz Rogowski | 2 | // CHANGED 2004-08-06 Lutz Rogowski |
3 | 3 | ||
4 | #include "settingsdialog.h" | 4 | #include "settingsdialog.h" |
5 | #include "opiemail.h" | 5 | #include "opiemail.h" |
6 | #include "editaccounts.h" | 6 | #include "editaccounts.h" |
7 | #include "composemail.h" | 7 | #include "composemail.h" |
8 | #include "mailistviewitem.h" | 8 | #include "mailistviewitem.h" |
9 | #include "viewmail.h" | 9 | #include "viewmail.h" |
10 | #include "selectstore.h" | 10 | #include "selectstore.h" |
11 | #include "selectsmtp.h" | 11 | #include "selectsmtp.h" |
12 | #include "accountitem.h" | 12 | #include "accountitem.h" |
13 | #include "koprefsdialog.h" | 13 | #include "koprefsdialog.h" |
14 | 14 | ||
15 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
16 | #include <qtimer.h> | 16 | #include <qtimer.h> |
17 | #include <libkdepim/externalapphandler.h> | 17 | #include <libkdepim/externalapphandler.h> |
18 | #include <libkdepim/kpimglobalprefs.h> | ||
18 | 19 | ||
19 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
20 | #include <libmailwrapper/smtpwrapper.h> | 21 | #include <libmailwrapper/smtpwrapper.h> |
21 | #include <libmailwrapper/mailtypes.h> | 22 | #include <libmailwrapper/mailtypes.h> |
22 | #include <libmailwrapper/abstractmail.h> | 23 | #include <libmailwrapper/abstractmail.h> |
23 | /* OPIE */ | 24 | /* OPIE */ |
24 | //#include <qpe/resource.h> | 25 | //#include <qpe/resource.h> |
25 | //#include <qpe/qpeapplication.h> | 26 | //#include <qpe/qpeapplication.h> |
26 | 27 | ||
27 | /* QT */ | 28 | /* QT */ |
28 | 29 | ||
29 | //using namespace Opie::Core; | 30 | //using namespace Opie::Core; |
30 | 31 | ||
31 | OpieMail::OpieMail( QWidget *parent, const char *name ) | 32 | OpieMail::OpieMail( QWidget *parent, const char *name ) |
32 | : MainWindow( parent, name) //, WStyle_ContextHelp ) | 33 | : MainWindow( parent, name) //, WStyle_ContextHelp ) |
33 | { | 34 | { |
34 | settings = new Settings(); | 35 | settings = new Settings(); |
36 | KPimGlobalPrefs::instance()->setGlobalConfig(); | ||
35 | 37 | ||
36 | folderView->populate( settings->getAccounts() ); | 38 | folderView->populate( settings->getAccounts() ); |
37 | 39 | ||
38 | } | 40 | } |
39 | 41 | ||
40 | OpieMail::~OpieMail() | 42 | OpieMail::~OpieMail() |
41 | { | 43 | { |
42 | if (settings) delete settings; | 44 | if (settings) delete settings; |
43 | } | 45 | } |
44 | 46 | ||
45 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | 47 | void OpieMail::appMessage(const QCString &msg, const QByteArray &data) |
46 | { | 48 | { |
47 | 49 | ||
48 | } | 50 | } |
49 | #include <stdlib.h> | 51 | #include <stdlib.h> |
50 | void OpieMail::message(const QCString &msg, const QByteArray &data) | 52 | void OpieMail::message(const QCString &msg, const QByteArray &data) |
51 | { | 53 | { |
52 | // copied from old mail2 | 54 | // copied from old mail2 |
53 | static int ii = 0; | 55 | static int ii = 0; |
54 | //qDebug("QCOP CALL ############################# %d ", ii); | 56 | //qDebug("QCOP CALL ############################# %d ", ii); |
55 | //QString mess ( msg ); | 57 | //QString mess ( msg ); |
56 | //qDebug("Message = %s ",mess.latin1()); | 58 | //qDebug("Message = %s ",mess.latin1()); |
57 | ++ii; | 59 | ++ii; |
58 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); | 60 | //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); |
59 | 61 | ||
60 | mPendingEmail = QString::null; | 62 | mPendingEmail = QString::null; |
61 | mPendingName = QString::null; | 63 | mPendingName = QString::null; |
62 | if (msg == "writeMail(QString,QString)") | 64 | if (msg == "writeMail(QString,QString)") |
63 | { | 65 | { |
64 | //qDebug("writeMail(QString,QString) "); | 66 | //qDebug("writeMail(QString,QString) "); |
65 | QDataStream stream(data,IO_ReadOnly); | 67 | QDataStream stream(data,IO_ReadOnly); |
66 | stream >> mPendingName >> mPendingEmail; | 68 | stream >> mPendingName >> mPendingEmail; |
67 | // removing the whitespaces at beginning and end is needed! | 69 | // removing the whitespaces at beginning and end is needed! |
68 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 70 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
69 | } | 71 | } |
70 | else if (msg == "newMail()") | 72 | else if (msg == "newMail()") |
71 | { | 73 | { |
72 | //qDebug("slotComposeMail() "); | 74 | //qDebug("slotComposeMail() "); |
73 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call | 75 | // we cannot call slotComposeMail(); directly, because may be executing a QCOP call |
74 | // and a QCOP call does not like a processevents in his execution | 76 | // and a QCOP call does not like a processevents in his execution |
75 | // with the Qtimer we call slotComposeMail() after we reached the main event loop | 77 | // with the Qtimer we call slotComposeMail() after we reached the main event loop |
76 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 78 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
77 | // slotComposeMail(); | 79 | // slotComposeMail(); |
78 | } | 80 | } |
79 | else if (msg == "newMail(QString)") | 81 | else if (msg == "newMail(QString)") |
80 | { | 82 | { |
81 | //qDebug(" newMail(QString)"); | 83 | //qDebug(" newMail(QString)"); |
82 | QDataStream stream(data,IO_ReadOnly); | 84 | QDataStream stream(data,IO_ReadOnly); |
83 | stream >> mPendingName; | 85 | stream >> mPendingName; |
84 | // the format is | 86 | // the format is |
85 | // NAME <EMAIL>:SUBJECT | 87 | // NAME <EMAIL>:SUBJECT |
86 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); | 88 | QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); |
87 | } else { | 89 | } else { |
88 | mPendingData = data; | 90 | mPendingData = data; |
89 | mPendingMessage = msg; | 91 | mPendingMessage = msg; |
90 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); | 92 | QTimer::singleShot ( 50, this, SLOT(slotExtAppHandler() ) ); |
91 | } | 93 | } |
92 | 94 | ||
93 | //qDebug("END OpieMail::message "); | 95 | //qDebug("END OpieMail::message "); |
94 | } | 96 | } |
95 | void OpieMail::slotExtAppHandler() | 97 | void OpieMail::slotExtAppHandler() |
96 | { | 98 | { |
97 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); | 99 | ExternalAppHandler::instance()->appMessage ( mPendingMessage, mPendingData ); |
98 | } | 100 | } |
99 | void OpieMail::slotwriteMail2(const QString& namemail ) | 101 | void OpieMail::slotwriteMail2(const QString& namemail ) |
100 | { | 102 | { |
101 | //qDebug("OpieMail::slotwriteMail2 "); | 103 | //qDebug("OpieMail::slotwriteMail2 "); |
102 | //qApp->processEvents(); | 104 | //qApp->processEvents(); |
103 | ComposeMail compose( settings, this, 0, true ); | 105 | ComposeMail compose( settings, this, 0, true ); |
104 | if ( !namemail.isEmpty() ) { | 106 | if ( !namemail.isEmpty() ) { |
105 | QString to = namemail; | 107 | QString to = namemail; |
106 | if ( namemail.find( " <") > 1 ) { | 108 | if ( namemail.find( " <") > 1 ) { |
107 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; | 109 | to = "\"" +to.replace( QRegExp( " <"), "\" <") ; |
108 | } else | 110 | } else |
109 | if ( namemail.find( "<") > 1 ) { | 111 | if ( namemail.find( "<") > 1 ) { |
110 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; | 112 | to = "\"" +to.replace( QRegExp( "<"), "\" <") ; |
111 | } | 113 | } |
112 | int sub = to.find( ">:"); | 114 | int sub = to.find( ">:"); |
113 | if ( sub > 0 ) { | 115 | if ( sub > 0 ) { |
114 | compose.setTo( to.left(sub+1) ); | 116 | compose.setTo( to.left(sub+1) ); |
115 | compose.setSubject( to.mid(sub+2) ); | 117 | compose.setSubject( to.mid(sub+2) ); |
116 | } else | 118 | } else |
117 | compose.setTo( to ); | 119 | compose.setTo( to ); |
118 | } | 120 | } |
119 | compose.slotAdjustColumns(); | 121 | compose.slotAdjustColumns(); |
120 | compose.showMaximized(); | 122 | compose.showMaximized(); |
121 | compose.exec(); | 123 | compose.exec(); |
122 | raise(); | 124 | raise(); |
123 | //qDebug("retttich "); | 125 | //qDebug("retttich "); |
124 | } | 126 | } |
125 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 127 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
126 | { | 128 | { |
127 | // qDebug("OpieMail::slotwriteMail "); | 129 | // qDebug("OpieMail::slotwriteMail "); |
128 | ComposeMail compose( settings, this, 0, true ); | 130 | ComposeMail compose( settings, this, 0, true ); |
129 | if (!email.isEmpty()) | 131 | if (!email.isEmpty()) |
130 | { | 132 | { |