author | zautrix <zautrix> | 2004-10-31 12:28:03 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-31 12:28:03 (UTC) |
commit | bed831cc1a38d38a4c5b9329bf37b1c663142c23 (patch) (side-by-side diff) | |
tree | db12b81ea6cee0cac347c801798d759dfe24acfb | |
parent | 553bd9acf9879a77c5fa925155f73afbe8a9af41 (diff) | |
download | kdepimpi-bed831cc1a38d38a4c5b9329bf37b1c663142c23.zip kdepimpi-bed831cc1a38d38a4c5b9329bf37b1c663142c23.tar.gz kdepimpi-bed831cc1a38d38a4c5b9329bf37b1c663142c23.tar.bz2 |
ompi utf8 fixes
-rw-r--r-- | kdepim-desktop.pro | 6 | ||||
-rw-r--r-- | kmicromail/composemail.cpp | 52 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/imapwrapper.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.cpp | 1 | ||||
-rw-r--r-- | kmicromail/libmailwrapper/settings.h | 1 | ||||
-rw-r--r-- | kmicromail/mailistviewitem.cpp | 4 | ||||
-rw-r--r-- | kmicromail/mainwindow.cpp | 6 | ||||
-rw-r--r-- | kmicromail/opiemail.cpp | 46 | ||||
-rw-r--r-- | kmicromail/opiemail.h | 1 | ||||
-rw-r--r-- | kmicromail/qpe/global.cpp | 6 | ||||
-rw-r--r-- | kmicromail/qpe/qdialog.h | 4 | ||||
-rw-r--r-- | kmicromail/qpe/qdialog_hacked.cpp | 6 | ||||
-rw-r--r-- | kmicromail/viewmail.cpp | 33 |
13 files changed, 106 insertions, 61 deletions
diff --git a/kdepim-desktop.pro b/kdepim-desktop.pro index 6d04a45..b0d60b7 100644 --- a/kdepim-desktop.pro +++ b/kdepim-desktop.pro @@ -1,6 +1,8 @@ TEMPLATE = subdirs -SUBDIRS = libical libkcal kabc libkdepim microkde kmicromail/libetpan kmicromail/libmailwrapper kmicromail korganizer kaddressbook kabc/plugins/file kabc/plugins/dir kabc/plugins/file kabc/plugins/qtopia gammu/emb/common gammu/emb/gammu pwmanager/libcrypt/cipher pwmanager/libcrypt/error pwmanager/libcrypt/mpi pwmanager/libcrypt/zlib pwmanager/pwmanager -#kalarmd +SUBDIRS = libical libkcal kabc libkdepim microkde korganizer kaddressbook kabc/plugins/file kabc/plugins/dir kabc/plugins/file kabc/plugins/qtopia gammu/emb/common gammu/emb/gammu +unix:{ +SUBDIRS += kmicromail/libetpan kmicromail/libmailwrapper kmicromail pwmanager/libcrypt/cipher pwmanager/libcrypt/error pwmanager/libcrypt/mpi pwmanager/libcrypt/zlib pwmanager/pwmanager +} diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 5945b7f..2dcbc75 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp @@ -1,102 +1,102 @@ // CHANGED 2004-08-06 Lutz Rogowski #include <kabc/addresseedialog.h> #include <kabc/stdaddressbook.h> #include <kabc/addressee.h> #ifdef DESKTOP_VERSION #include <qapplication.h> #include <kabc/addresseedialog.h> #endif //DESKTOP_VERSION #include <libkdepim/externalapphandler.h> #include "koprefs.h" #ifdef MINIKDE_KDIALOG_H #undef MINIKDE_KDIALOG_H #endif #include "composemail.h" #include <libmailwrapper/smtpwrapper.h> #include <libmailwrapper/storemail.h> #include <libmailwrapper/abstractmail.h> #include <libmailwrapper/mailtypes.h> /* OPIE */ //#include <opie2/ofiledialog.h> //#include <opie2/odebug.h> #include <kfiledialog.h> //#include <qpe/resource.h> #include <qpe/global.h> //#include <qpe/contact.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qiconset.h> #include <qtimer.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qmultilineedit.h> #include <qlabel.h> #include <qtabwidget.h> #include <qlistview.h> //using namespace Opie::Core; //using namespace Opie::Ui; -ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) +ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, bool modal ) : ComposeMailUI( parent, name, modal ) { mPickLineEdit = 0; connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); - settings = s; + settings = sett; m_replyid = ""; if ( KOPrefs::instance()->mUseKapi) { KConfig config( locateLocal("config", "kabcrc") ); config.setGroup( "General" ); QString whoami_uid = config.readEntry( "WhoAmI" ); if ( whoami_uid.isEmpty() ) { QMessageBox::information( 0, i18n( "Hint" ), i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), i18n( "Ok" ) ); fillSettings(); } else ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); #ifdef DESKTOP_VERSION KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); QStringList mails = con.emails(); QString defmail = con.preferredEmail(); if ( mails.count() == 0) QMessageBox::information( 0, i18n( "Hint" ), i18n( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), i18n( "Ok" ) ); if (defmail.length()!=0) { fromBox->insertItem(defmail); } QStringList::ConstIterator sit = mails.begin(); for (;sit!=mails.end();++sit) { if ( (*sit)==defmail) continue; fromBox->insertItem((*sit)); } senderNameEdit->setText(con.formattedName()); #endif } else { fillSettings(); } checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); attList->addColumn( i18n( "Name" ) ); attList->addColumn( i18n( "Size" ) ); QList<Account> accounts = settings->getAccounts(); if ( QApplication::desktop()->width() < 320 ) smtpAccountBox->setMaximumWidth( 80 ); @@ -120,109 +120,109 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m QIconSet icon; //icon = SmallIcon("fileexport"); icon = SmallIcon("filesave"); SaveButton->setIconSet (icon ) ; if ( QApplication::desktop()->width() < 320 ) { SaveButton->setText ("") ; SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; } else SaveButton->setText (i18n("Save")); #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); #endif message->setFont ( KOPrefs::instance()->mComposeFont ); message->setWordWrap (QMultiLineEdit::WidgetWidth); if ( smtpAccounts.count() > 0 ) { fillValues( smtpAccountBox->currentItem() ); } else { QMessageBox::information( 0, i18n( "Problem" ), i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), i18n( "Ok" ) ); return; } connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); } void ComposeMail::fillSettings() { if ( QApplication::desktop()->width() < 320 ) fromBox->setMaximumWidth( 100 ); QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); QStringList::ConstIterator sit = mailList.begin(); int pref = 0; for (;sit!=mailList.end();++sit) { fromBox->insertItem((*sit)); } senderNameEdit->setText(KOPrefs::instance()->mName); } void ComposeMail::saveAsDraft() { Opie::Core::OSmartPointer<Mail> mail= new Mail(); - mail->setMail(fromBox->currentText()); - mail->setTo( toLine->text() ); - mail->setName(senderNameEdit->text()); - mail->setCC( ccLine->text() ); - mail->setBCC( bccLine->text() ); - mail->setReply( replyLine->text() ); - mail->setSubject( subjectLine->text() ); + mail->setMail(fromBox->currentText().utf8 ()); + mail->setTo( toLine->text().utf8 () ); + mail->setName(senderNameEdit->text().utf8 ()); + mail->setCC( ccLine->text().utf8 () ); + mail->setBCC( bccLine->text().utf8 () ); + mail->setReply( replyLine->text().utf8 () ); + mail->setSubject( subjectLine->text().utf8 () ); if (!m_replyid.isEmpty()) { QStringList ids; ids.append(m_replyid); mail->setInreply(ids); } - QString txt = message->text(); + QString txt = message->text().utf8 (); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); txt.append( sigMultiLine->text() ); } mail->setMessage( txt ); /* only use the default drafts folder name! */ Storemail wrapper(AbstractMail::draftFolder()); wrapper.storeMail(mail); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); /* attachments we will ignore! */ if ( it != 0 ) { if ( warnAttach ) QMessageBox::warning(0,i18n("Store message"), i18n("<center>Attachments will not be stored in \"Draft\" folder</center>")); warnAttach = false; } setStatus( i18n("Mail saved as draft!") ); } void ComposeMail::clearStatus() { topLevelWidget()->setCaption( i18n("Compose mail") ); } void ComposeMail::setStatus( QString status ) { topLevelWidget()->setCaption( status ); QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ; } void ComposeMail::pickAddress( ) { QLineEdit *line = mPickLineEdit; if ( line == 0 ) return; #ifdef DESKTOP_VERSION //qDebug(" ComposeMail::pickAddress "); QString names ;//= AddressPicker::getNames(); KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); uint i=0; for (i=0; i < list.count(); i++) { if ( !list[i].preferredEmail().isEmpty()) { if ( ! names.isEmpty() ) names+= ","; names+= "\""+list[i].realName() +"\"<" +list[i].preferredEmail() +">"; } @@ -363,141 +363,141 @@ void ComposeMail::slotAdjustColumns() tabWidget->setCurrentPage( currPage ); } void ComposeMail::addAttachment() { QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); if ( !lnk.isEmpty() ) { Attachment *att = new Attachment( lnk ); (void) new AttachViewItem( attList, att ); } } void ComposeMail::removeAttachment() { if ( !attList->currentItem() ) { QMessageBox::information( this, i18n( "Error" ), i18n( "<p>Please select a File.</p>" ), i18n( "Ok" ) ); } else { attList->takeItem( attList->currentItem() ); } } void ComposeMail::accept() { if ( smtpAccountBox->count() == 0 ) { reject(); return; } if (! checkBoxLater->isChecked() ) { int yesno = QMessageBox::warning(0,i18n("Stop editing message"), i18n("Send this message?"), i18n("Yes"), i18n("Cancel")); if (yesno == 1) { return; } } #if 0 odebug << "Sending Mail with " << smtpAccounts.at( smtpAccountBox->currentItem() )->getAccountName() << oendl; #endif Opie::Core::OSmartPointer<Mail> mail=new Mail; SMTPaccount *smtp = smtpAccounts.at( smtpAccountBox->currentItem() ); - mail->setMail(fromBox->currentText()); + mail->setMail(fromBox->currentText().utf8 ()); if ( !toLine->text().isEmpty() ) { - mail->setTo( toLine->text() ); + mail->setTo( toLine->text().utf8 () ); } else { QMessageBox::warning(0,i18n("Sending mail"), i18n("No Receiver spezified" ) ); return; } - mail->setName(senderNameEdit->text()); - mail->setCC( ccLine->text() ); - mail->setBCC( bccLine->text() ); - mail->setReply( replyLine->text() ); - mail->setSubject( subjectLine->text() ); + mail->setName(senderNameEdit->text().utf8 ()); + mail->setCC( ccLine->text().utf8 () ); + mail->setBCC( bccLine->text().utf8 () ); + mail->setReply( replyLine->text().utf8 () ); + mail->setSubject( subjectLine->text().utf8 () ); if (!m_replyid.isEmpty()) { QStringList ids; - ids.append(m_replyid); + ids.append(m_replyid.utf8 ()); mail->setInreply(ids); } - QString txt = message->text(); + QString txt = message->text().utf8 (); if ( !sigMultiLine->text().isEmpty() ) { txt.append( "\n--\n" ); - txt.append( sigMultiLine->text() ); + txt.append( sigMultiLine->text().utf8 () ); } mail->setMessage( txt ); AttachViewItem *it = (AttachViewItem *) attList->firstChild(); while ( it != 0 ) { mail->addAttachment( it->getAttachment() ); it = (AttachViewItem *) it->nextSibling(); } SMTPwrapper wrapper( smtp ); if ( wrapper.sendMail( mail,checkBoxLater->isChecked() ) ) setStatus( tr ("Mail sent")); else { setStatus( tr ("Error: Something went wrong. Nothing sent")); return; } QDialog::accept(); } void ComposeMail::reject() { //qDebug("ComposeMail::reject() "); int yesno = QMessageBox::warning(0,i18n("Store message?"), i18n("Store message into drafts?\n"), i18n("Yes"), i18n("No")); //qDebug("button %d ", yesno); if (yesno == 0) { if ( toLine->text().isEmpty() ) { QMessageBox::warning(0,i18n("Sending mail"), i18n("No Receiver spezified" ) ); return; } saveAsDraft(); } if (yesno == 2) { qDebug("return "); return; } QDialog::reject(); } ComposeMail::~ComposeMail() { } void ComposeMail::reEditMail(const RecMailP¤t) { RecMailP data = current; - message->setText(data->Wrapper()->fetchBody(current)->Bodytext()); - subjectLine->setText( data->getSubject()); - toLine->setText(data->To().join(",")); - ccLine->setText(data->CC().join(",")); - bccLine->setText(data->Bcc().join(",")); - replyLine->setText(data->Replyto()); + message->setText(QString::fromUtf8( data->Wrapper()->fetchBody(current)->Bodytext().latin1() )); + subjectLine->setText( QString::fromUtf8( data->getSubject().latin1() )); + toLine->setText(QString::fromUtf8( data->To().join(",").latin1() )); + ccLine->setText(QString::fromUtf8( data->CC().join(",").latin1() )); + bccLine->setText(QString::fromUtf8( data->Bcc().join(",").latin1() )); + replyLine->setText(QString::fromUtf8( data->Replyto().latin1() )); } AttachViewItem::AttachViewItem( QListView *parent, Attachment *att ) : QListViewItem( parent ) { attachment = att; if ( !attachment->getPixmap().isNull() ) setPixmap( 0,attachment->getPixmap() ); setText( 0, att->getName().isEmpty() ? att->getFileName() : att->getName() ); setText( 1, QString::number( att->getSize() ) ); } diff --git a/kmicromail/libmailwrapper/imapwrapper.cpp b/kmicromail/libmailwrapper/imapwrapper.cpp index 110583f..ae667ec 100644 --- a/kmicromail/libmailwrapper/imapwrapper.cpp +++ b/kmicromail/libmailwrapper/imapwrapper.cpp @@ -706,96 +706,97 @@ encodedString*IMAPwrapper::fetchRawPart(const RecMailP&mail,const QValueList<int msg_att = (mailimap_msg_att*)current->data; mailimap_msg_att_item*msg_att_item; for(cur = clist_begin(msg_att->att_list) ; cur != NULL ; cur = clist_next(cur)) { msg_att_item = (mailimap_msg_att_item*)clist_content(cur); if (msg_att_item->att_type == MAILIMAP_MSG_ATT_ITEM_STATIC) { if (msg_att_item->att_data.att_static->att_type == MAILIMAP_MSG_ATT_BODY_SECTION) { char*text = msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part; /* detach - we take over the content */ msg_att_item->att_data.att_static->att_data.att_body_section->sec_body_part = 0L; res->setContent(text,msg_att_item->att_data.att_static->att_data.att_body_section->sec_length); } } } } else { ;//odebug << "error fetching text: " << m_imap->imap_response << "" << oendl; } if (result) mailimap_fetch_list_free(result); return res; } /* current_recursion is for recursive calls. current_count means the position inside the internal loop! */ void IMAPwrapper::traverseBody(const RecMailP&mail,mailimap_body*body,RecBodyP&target_body, int current_recursion,QValueList<int>recList,int current_count) { if (!body || current_recursion>=10) { return; } switch (body->bd_type) { case MAILIMAP_BODY_1PART: { QValueList<int>countlist = recList; countlist.append(current_count); RecPartP currentPart = new RecPart(); mailimap_body_type_1part*part1 = body->bd_data.bd_body_1part; QString id(""); currentPart->setPositionlist(countlist); for (unsigned int j = 0; j < countlist.count();++j) { id+=(j>0?" ":""); id+=QString("%1").arg(countlist[j]); } //odebug << "ID = " << id.latin1() << "" << oendl; currentPart->setIdentifier(id); fillSinglePart(currentPart,part1); /* important: Check for is NULL 'cause a body can be empty! And we put it only into the mail if it is the FIRST part */ if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_TEXT && target_body->Bodytext().isNull() && countlist[0]==1) { QString body_text = fetchTextPart(mail,countlist,true,currentPart->Encoding()); + //qDebug("encoding %d text %s ",currentPart->Encoding().latin1(), body_text.latin1() ); target_body->setDescription(currentPart); target_body->setBodytext(body_text); if (countlist.count()>1) { target_body->addPart(currentPart); } } else { target_body->addPart(currentPart); } if (part1->bd_type==MAILIMAP_BODY_TYPE_1PART_MSG) { traverseBody(mail,part1->bd_data.bd_type_msg->bd_body,target_body,current_recursion+1,countlist); } } break; case MAILIMAP_BODY_MPART: { QValueList<int>countlist = recList; clistcell*current=0; mailimap_body*current_body=0; unsigned int ccount = 1; mailimap_body_type_mpart*mailDescription = body->bd_data.bd_body_mpart; for (current=clist_begin(mailDescription->bd_list);current!=0;current=clist_next(current)) { current_body = (mailimap_body*)current->data; if (current_body->bd_type==MAILIMAP_BODY_MPART) { RecPartP targetPart = new RecPart(); targetPart->setType("multipart"); fillMultiPart(targetPart,mailDescription); countlist.append(current_count); targetPart->setPositionlist(countlist); target_body->addPart(targetPart); QString id(""); for (unsigned int j = 0; j < countlist.count();++j) { id+=(j>0?" ":""); id+=QString("%1").arg(countlist[j]); } // odebug << "ID(mpart) = " << id.latin1() << "" << oendl; } traverseBody(mail,current_body,target_body,current_recursion+1,countlist,ccount); if (current_body->bd_type==MAILIMAP_BODY_MPART) { countlist = recList; } ++ccount; } } break; default: break; } } diff --git a/kmicromail/libmailwrapper/settings.cpp b/kmicromail/libmailwrapper/settings.cpp index 40b5591..5d2c0ad 100644 --- a/kmicromail/libmailwrapper/settings.cpp +++ b/kmicromail/libmailwrapper/settings.cpp @@ -1,72 +1,73 @@ #include <stdlib.h> #include <qdir.h> //#include <opie2/odebug.h> #include <kconfig.h> #include <kstandarddirs.h> #include "settings.h" //#include "defines.h" #define IMAP_PORT "143" #define IMAP_SSL_PORT "993" #define SMTP_PORT "25" #define SMTP_SSL_PORT "465" #define POP3_PORT "110" #define POP3_SSL_PORT "995" #define NNTP_PORT "119" #define NNTP_SSL_PORT "563" Settings::Settings() : QObject() { updateAccounts(); + //qDebug("++++++++++++++++++new settings "); } void Settings::checkDirectory() { return; locateLocal("data", "kopiemail" ); /* if ( !QDir( (QString) getenv( "HOME" ) + "/Applications/opiemail/" ).exists() ) { system( "mkdir -p $HOME/Applications/opiemail" ); qDebug("$HOME/Applications/opiemail created "); } */ } QList<Account> Settings::getAccounts() { return accounts; } void Settings::addAccount( Account *account ) { accounts.append( account ); } void Settings::delAccount( Account *account ) { accounts.remove( account ); account->remove(); } void Settings::updateAccounts() { accounts.clear(); QDir dir( locateLocal("data", "kopiemail" ) ); QStringList::Iterator it; QStringList imap = dir.entryList( "imap-*" ); for ( it = imap.begin(); it != imap.end(); it++ ) { IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") ); accounts.append( account ); } QStringList pop3 = dir.entryList( "pop3-*" ); for ( it = pop3.begin(); it != pop3.end(); it++ ) { POP3account *account = new POP3account( (*it).replace(0, 5, "") ); accounts.append( account ); } diff --git a/kmicromail/libmailwrapper/settings.h b/kmicromail/libmailwrapper/settings.h index 79567ef..c996fe0 100644 --- a/kmicromail/libmailwrapper/settings.h +++ b/kmicromail/libmailwrapper/settings.h @@ -120,62 +120,63 @@ public: static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); void setLogin( bool b ) { login = b; } bool getLogin() { return login; } private: QString file, name, mail, org, cc, bcc, reply, signature; bool useCC, useBCC, useReply, login; }; class NNTPaccount : public Account { public: NNTPaccount(); NNTPaccount( QString filename ); static QString getUniqueFileName(); virtual void read(); virtual void save(); virtual QString getFileName(); void setLogin( bool b ) { login = b; } bool getLogin() { return login; } void setGroups( QStringList list ) { subscribedGroups = list; } QStringList getGroups() { return subscribedGroups; } private: QString file; bool login; QStringList subscribedGroups; }; class Settings : public QObject { Q_OBJECT public: Settings(); + //~Settings(){qDebug("-------------------settings "); }; QList<Account> getAccounts(); void addAccount(Account *account); void delAccount(Account *account); void saveAccounts(); void readAccounts(); static void checkDirectory(); private: void updateAccounts(); QList<Account> accounts; }; #endif diff --git a/kmicromail/mailistviewitem.cpp b/kmicromail/mailistviewitem.cpp index 484a635..5ef5b6a 100644 --- a/kmicromail/mailistviewitem.cpp +++ b/kmicromail/mailistviewitem.cpp @@ -10,98 +10,98 @@ MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) { } void MailListViewItem::showEntry() { if ( mail_data->getFlags().testBit( FLAG_ANSWERED ) == true) { setPixmap( 0, SmallIcon ( "kmmsgreplied") ); } else if ( mail_data->getFlags().testBit( FLAG_SEEN ) == true ) { /* I think it looks nicer if there are not such a log of icons but only on mails replied or new - Alwin*/ //setPixmap( 0,SmallIcon ("kmmsgunseen") ); } else { setPixmap( 0,SmallIcon ( "kmmsgnew") ); } double s = mail_data->Msgsize(); int w = 0; s/=1024; if (s>999.0) { s/=1024.0; ++w; } QString fsort; fsort.sprintf( "%.2f", s ); QString fsize = QString::number( s, 'f', 2 ); // 1.23 // 11.23 // 111.23 // 999.23 maxlen switch(fsize.length() ) { case 4: fsort = "00" + fsize ; break; case 5: fsort = "0" + fsize ; break; default: fsort = fsize ; break; } if ( w == 0 ) { setText(3, fsize + "kB" ); mKeyMap.insert(3, "k" + fsort); //setText(3, "kB" + fsort ); // test only } else { //setText(3, fsize + "MB"); mKeyMap.insert(3, "M" +fsort ); } - setText(1,mail_data->getSubject()); - setText(2,mail_data->getFrom()); + setText(1,QString::fromUtf8( mail_data->getSubject().latin1())); + setText(2,QString::fromUtf8( mail_data->getFrom().latin1())); #if 0 QString date = mail_data->getDate(); int kom = date.find( ",")+2; if ( kom == 1 ) kom = 0; if ( date.mid(kom,1) == " ") ++kom; if ( date.mid(kom+1,1) == " " ) date = "0" + date.mid( kom ); else if ( kom ) date = date.mid( kom ); if ( kom || date.mid(2,1 ) == " ") { QString mon = date.mid(3,3); QString so = 00; if ( mon == "Jan" ) so = "01"; else if ( mon == "Feb" ) so = "02"; else if ( mon == "Mar" ) so = "03"; else if ( mon == "Apr" ) so = "04"; else if ( mon == "May" ) so = "05"; else if ( mon == "Jun" ) so = "06"; else if ( mon == "Jul" ) so = "07"; else if ( mon == "Aug" ) so = "08"; else if ( mon == "Sep" ) so = "09"; else if ( mon == "Oct" ) so = "10"; else if ( mon == "Nov" ) so = "11"; else if ( mon == "Dec" ) so = "12"; date = date.mid(7,4)+so+date.left(2)+date.mid(12,14); } //qDebug("insert Date %s ", date.latin1()); // if ( date.left(1) != "1" || date.left(1) != "2" ) // date = date.mid(5); mKeyMap.insert(4,date); #endif mKeyMap.insert(4,mail_data->getIsoDate()); setText(4,mail_data->getDate()); diff --git a/kmicromail/mainwindow.cpp b/kmicromail/mainwindow.cpp index 4115276..98eb9a5 100644 --- a/kmicromail/mainwindow.cpp +++ b/kmicromail/mainwindow.cpp @@ -1,74 +1,78 @@ // CHANGED 2004-08-06 Lutz Rogowski #include <qlabel.h> #include <qvbox.h> #include <qheader.h> #include <qtimer.h> #include <qlayout.h> //#include <kdialog.h> #include <kiconloader.h> #include <kapplication.h> #ifdef DESKTOP_VERSION #include <qapplication.h> +#include <qstatusbar.h> +extern QStatusBar* globalSstatusBarMainWindow; #else #include <qpe/qpeapplication.h> #endif #include "defines.h" #include "mainwindow.h" #include <KDGanttMinimizeSplitter.h> - #include <kabc/stdaddressbook.h> MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name ) //, flags ) { +#ifdef DESKTOP_VERSION + globalSstatusBarMainWindow = statusBar(); +#endif setCaption( i18n( "KOpieMail/Pi" ) ); setToolBarsMovable( false ); //KABC::StdAddressBook::self(); toolBar = new QToolBar( this ); menuBar = new QPEMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( i18n( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( i18n( "Settings" ), settingsMenu ); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); QAction* getMail = new QAction( i18n( "Get all new mails" ), SmallIcon("enter"), 0, 0, this ); connect(getMail, SIGNAL( activated() ), SLOT( slotGetAllMail() ) ); getMail->addTo( mailMenu ); getMail = new QAction( i18n( "Get new messages" ), SmallIcon("add"), 0, 0, this ); getMail->addTo( toolBar ); getMail->addTo( mailMenu ); connect(getMail, SIGNAL( activated() ), SLOT( slotGetMail() ) ); composeMail = new QAction( i18n( "Compose new mail" ), SmallIcon("composemail"), 0, 0, this ); composeMail->addTo( toolBar ); composeMail->addTo( mailMenu ); sendQueued = new QAction( i18n( "Send queued mails" ), SmallIcon("sendqueued") , 0, 0, this ); sendQueued->addTo( toolBar ); sendQueued->addTo( mailMenu ); /* syncFolders = new QAction( i18n( "Sync mailfolders" ), ICON_SYNC, 0, 0, this ); syncFolders->addTo( toolBar ); syncFolders->addTo( mailMenu ); */ showFolders = new QAction( i18n( "Show/Hide folders" ), SmallIcon("showfolders") , 0, 0, this, 0, true ); showFolders->addTo( toolBar ); showFolders->addTo( mailMenu ); showFolders->setOn( true ); connect(showFolders, SIGNAL( toggled(bool) ), diff --git a/kmicromail/opiemail.cpp b/kmicromail/opiemail.cpp index ca3faaf..fe9df87 100644 --- a/kmicromail/opiemail.cpp +++ b/kmicromail/opiemail.cpp @@ -1,90 +1,91 @@ // CHANGED 2004-09-31 Lutz Rogowski // CHANGED 2004-08-06 Lutz Rogowski #include "koprefsdialog.h" #include <kapplication.h> #include <libkdepim/externalapphandler.h> #include <libkdepim/kpimglobalprefs.h> #ifdef MINIKDE_KDIALOG_H #undef MINIKDE_KDIALOG_H #endif #include "settingsdialog.h" #include "opiemail.h" #include "editaccounts.h" #include "composemail.h" #include "mailistviewitem.h" #include "viewmail.h" #include "selectstore.h" #include "selectsmtp.h" #include "accountitem.h" #include "klocale.h" #include <qmessagebox.h> #include <qtimer.h> #include <qcursor.h> #include <qregexp.h> #ifdef DESKTOP_VERSION #include <qapplication.h> #else #include <qpe/qpeapplication.h> #endif #include <libmailwrapper/smtpwrapper.h> #include <libmailwrapper/mailtypes.h> #include <libmailwrapper/abstractmail.h> //using namespace Opie::Core; OpieMail::OpieMail( QWidget *parent, const char *name ) : MainWindow( parent, name) //, WStyle_ContextHelp ) { settings = new Settings(); + setIcon(SmallIcon( "kmicromail" ) ); folderView->populate( settings->getAccounts() ); } OpieMail::~OpieMail() { if (settings) delete settings; } void OpieMail::appMessage(const QCString &msg, const QByteArray &data) { } #include <stdlib.h> void OpieMail::message(const QCString &msg, const QByteArray &data) { // copied from old mail2 static int ii = 0; //qDebug("QCOP CALL ############################# %d ", ii); //QString mess ( msg ); //qDebug("Message = %s ",mess.latin1()); ++ii; //qDebug("KM:appMessage %d *%s* %x", ii, msg.data(), this); mPendingEmail = QString::null; mPendingName = QString::null; if (msg == "writeMail(QString,QString)") { //qDebug("writeMail(QString,QString) "); QDataStream stream(data,IO_ReadOnly); stream >> mPendingName >> mPendingEmail; // removing the whitespaces at beginning and end is needed! QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); } else if (msg == "newMail()") { //qDebug("slotComposeMail() "); // we cannot call slotComposeMail(); directly, because may be executing a QCOP call // and a QCOP call does not like a processevents in his execution // with the Qtimer we call slotComposeMail() after we reached the main event loop QTimer::singleShot ( 50, this, SLOT(slotComposeMail() ) ); // slotComposeMail(); } else if (msg == "newMail(QString)") { //qDebug(" newMail(QString)"); QDataStream stream(data,IO_ReadOnly); stream >> mPendingName; @@ -195,97 +196,140 @@ void OpieMail::slotSendQueued() selsmtp.setSelectionlist(&smtpList); selsmtp.showMaximized(); if ( selsmtp.exec() == QDialog::Accepted ) { smtp = selsmtp.selected_smtp(); } } if (smtp) { SMTPwrapper * wrap = new SMTPwrapper(smtp); if ( wrap->flushOutbox() ) { QMessageBox::information(0,i18n("Info"),i18n("Mail queue flushed")); } delete wrap; } } void OpieMail::slotSearchMails() { qDebug("OpieMail::slotSearchMails():not implemented "); } void OpieMail::slotEditSettings() { KOPrefsDialog settingsDialog( this, "koprefs", true ); #ifndef DESKTOP_VERSION settingsDialog.showMaximized(); #endif settingsDialog.exec(); // KApplication::execDialog(settingsDialog); } void OpieMail::slotEditAccounts() { EditAccounts eaDialog( settings, this, 0, true ); eaDialog.slotAdjustColumns(); #ifndef DESKTOP_VERSION eaDialog.showMaximized(); #endif eaDialog.exec(); if ( settings ) delete settings; settings = new Settings(); folderView->populate( settings->getAccounts() ); } +void OpieMail::replyMail() +{ + + QListViewItem*item = mailView->currentItem(); + if (!item) return; + RecMailP mail = ((MailListViewItem*)item)->data(); + RecBodyP body = folderView->fetchBody(mail); + + QString rtext; + rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose + .arg( QString::fromUtf8( mail->getFrom().latin1())) + .arg( QString::fromUtf8( mail->getDate().latin1() )); + + QString text = QString::fromUtf8( body->Bodytext().latin1() ); + QStringList lines = QStringList::split(QRegExp("\\n"), text); + QStringList::Iterator it; + for (it = lines.begin(); it != lines.end(); it++) + { + rtext += "> " + *it + "\n"; + } + rtext += "\n"; + QString prefix; + if ( mail->getSubject().find(QRegExp("^Re: .*$")) != -1) prefix = ""; + else prefix = "Re: "; // no i18n on purpose + + Settings *settings = new Settings(); + ComposeMail composer( settings ,this, 0, true); + if (mail->Replyto().isEmpty()) { + composer.setTo( QString::fromUtf8( mail->getFrom().latin1())); + } else { + composer.setTo( QString::fromUtf8(mail->Replyto().latin1())); + } + composer.setSubject( prefix + QString::fromUtf8( mail->getSubject().latin1() ) ); + composer.setMessage( rtext ); + composer.setInReplyTo( QString::fromUtf8(mail->Msgid().latin1())); + + if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) + { + mail->Wrapper()->answeredMail(mail); + } + delete settings; + +} void OpieMail::displayMail() { QListViewItem*item = mailView->currentItem(); if (!item) return; RecMailP mail = ((MailListViewItem*)item)->data(); RecBodyP body = folderView->fetchBody(mail); ViewMail readMail( this,"", Qt::WType_Modal ); readMail.setBody( body ); readMail.setMail( mail ); #ifndef DESKTOP_VERSION readMail.showMaximized(); #else readMail.resize( 640, 480); #endif readMail.exec(); if ( readMail.deleted ) { folderView->refreshCurrent(); } else { ( (MailListViewItem*)item )->setPixmap( 0, QPixmap() ); } } void OpieMail::slotGetAllMail() { QListViewItem * item = folderView->firstChild(); while ( item ){ ((AccountViewItem *)item)->contextMenuSelected( 101 ); item = item->nextSibling (); } } void OpieMail::slotGetMail() { QListViewItem * item = folderView->currentItem(); if ( ! item ) return; ((AccountViewItem *)item)->contextMenuSelected( 101 ); } void OpieMail::slotDeleteMail() { if (!mailView->currentItem()) return; RecMailP mail = ((MailListViewItem*)mailView->currentItem() )->data(); if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + mail->getFrom() + " - " + mail->getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { mail->Wrapper()->deleteMail( mail ); folderView->refreshCurrent(); } @@ -295,96 +339,98 @@ void OpieMail::slotDeleteAllMail() QValueList<RecMailP> t; if ( QMessageBox::warning(this, i18n("Delete All Mails"), i18n("Do you really want to delete\nall selected mails?" ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { MailListViewItem* item = (MailListViewItem*)mailView->firstChild (); while ( item ) { if ( item->isSelected() ) { t.append( item->data() ); } item = (MailListViewItem*)item->nextSibling(); } } else return; if ( t.count() == 0 ) return; RecMailP mail = t.first(); mail->Wrapper()->deleteMailList(t); folderView->refreshCurrent(); } void OpieMail::clearSelection() { mailView->clearSelection(); } void OpieMail::mailHold(int button, QListViewItem *item,const QPoint&,int ) { if (!mailView->currentItem()) return; MAILLIB::ATYPE mailtype = ((MailListViewItem*)mailView->currentItem() )->wrapperType(); /* just the RIGHT button - or hold on pda */ if (button!=2) {return;} if (!item) return; QPopupMenu *m = new QPopupMenu(0); if (m) { if (mailtype==MAILLIB::A_NNTP) { m->insertItem(i18n("Read this posting"),this,SLOT(displayMail())); m->insertItem(i18n("Copy this posting"),this,SLOT(slotMoveCopyMail())); m->insertSeparator(); m->insertItem(i18n("Copy all selected postings"),this,SLOT(slotMoveCopyAllMail())); m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); } else { if (folderView->currentisDraft()) { m->insertItem(i18n("Edit this mail"),this,SLOT(reEditMail())); } + m->insertItem(i18n("Reply to this mail"),this,SLOT(replyMail())); + m->insertSeparator(); m->insertItem(i18n("Read this mail"),this,SLOT(displayMail())); m->insertItem(i18n("Move/Copy this mail"),this,SLOT(slotMoveCopyMail())); m->insertItem(i18n("Delete this mail"),this,SLOT(slotDeleteMail())); m->insertSeparator(); m->insertItem(i18n("Move/Copy all selected mail"),this,SLOT(slotMoveCopyAllMail())); m->insertItem(i18n("Delete all selected mails"),this,SLOT(slotDeleteAllMail())); m->insertItem(i18n("Clear selection"),this,SLOT(clearSelection())); } m->setFocus(); m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y()) ); delete m; } } void OpieMail::slotShowFolders( bool show ) { if ( show && folderView->isHidden() ) { folderView->show(); } else if ( !show && !folderView->isHidden() ) { folderView->hide(); } } void OpieMail::refreshMailView(const QValueList<RecMailP>&list) { MailListViewItem*item = 0; mailView->clear(); QValueList<RecMailP>::ConstIterator it; for (it = list.begin(); it != list.end();++it) { item = new MailListViewItem(mailView,item); item->storeData((*it)); item->showEntry(); } } void OpieMail::mailLeftClicked( QListViewItem *item ) { mailView->clearSelection(); /* just LEFT button - or tap with stylus on pda */ //if (button!=1) return; if (!item) return; if (folderView->currentisDraft()) { reEditMail(); diff --git a/kmicromail/opiemail.h b/kmicromail/opiemail.h index 9de95f8..44ab1ec 100644 --- a/kmicromail/opiemail.h +++ b/kmicromail/opiemail.h @@ -1,55 +1,56 @@ // CHANGED 2004-09-31 Lutz Rogowski #ifndef OPIEMAIL_H #define OPIEMAIL_H #include "mainwindow.h" #include <libmailwrapper/settings.h> #include <opie2/osmartpointer.h> #include <libmailwrapper/mailtypes.h> class OpieMail : public MainWindow { Q_OBJECT public: OpieMail( QWidget *parent = 0, const char *name = 0 ); virtual ~OpieMail(); static QString appName() { return QString::fromLatin1("kopiemail"); } public slots: virtual void slotwriteMail(const QString&name,const QString&email); virtual void slotwriteMail2(const QString&nameemail); virtual void slotComposeMail(); virtual void slotExtAppHandler(); virtual void appMessage(const QCString &msg, const QByteArray &data); virtual void message(const QCString &msg, const QByteArray &data); protected slots: virtual void slotSendQueued(); virtual void slotSearchMails(); virtual void slotEditSettings(); virtual void slotEditAccounts(); virtual void displayMail(); + virtual void replyMail(); virtual void slotDeleteMail(); virtual void slotGetMail(); virtual void slotGetAllMail(); virtual void slotDeleteAllMail(); virtual void mailHold(int, QListViewItem *,const QPoint&,int); virtual void slotShowFolders( bool show ); virtual void refreshMailView(const QValueList<RecMailP>&); virtual void mailLeftClicked( QListViewItem * ); virtual void slotMoveCopyMail(); virtual void slotMoveCopyAllMail(); virtual void reEditMail(); void clearSelection(); private: QString mPendingEmail; QString mPendingName; QByteArray mPendingData; QCString mPendingMessage; Settings *settings; }; #endif diff --git a/kmicromail/qpe/global.cpp b/kmicromail/qpe/global.cpp index f4c6f60..8314f23 100644 --- a/kmicromail/qpe/global.cpp +++ b/kmicromail/qpe/global.cpp @@ -1,12 +1,14 @@ #include "global.h" - +#include <qstatusbar.h> +QStatusBar* globalSstatusBarMainWindow = 0; namespace Global{ void statusMessage(QString message) { - + if ( globalSstatusBarMainWindow ) + globalSstatusBarMainWindow->message( message,15000 ); qDebug("statusMessage %s ", message.latin1()); } } diff --git a/kmicromail/qpe/qdialog.h b/kmicromail/qpe/qdialog.h index aafdf80..c63133d 100644 --- a/kmicromail/qpe/qdialog.h +++ b/kmicromail/qpe/qdialog.h @@ -1,33 +1,29 @@ #ifndef MINIKDE_KDIALOG_H #ifndef DEFINE_QDIALOG_HACK #define DEFINE_QDIALOG_HACK #warning call of include <qdialog.h> #warning including /usr/local/qt/include/qdialog.h #warning if you get a compiling error #warning please adjust your path here! #include "/usr/local/qt/include/qdialog.h" class QDialog_hacked : public QDialog { //Q__OBJECT public: QDialog_hacked ( QWidget * parent=0, const char * name=0, bool modal=true, WFlags f=0 ); }; #define QDialog QDialog_hacked #endif #else -#warning ****************************************** -#warning ****************************************** -#warning ****************************************** -#warning ****************************************** #warning "/usr/local/qt/include/qdialog.h" for KDialog #include "/usr/local/qt/include/qdialog.h" #endif diff --git a/kmicromail/qpe/qdialog_hacked.cpp b/kmicromail/qpe/qdialog_hacked.cpp index 3669312..0a34cec 100644 --- a/kmicromail/qpe/qdialog_hacked.cpp +++ b/kmicromail/qpe/qdialog_hacked.cpp @@ -1,31 +1,27 @@ #include <qdialog.h> #include <qhbox.h> #include <qpushbutton.h> #include <klocale.h> #ifdef QDialog #undef QDialog #endif QDialog_hacked::QDialog_hacked ( QWidget * parent, const char * name, bool modal, WFlags f ) : QDialog( parent,name,modal, f) { - qDebug("******************** "); - qDebug("******************** "); - qDebug("******************** "); - qDebug("******************** "); - qDebug("New hacked QDialog for ompi "); + qDebug("New hacked QDialog for ompi desktop"); //QTimer::singleShot( 1, this,SLOT(addaddbuttons()) ); setOrientation ( Vertical ); QHBox * hb = new QHBox ( this ); QPushButton *ok = new QPushButton( i18n("OK"), hb ); QPushButton *cancel = new QPushButton( i18n("Cancel"), hb ); setExtension ( hb ); showExtension ( true ); connect ( ok, SIGNAL ( clicked()),this, SLOT (accept() ) ); connect ( cancel, SIGNAL ( clicked()),this, SLOT (reject() ) ); //setWFlags(WStyle_MinMax ); } diff --git a/kmicromail/viewmail.cpp b/kmicromail/viewmail.cpp index f1e0225..2093678 100644 --- a/kmicromail/viewmail.cpp +++ b/kmicromail/viewmail.cpp @@ -53,97 +53,98 @@ AttachItem::AttachItem(QListViewItem * parent,QListViewItem *after, const QStrin _path=path; setText(0, mime); setText(1, desc); setText(2, file); setText(3, fsize); } bool AttachItem::isParentof(const QValueList<int>&path) { /* if not set, then no parent */ if (path.count()==0||_path.count()==0) return false; /* the parent must have one digit less then a child */ if (path.count()!=_path.count()+1) return false; for (unsigned int i=0; i < _path.count();++i) { if (_path[i]!=path[i]) return false; } return true; } AttachItem* ViewMail::searchParent(const QValueList<int>&path) { QListViewItemIterator it( attachments ); for ( ; it.current(); ++it ) { AttachItem*ati = (AttachItem*)it.current(); if (ati->isParentof(path)) return ati; } return 0; } AttachItem* ViewMail::lastChild(AttachItem*parent) { if (!parent) return 0; AttachItem* item = (AttachItem*)parent->firstChild(); if (!item) return item; AttachItem*temp=0; while( (temp=(AttachItem*)item->nextSibling())) { item = temp; } return item; } void ViewMail::setBody(const RecBodyP&body ) { m_body = body; - m_mail[2] = body->Bodytext(); + m_mail[2] = QString::fromUtf8( body->Bodytext().latin1() ); + // qDebug("********text %s ",m_mail[2].latin1() ); attachbutton->setEnabled(body->Parts().count()>0); attachments->setEnabled(body->Parts().count()>0); if (body->Parts().count()==0) { return; } AttachItem * curItem=0; AttachItem * parentItem = 0; QString type=body->Description()->Type()+"/"+body->Description()->Subtype(); QString desc,fsize; double s = body->Description()->Size(); int w; w=0; while (s>1024) { s/=1024; ++w; if (w>=2) break; } QString q=""; switch(w) { case 1: q="k"; break; case 2: q="M"; break; default: break; } { /* I did not found a method to make a CONTENT reset on a QTextStream so I use this construct that the stream will re-constructed in each loop. To let it work, the textstream is packed into a own area of code is it will be destructed after finishing its small job. */ QTextOStream o(&fsize); if (w>0) o.precision(2); else o.precision(0); o.setf(QTextStream::fixed); o << s << " " << q << "Byte"; } curItem=new AttachItem(attachments,curItem,type,"Mailbody","",fsize,-1,body->Description()->Positionlist()); QString filename = ""; @@ -255,264 +256,258 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int } } break ; case 2: { #ifdef DESKTOP_VERSION QString tmpfile = locateLocal( "tmp", "opiemail-image"); #else QString tmpfile = "/tmp/opiemail-image"; #endif encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); if (content) { QFile output(tmpfile); output.open(IO_WriteOnly); output.writeBlock(content->Content(),content->Length()); output.close(); delete content; MailImageDlg iview(""); iview.setName(tmpfile); KApplication::execDialog(&iview); output.remove(); } } break; case 1: if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { setText(); } else { if ( m_recMail->Wrapper() != 0l ) { // make sure that there is a wrapper , even after delete or simular actions browser->setText( m_recMail->Wrapper()->fetchTextPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ) ); } } break; } delete menu; } void ViewMail::setMail(const RecMailP&mail ) { m_recMail = mail; - m_mail[0] = mail->getFrom(); - m_mail[1] = mail->getSubject(); - m_mail[3] = mail->getDate(); - m_mail[4] = mail->Msgid(); + m_mail[0] = QString::fromUtf8( mail->getFrom().latin1() ); + m_mail[1] = QString::fromUtf8( mail->getSubject().latin1() ); + m_mail[3] = QString::fromUtf8( mail->getDate().latin1() ); + m_mail[4] = QString::fromUtf8( mail->Msgid().latin1() ); m_mail2[0] = mail->To(); m_mail2[1] = mail->CC(); m_mail2[2] = mail->Bcc(); setText(); } ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) : ViewMailBase(parent, name, fl), _inLoop(false) { m_gotBody = false; deleted = false; connect( reply, SIGNAL(activated()), SLOT(slotReply())); connect( forward, SIGNAL(activated()), SLOT(slotForward())); connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); connect( closeMail, SIGNAL( activated() ), SLOT( close() ) ); attachments->setEnabled(m_gotBody); connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); readConfig(); attachments->setSorting(-1); } void ViewMail::readConfig() { setFont ( KOPrefs::instance()->mReadFont ); m_showHtml = KOPrefs::instance()->mViewAsHtml; showHtml->setOn( m_showHtml ); } void ViewMail::setText() { QString toString; QString ccString; QString bccString; - for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) - { - toString += (*it); - } - for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) - { - ccString += (*it); - } - for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) - { - bccString += (*it); - } + + toString = QString::fromUtf8(m_mail2[0].join(",").latin1()); + ccString = QString::fromUtf8(m_mail2[1].join(",").latin1()); + bccString = QString::fromUtf8(m_mail2[2].join(",").latin1()); + setCaption( i18n("E-Mail by %1").arg( m_mail[0] ) ); m_mailHtml = "<html><body>" "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" "<b>" + i18n( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" "<b>" + i18n( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + i18n( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" "<b>" + i18n( "Date" ) + ": </b> " + m_mail[3] + "</td></tr></table><font>"; if ( !m_showHtml ) { browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); } else { browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); } // remove later in favor of a real handling m_gotBody = true; } ViewMail::~ViewMail() { m_recMail->Wrapper()->cleanMimeCache(); hide(); } void ViewMail::hide() { QWidget::hide(); if (_inLoop) { _inLoop = false; qApp->exit_loop(); } } void ViewMail::exec() { show(); if (!_inLoop) { _inLoop = true; qApp->enter_loop(); } } QString ViewMail::deHtml(const QString &string) { QString string_ = string; string_.replace(QRegExp("&"), "&"); string_.replace(QRegExp("<"), "<"); string_.replace(QRegExp(">"), ">"); string_.replace(QRegExp("\\n"), "<br>"); return string_; } void ViewMail::slotReply() { if (!m_gotBody) { QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot reply yet."), i18n("Ok")); return; } QString rtext; rtext += QString("* %1 wrote on %2:\n") // no i18n on purpose .arg( m_mail[0] ) .arg( m_mail[3] ); QString text = m_mail[2]; QStringList lines = QStringList::split(QRegExp("\\n"), text); QStringList::Iterator it; for (it = lines.begin(); it != lines.end(); it++) { rtext += "> " + *it + "\n"; } rtext += "\n"; QString prefix; if ( m_mail[1].find(QRegExp("^Re: .*$")) != -1) prefix = ""; else prefix = "Re: "; // no i18n on purpose Settings *settings = new Settings(); ComposeMail composer( settings ,this, 0, true); if (m_recMail->Replyto().isEmpty()) { - composer.setTo( m_recMail->getFrom()); + composer.setTo( QString::fromUtf8( m_recMail->getFrom().latin1())); } else { - composer.setTo( m_recMail->Replyto()); + composer.setTo( QString::fromUtf8( m_recMail->Replyto().latin1())); } composer.setSubject( prefix + m_mail[1] ); composer.setMessage( rtext ); composer.setInReplyTo(m_recMail->Msgid()); if ( QDialog::Accepted == KApplication::execDialog( &composer ) ) { m_recMail->Wrapper()->answeredMail(m_recMail); } + delete settings; } void ViewMail::slotForward() { if (!m_gotBody) { QMessageBox::information(this, i18n("Error"), i18n("<p>The mail body is not yet downloaded, so you cannot forward yet."), i18n("Ok")); return; } QString ftext; ftext += QString("\n----- Forwarded message from %1 -----\n\n") .arg( m_mail[0] ); if (!m_mail[3].isNull()) ftext += QString("Date: %1\n") .arg( m_mail[3] ); if (!m_mail[0].isNull()) ftext += QString("From: %1\n") .arg( m_mail[0] ); if (!m_mail[1].isNull()) ftext += QString("Subject: %1\n") .arg( m_mail[1] ); ftext += QString("\n%1\n") .arg( m_mail[2]); ftext += QString("----- End forwarded message -----\n"); Settings *settings = new Settings(); ComposeMail composer( settings ,this, 0, true); composer.setSubject( "Fwd: " + m_mail[1] ); composer.setMessage( ftext ); if ( QDialog::Accepted == KApplication::execDialog( &composer )) { } } void ViewMail::slotDeleteMail( ) { if ( QMessageBox::warning(this, i18n("Delete Mail"), QString( i18n("<p>Do you really want to delete this mail? <br><br>" ) + m_mail[0] + " - " + m_mail[1] ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { m_recMail->Wrapper()->deleteMail( m_recMail ); hide(); deleted = true; } } MailImageDlg::MailImageDlg(const QString&fname,QWidget *parent, const char *name, bool modal, WFlags f) |