summaryrefslogtreecommitdiff
authoralwin <alwin>2004-01-04 01:59:09 (UTC)
committer alwin <alwin>2004-01-04 01:59:09 (UTC)
commit16d8d88dc09477d871f92d283aa59c8206456a26 (patch) (side-by-side diff)
treef9aa7a7d6861c81535810092eae8a1f93a9d2358
parent6fd109ed595e4e28f49f5de0a26e9f9445e672f6 (diff)
downloadopie-16d8d88dc09477d871f92d283aa59c8206456a26.zip
opie-16d8d88dc09477d871f92d283aa59c8206456a26.tar.gz
opie-16d8d88dc09477d871f92d283aa59c8206456a26.tar.bz2
moved to shared lib
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/genericwrapper.cpp503
-rw-r--r--noncore/net/mail/genericwrapper.h59
-rw-r--r--noncore/net/mail/mailwrapper.cpp137
-rw-r--r--noncore/net/mail/mailwrapper.h92
-rw-r--r--noncore/net/mail/settings.cpp403
-rw-r--r--noncore/net/mail/settings.h146
6 files changed, 0 insertions, 1340 deletions
diff --git a/noncore/net/mail/genericwrapper.cpp b/noncore/net/mail/genericwrapper.cpp
deleted file mode 100644
index 714396b..0000000
--- a/noncore/net/mail/genericwrapper.cpp
+++ b/dev/null
@@ -1,503 +0,0 @@
-#include "genericwrapper.h"
-#include <libetpan/libetpan.h>
-#include "mailtypes.h"
-
-Genericwrapper::Genericwrapper()
- : AbstractMail()
-{
- bodyCache.clear();
-}
-
-Genericwrapper::~Genericwrapper()
-{
- cleanMimeCache();
-}
-
-void Genericwrapper::fillSingleBody(RecPart&target,mailmessage*,mailmime*mime)
-{
- if (!mime) {
- return;
- }
- mailmime_field*field = 0;
- mailmime_single_fields fields;
- memset(&fields, 0, sizeof(struct mailmime_single_fields));
- if (mime->mm_mime_fields != NULL) {
- mailmime_single_fields_init(&fields, mime->mm_mime_fields,
- mime->mm_content_type);
- }
-
- mailmime_content*type = fields.fld_content;
- clistcell*current;
- if (!type) {
- target.setType("text");
- target.setSubtype("plain");
- } else {
- target.setSubtype(type->ct_subtype);
- switch(type->ct_type->tp_data.tp_discrete_type->dt_type) {
- case MAILMIME_DISCRETE_TYPE_TEXT:
- target.setType("text");
- break;
- case MAILMIME_DISCRETE_TYPE_IMAGE:
- target.setType("image");
- break;
- case MAILMIME_DISCRETE_TYPE_AUDIO:
- target.setType("audio");
- break;
- case MAILMIME_DISCRETE_TYPE_VIDEO:
- target.setType("video");
- break;
- case MAILMIME_DISCRETE_TYPE_APPLICATION:
- target.setType("application");
- break;
- case MAILMIME_DISCRETE_TYPE_EXTENSION:
- default:
- if (type->ct_type->tp_data.tp_discrete_type->dt_extension) {
- target.setType(type->ct_type->tp_data.tp_discrete_type->dt_extension);
- }
- break;
- }
- if (type->ct_parameters) {
- fillParameters(target,type->ct_parameters);
- }
- }
- if (mime->mm_mime_fields && mime->mm_mime_fields->fld_list) {
- for (current=clist_begin(mime->mm_mime_fields->fld_list);current!=0;current=clist_next(current)) {
- field = (mailmime_field*)current->data;
- switch(field->fld_type) {
- case MAILMIME_FIELD_TRANSFER_ENCODING:
- target.setEncoding(getencoding(field->fld_data.fld_encoding));
- break;
- case MAILMIME_FIELD_ID:
- target.setIdentifier(field->fld_data.fld_id);
- break;
- case MAILMIME_FIELD_DESCRIPTION:
- target.setDescription(field->fld_data.fld_description);
- break;
- default:
- break;
- }
- }
- }
-}
-
-void Genericwrapper::fillParameters(RecPart&target,clist*parameters)
-{
- if (!parameters) {return;}
- clistcell*current=0;
- mailmime_parameter*param;
- for (current=clist_begin(parameters);current!=0;current=clist_next(current)) {
- param = (mailmime_parameter*)current->data;
- if (param) {
- target.addParameter(QString(param->pa_name).lower(),QString(param->pa_value));
- }
- }
-}
-
-QString Genericwrapper::getencoding(mailmime_mechanism*aEnc)
-{
- QString enc="7bit";
- if (!aEnc) return enc;
- switch(aEnc->enc_type) {
- case MAILMIME_MECHANISM_7BIT:
- enc = "7bit";
- break;
- case MAILMIME_MECHANISM_8BIT:
- enc = "8bit";
- break;
- case MAILMIME_MECHANISM_BINARY:
- enc = "binary";
- break;
- case MAILMIME_MECHANISM_QUOTED_PRINTABLE:
- enc = "quoted-printable";
- break;
- case MAILMIME_MECHANISM_BASE64:
- enc = "base64";
- break;
- case MAILMIME_MECHANISM_TOKEN:
- default:
- if (aEnc->enc_token) {
- enc = QString(aEnc->enc_token);
- }
- break;
- }
- return enc;
-}
-
-void Genericwrapper::traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rec,int current_count)
-{
- if (current_rec >= 10) {
- qDebug("too deep recursion!");
- }
- if (!message || !mime) {
- return;
- }
- int r;
- char*data = 0;
- size_t len;
- clistiter * cur = 0;
- QString b;
- RecPart part;
-
- switch (mime->mm_type) {
- case MAILMIME_SINGLE:
- {
- QValueList<int>countlist = recList;
- countlist.append(current_count);
- r = mailmessage_fetch_section(message,mime,&data,&len);
- part.setSize(len);
- part.setPositionlist(countlist);
- b = gen_attachment_id();
- part.setIdentifier(b);
- fillSingleBody(part,message,mime);
- if (part.Type()=="text" && target.Bodytext().isNull()) {
- encodedString*r = new encodedString();
- r->setContent(data,len);
- encodedString*res = decode_String(r,part.Encoding());
- if (countlist.count()>2) {
- bodyCache[b]=r;
- target.addPart(part);
- } else {
- delete r;
- }
- b = QString(res->Content());
- delete res;
- target.setBodytext(b);
- target.setDescription(part);
- } else {
- bodyCache[b]=new encodedString(data,len);
- target.addPart(part);
- }
- }
- break;
- case MAILMIME_MULTIPLE:
- {
- unsigned int ccount = 1;
- mailmime*cbody=0;
- QValueList<int>countlist = recList;
- for (cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) {
- cbody = (mailmime*)clist_content(cur);
- if (cbody->mm_type==MAILMIME_MULTIPLE) {
- RecPart targetPart;
- targetPart.setType("multipart");
- countlist.append(current_count);
- targetPart.setPositionlist(countlist);
- target.addPart(targetPart);
- }
- traverseBody(target,message, cbody,countlist,current_rec+1,ccount);
- if (cbody->mm_type==MAILMIME_MULTIPLE) {
- countlist = recList;
- }
- ++ccount;
- }
- }
- break;
- case MAILMIME_MESSAGE:
- {
- QValueList<int>countlist = recList;
- countlist.append(current_count);
- /* the own header is always at recursion 0 - we don't need that */
- if (current_rec > 0) {
- part.setPositionlist(countlist);
- r = mailmessage_fetch_section(message,mime,&data,&len);
- part.setSize(len);
- part.setPositionlist(countlist);
- b = gen_attachment_id();
- part.setIdentifier(b);
- part.setType("message");
- part.setSubtype("rfc822");
- bodyCache[b]=new encodedString(data,len);
- target.addPart(part);
- }
- if (mime->mm_data.mm_message.mm_msg_mime != NULL) {
- traverseBody(target,message,mime->mm_data.mm_message.mm_msg_mime,countlist,current_rec+1);
- }
- }
- break;
- }
-}
-
-RecBody Genericwrapper::parseMail( mailmessage * msg )
-{
- int err = MAILIMF_NO_ERROR;
- mailmime_single_fields fields;
- /* is bound to msg and will be freed there */
- mailmime * mime=0;
- RecBody body;
- memset(&fields, 0, sizeof(struct mailmime_single_fields));
- err = mailmessage_get_bodystructure(msg,&mime);
- QValueList<int>recList;
- traverseBody(body,msg,mime,recList);
- return body;
-}
-
-RecMail *Genericwrapper::parseHeader( const char *header )
-{
- int err = MAILIMF_NO_ERROR;
- size_t curTok = 0;
- RecMail *mail = new RecMail();
- mailimf_fields *fields = 0;
- mailimf_references * refs = 0;
- mailimf_keywords*keys = 0;
- QString status;
- QString value;
- QBitArray mFlags(7);
-
- err = mailimf_fields_parse( (char *) header, strlen( header ), &curTok, &fields );
- for ( clistiter *current = clist_begin( fields->fld_list ); current != NULL; current = current->next ) {
- mailimf_field *field = (mailimf_field *) current->data;
- switch ( field->fld_type ) {
- case MAILIMF_FIELD_FROM:
- mail->setFrom( parseMailboxList( field->fld_data.fld_from->frm_mb_list ) );
- break;
- case MAILIMF_FIELD_TO:
- mail->setTo( parseAddressList( field->fld_data.fld_to->to_addr_list ) );
- break;
- case MAILIMF_FIELD_CC:
- mail->setCC( parseAddressList( field->fld_data.fld_cc->cc_addr_list ) );
- break;
- case MAILIMF_FIELD_BCC:
- mail->setBcc( parseAddressList( field->fld_data.fld_bcc->bcc_addr_list ) );
- break;
- case MAILIMF_FIELD_SUBJECT:
- mail->setSubject(convert_String( field->fld_data.fld_subject->sbj_value ) );
- break;
- case MAILIMF_FIELD_ORIG_DATE:
- mail->setDate( parseDateTime( field->fld_data.fld_orig_date->dt_date_time ) );
- break;
- case MAILIMF_FIELD_MESSAGE_ID:
- mail->setMsgid(QString(field->fld_data.fld_message_id->mid_value));
- break;
- case MAILIMF_FIELD_REFERENCES:
- refs = field->fld_data.fld_references;
- if (refs && refs->mid_list && clist_count(refs->mid_list)) {
- char * text = (char*)refs->mid_list->first->data;
- mail->setReplyto(QString(text));
- }
- break;
- case MAILIMF_FIELD_KEYWORDS:
- keys = field->fld_data.fld_keywords;
- for (clistcell*cur = clist_begin(keys->kw_list);cur!=0;cur=clist_next(cur)) {
- qDebug("Keyword: %s",(char*)cur->data);
- }
- break;
- case MAILIMF_FIELD_OPTIONAL_FIELD:
- status = field->fld_data.fld_optional_field->fld_name;
- value = field->fld_data.fld_optional_field->fld_value;
- if (status.lower()=="status") {
- if (value.lower()=="ro") {
- mFlags.setBit(FLAG_SEEN);
- }
- } else if (status.lower()=="x-status") {
- qDebug("X-Status: %s",value.latin1());
- if (value.lower()=="a") {
- mFlags.setBit(FLAG_ANSWERED);
- }
- } else {
-// qDebug("Optionales feld: %s -> %s)",field->fld_data.fld_optional_field->fld_name,
-// field->fld_data.fld_optional_field->fld_value);
- }
- break;
- default:
- qDebug("Non parsed field");
- break;
- }
- }
- if (fields) mailimf_fields_free(fields);
- mail->setFlags(mFlags);
- return mail;
-}
-
-QString Genericwrapper::parseDateTime( mailimf_date_time *date )
-{
- char tmp[23];
-
- snprintf( tmp, 23, "%02i.%02i.%04i %02i:%02i:%02i %+05i",
- date->dt_day, date->dt_month, date->dt_year, date->dt_hour, date->dt_min, date->dt_sec, date->dt_zone );
-
- return QString( tmp );
-}
-
-QString Genericwrapper::parseAddressList( mailimf_address_list *list )
-{
- QString result( "" );
-
- bool first = true;
- if (list == 0) return result;
- for ( clistiter *current = clist_begin( list->ad_list ); current != NULL; current = current->next ) {
- mailimf_address *addr = (mailimf_address *) current->data;
-
- if ( !first ) {
- result.append( "," );
- } else {
- first = false;
- }
-
- switch ( addr->ad_type ) {
- case MAILIMF_ADDRESS_MAILBOX:
- result.append( parseMailbox( addr->ad_data.ad_mailbox ) );
- break;
- case MAILIMF_ADDRESS_GROUP:
- result.append( parseGroup( addr->ad_data.ad_group ) );
- break;
- default:
- qDebug( "Generic: unkown mailimf address type" );
- break;
- }
- }
-
- return result;
-}
-
-QString Genericwrapper::parseGroup( mailimf_group *group )
-{
- QString result( "" );
-
- result.append( group->grp_display_name );
- result.append( ": " );
-
- if ( group->grp_mb_list != NULL ) {
- result.append( parseMailboxList( group->grp_mb_list ) );
- }
-
- result.append( ";" );
-
- return result;
-}
-
-QString Genericwrapper::parseMailbox( mailimf_mailbox *box )
-{
- QString result( "" );
-
- if ( box->mb_display_name == NULL ) {
- result.append( box->mb_addr_spec );
- } else {
- result.append( convert_String(box->mb_display_name).latin1() );
- result.append( " <" );
- result.append( box->mb_addr_spec );
- result.append( ">" );
- }
-
- return result;
-}
-
-QString Genericwrapper::parseMailboxList( mailimf_mailbox_list *list )
-{
- QString result( "" );
-
- bool first = true;
- for ( clistiter *current = clist_begin( list->mb_list ); current != NULL; current = current->next ) {
- mailimf_mailbox *box = (mailimf_mailbox *) current->data;
-
- if ( !first ) {
- result.append( "," );
- } else {
- first = false;
- }
-
- result.append( parseMailbox( box ) );
- }
-
- return result;
-}
-
-encodedString* Genericwrapper::fetchDecodedPart(const RecMail&,const RecPart&part)
-{
- QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
- if (it==bodyCache.end()) return new encodedString();
- encodedString*t = decode_String(it.data(),part.Encoding());
- return t;
-}
-
-encodedString* Genericwrapper::fetchRawPart(const RecMail&mail,const RecPart&part)
-{
- QMap<QString,encodedString*>::ConstIterator it = bodyCache.find(part.Identifier());
- if (it==bodyCache.end()) return new encodedString();
- encodedString*t = it.data();
- return t;
-}
-
-QString Genericwrapper::fetchTextPart(const RecMail&mail,const RecPart&part)
-{
- encodedString*t = fetchDecodedPart(mail,part);
- QString text=t->Content();
- delete t;
- return text;
-}
-
-void Genericwrapper::cleanMimeCache()
-{
- QMap<QString,encodedString*>::Iterator it = bodyCache.begin();
- for (;it!=bodyCache.end();++it) {
- encodedString*t = it.data();
- //it.setValue(0);
- if (t) delete t;
- }
- bodyCache.clear();
- qDebug("Genericwrapper: cache cleaned");
-}
-
-void Genericwrapper::parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox)
-{
- int r;
- mailmessage_list * env_list = 0;
- r = mailsession_get_messages_list(session,&env_list);
- if (r != MAIL_NO_ERROR) {
- qDebug("Error message list");
- return;
- }
- r = mailsession_get_envelopes_list(session, env_list);
- if (r != MAIL_NO_ERROR) {
- qDebug("Error filling message list");
- if (env_list) {
- mailmessage_list_free(env_list);
- }
- return;
- }
- mailimf_references * refs;
- uint32_t i = 0;
- for(; i < carray_count(env_list->msg_tab) ; ++i) {
- mailmessage * msg;
- QBitArray mFlags(7);
- msg = (mailmessage*)carray_get(env_list->msg_tab, i);
- if (msg->msg_fields == NULL) {
- qDebug("could not fetch envelope of message %i", i);
- continue;
- }
- RecMail * mail = new RecMail();
- mail->setWrapper(this);
- mail_flags * flag_result = 0;
- r = mailmessage_get_flags(msg,&flag_result);
- if (r == MAIL_ERROR_NOT_IMPLEMENTED) {
- mFlags.setBit(FLAG_SEEN);
- }
- mailimf_single_fields single_fields;
- mailimf_single_fields_init(&single_fields, msg->msg_fields);
- mail->setMsgsize(msg->msg_size);
- mail->setFlags(mFlags);
- mail->setMbox(mailbox);
- mail->setNumber(msg->msg_index);
- if (single_fields.fld_subject)
- mail->setSubject( convert_String(single_fields.fld_subject->sbj_value));
- if (single_fields.fld_from)
- mail->setFrom(parseMailboxList(single_fields.fld_from->frm_mb_list));
- if (single_fields.fld_to)
- mail->setTo( parseAddressList( single_fields.fld_to->to_addr_list ) );
- if (single_fields.fld_cc)
- mail->setCC( parseAddressList( single_fields.fld_cc->cc_addr_list ) );
- if (single_fields.fld_bcc)
- mail->setBcc( parseAddressList( single_fields.fld_bcc->bcc_addr_list ) );
- if (single_fields.fld_orig_date)
- mail->setDate( parseDateTime( single_fields.fld_orig_date->dt_date_time ) );
- if (single_fields.fld_message_id->mid_value)
- mail->setMsgid(QString(single_fields.fld_message_id->mid_value));
- refs = single_fields.fld_references;
- if (refs && refs->mid_list && clist_count(refs->mid_list)) {
- char * text = (char*)refs->mid_list->first->data;
- mail->setReplyto(QString(text));
- }
- target.append(mail);
- }
- if (env_list) {
- mailmessage_list_free(env_list);
- }
-}
diff --git a/noncore/net/mail/genericwrapper.h b/noncore/net/mail/genericwrapper.h
deleted file mode 100644
index 32b75c8..0000000
--- a/noncore/net/mail/genericwrapper.h
+++ b/dev/null
@@ -1,59 +0,0 @@
-#ifndef __GENERIC_WRAPPER_H
-#define __GENERIC_WRAPPER_H
-
-#include "abstractmail.h"
-#include <qmap.h>
-#include <qstring.h>
-#include <libetpan/clist.h>
-
-class RecMail;
-class RecBody;
-class encodedString;
-struct mailpop3;
-struct mailmessage;
-struct mailmime;
-struct mailmime_mechanism;
-struct mailimf_mailbox_list;
-struct mailimf_mailbox;
-struct mailimf_date_time;
-struct mailimf_group;
-struct mailimf_address_list;
-struct mailsession;
-
-/* this class hold just the funs shared between
- * mbox and pop3 (later mh, too) mail access.
- * it is not desigend to make a instance of it!
- */
-class Genericwrapper : public AbstractMail
-{
- Q_OBJECT
-public:
- Genericwrapper();
- virtual ~Genericwrapper();
-
- virtual encodedString* fetchDecodedPart(const RecMail&mail,const RecPart&part);
- virtual encodedString* fetchRawPart(const RecMail&mail,const RecPart&part);
- virtual QString fetchTextPart(const RecMail&mail,const RecPart&part);
- virtual void cleanMimeCache();
-
-protected:
- RecMail *parseHeader( const char *header );
- RecBody parseMail( mailmessage * msg );
- QString parseMailboxList( mailimf_mailbox_list *list );
- QString parseMailbox( mailimf_mailbox *box );
- QString parseGroup( mailimf_group *group );
- QString parseAddressList( mailimf_address_list *list );
- QString parseDateTime( mailimf_date_time *date );
-
- void traverseBody(RecBody&target,mailmessage*message,mailmime*mime,QValueList<int>recList,unsigned int current_rek=0,int current_count=1);
- static void fillSingleBody(RecPart&target,mailmessage*message,mailmime*mime);
- static void fillParameters(RecPart&target,clist*parameters);
- static QString getencoding(mailmime_mechanism*aEnc);
- virtual void parseList(QList<RecMail> &target,mailsession*session,const QString&mailbox);
-
- QString msgTempName;
- unsigned int last_msg_id;
- QMap<QString,encodedString*> bodyCache;
-};
-
-#endif
diff --git a/noncore/net/mail/mailwrapper.cpp b/noncore/net/mail/mailwrapper.cpp
deleted file mode 100644
index 9398823..0000000
--- a/noncore/net/mail/mailwrapper.cpp
+++ b/dev/null
@@ -1,137 +0,0 @@
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <qdir.h>
-
-#include "mailwrapper.h"
-#include "logindialog.h"
-#include "defines.h"
-
-Attachment::Attachment( DocLnk lnk )
-{
- doc = lnk;
- size = QFileInfo( doc.file() ).size();
-}
-
-Folder::Folder(const QString&tmp_name, const QString&sep )
-{
- name = tmp_name;
- nameDisplay = name;
- separator = sep;
-}
-
-const QString& Folder::Separator()const
-{
- return separator;
-}
-
-IMAPFolder::IMAPFolder(const QString&name,const QString&sep, bool select,bool no_inf, const QString&prefix )
- : Folder( name,sep ),m_MaySelect(select),m_NoInferior(no_inf)
-{
- // Decode IMAP foldername
- nameDisplay = IMAPFolder::decodeFolderName( name );
- qDebug( "folder " + name + " - displayed as " + nameDisplay );
-
- if (prefix.length()>0) {
- if (nameDisplay.startsWith(prefix) && nameDisplay.length()>prefix.length()) {
- nameDisplay=nameDisplay.right(nameDisplay.length()-prefix.length());
- }
- }
-}
-
-static unsigned char base64chars[] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
-
-/**
- * Decodes base64 encoded parts of the imapfolder name
- * Code taken from kde cvs: kdebase/kioslave/imap4/rfcdecoder.cc
- */
-QString IMAPFolder::decodeFolderName( const QString &name )
-{
- unsigned char c, i, bitcount;
- unsigned long ucs4, utf16, bitbuf;
- unsigned char base64[256], utf8[6];
- unsigned long srcPtr = 0;
- QCString dst = "";
- QCString src = name.ascii();
-
- /* initialize modified base64 decoding table */
- memset(base64, UNDEFINED, sizeof(base64));
- for (i = 0; i < sizeof(base64chars); ++i) {
- base64[(int)base64chars[i]] = i;
- }
-
- /* loop until end of string */
- while (srcPtr < src.length ()) {
- c = src[srcPtr++];
- /* deal with literal characters and &- */
- if (c != '&' || src[srcPtr] == '-') {
- /* encode literally */
- dst += c;
- /* skip over the '-' if this is an &- sequence */
- if (c == '&')
- srcPtr++;
- } else {
- /* convert modified UTF-7 -> UTF-16 -> UCS-4 -> UTF-8 -> HEX */
- bitbuf = 0;
- bitcount = 0;
- ucs4 = 0;
- while ((c = base64[(unsigned char) src[srcPtr]]) != UNDEFINED) {
- ++srcPtr;
- bitbuf = (bitbuf << 6) | c;
- bitcount += 6;
- /* enough bits for a UTF-16 character? */
- if (bitcount >= 16) {
- bitcount -= 16;
- utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff;
- /* convert UTF16 to UCS4 */
- if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) {
- ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT;
- continue;
- } else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) {
- ucs4 += utf16 - UTF16LOSTART + UTF16BASE;
- } else {
- ucs4 = utf16;
- }
- /* convert UTF-16 range of UCS4 to UTF-8 */
- if (ucs4 <= 0x7fUL) {
- utf8[0] = ucs4;
- i = 1;
- } else if (ucs4 <= 0x7ffUL) {
- utf8[0] = 0xc0 | (ucs4 >> 6);
- utf8[1] = 0x80 | (ucs4 & 0x3f);
- i = 2;
- } else if (ucs4 <= 0xffffUL) {
- utf8[0] = 0xe0 | (ucs4 >> 12);
- utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f);
- utf8[2] = 0x80 | (ucs4 & 0x3f);
- i = 3;
- } else {
- utf8[0] = 0xf0 | (ucs4 >> 18);
- utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f);
- utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f);
- utf8[3] = 0x80 | (ucs4 & 0x3f);
- i = 4;
- }
- /* copy it */
- for (c = 0; c < i; ++c) {
- dst += utf8[c];
- }
- }
- }
- /* skip over trailing '-' in modified UTF-7 encoding */
- if (src[srcPtr] == '-')
- ++srcPtr;
- }
- }
-
- return QString::fromUtf8( dst.data() );
-}
-
-Mail::Mail()
- :name(""), mail(""), to(""), cc(""), bcc(""), reply(""), subject(""), message("")
-{
-}
diff --git a/noncore/net/mail/mailwrapper.h b/noncore/net/mail/mailwrapper.h
deleted file mode 100644
index a60777d..0000000
--- a/noncore/net/mail/mailwrapper.h
+++ b/dev/null
@@ -1,92 +0,0 @@
-#ifndef MAILWRAPPER_H
-#define MAILWRAPPER_H
-
-#include <qpe/applnk.h>
-
-#include <qbitarray.h>
-#include <qdatetime.h>
-
-#include "settings.h"
-
-class Attachment
-{
-public:
- Attachment( DocLnk lnk );
- virtual ~Attachment(){}
- const QString getFileName()const{ return doc.file(); }
- const QString getName()const{ return doc.name(); }
- const QString getMimeType()const{ return doc.type(); }
- const QPixmap getPixmap()const{ return doc.pixmap(); }
- const int getSize()const { return size; }
- DocLnk getDocLnk() { return doc; }
-
-protected:
- DocLnk doc;
- int size;
-
-};
-
-class Mail
-{
-public:
- Mail();
- /* Possible that this destructor must not be declared virtual
- * 'cause it seems that it will never have some child classes.
- * in this case this object will not get a virtual table -> memory and
- * speed will be a little bit better?
- */
- virtual ~Mail(){}
- void addAttachment( Attachment *att ) { attList.append( att ); }
- const QList<Attachment>& getAttachments()const { return attList; }
- void removeAttachment( Attachment *att ) { attList.remove( att ); }
- const QString&getName()const { return name; }
- void setName( QString s ) { name = s; }
- const QString&getMail()const{ return mail; }
- void setMail( const QString&s ) { mail = s; }
- const QString&getTo()const{ return to; }
- void setTo( const QString&s ) { to = s; }
- const QString&getCC()const{ return cc; }
- void setCC( const QString&s ) { cc = s; }
- const QString&getBCC()const { return bcc; }
- void setBCC( const QString&s ) { bcc = s; }
- const QString&getMessage()const { return message; }
- void setMessage( const QString&s ) { message = s; }
- const QString&getSubject()const { return subject; }
- void setSubject( const QString&s ) { subject = s; }
- const QString&getReply()const{ return reply; }
- void setReply( const QString&a ) { reply = a; }
-
-private:
- QList<Attachment> attList;
- QString name, mail, to, cc, bcc, reply, subject, message;
-};
-
-class Folder : public QObject
-{
- Q_OBJECT
-
-public:
- Folder( const QString&init_name,const QString&sep );
- const QString&getDisplayName()const { return nameDisplay; }
- const QString&getName()const { return name; }
- virtual bool may_select()const{return true;}
- virtual bool no_inferior()const{return true;}
- const QString&Separator()const;
-
-protected:
- QString nameDisplay, name, separator;
-
-};
-
-class IMAPFolder : public Folder
-{
- public:
- IMAPFolder(const QString&name, const QString&sep, bool select=true,bool noinf=false,const QString&prefix="" );
- virtual bool may_select()const{return m_MaySelect;}
- virtual bool no_inferior()const{return m_NoInferior;}
- private:
- static QString decodeFolderName( const QString &name );
- bool m_MaySelect,m_NoInferior;
-};
-
-#endif
diff --git a/noncore/net/mail/settings.cpp b/noncore/net/mail/settings.cpp
deleted file mode 100644
index 17aa1b0..0000000
--- a/noncore/net/mail/settings.cpp
+++ b/dev/null
@@ -1,403 +0,0 @@
-#include <stdlib.h>
-#include <qdir.h>
-
-#include <qpe/config.h>
-
-#include "settings.h"
-#include "defines.h"
-
-Settings::Settings()
- : QObject()
-{
- updateAccounts();
-}
-
-void Settings::checkDirectory()
-{
- 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( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
- QStringList::Iterator it;
-
- QStringList imap = dir.entryList( "imap-*" );
- for ( it = imap.begin(); it != imap.end(); it++ ) {
- qDebug( "Added IMAP account" );
- IMAPaccount *account = new IMAPaccount( (*it).replace(0, 5, "") );
- accounts.append( account );
- }
-
- QStringList pop3 = dir.entryList( "pop3-*" );
- for ( it = pop3.begin(); it != pop3.end(); it++ ) {
- qDebug( "Added POP account" );
- POP3account *account = new POP3account( (*it).replace(0, 5, "") );
- accounts.append( account );
- }
-
- QStringList smtp = dir.entryList( "smtp-*" );
- for ( it = smtp.begin(); it != smtp.end(); it++ ) {
- qDebug( "Added SMTP account" );
- SMTPaccount *account = new SMTPaccount( (*it).replace(0, 5, "") );
- accounts.append( account );
- }
-
- QStringList nntp = dir.entryList( "nntp-*" );
- for ( it = nntp.begin(); it != nntp.end(); it++ ) {
- qDebug( "Added NNTP account" );
- NNTPaccount *account = new NNTPaccount( (*it).replace(0, 5, "") );
- accounts.append( account );
- }
-
- readAccounts();
-}
-
-void Settings::saveAccounts()
-{
- checkDirectory();
- Account *it;
-
- for ( it = accounts.first(); it; it = accounts.next() ) {
- it->save();
- }
-}
-
-void Settings::readAccounts()
-{
- checkDirectory();
- Account *it;
-
- for ( it = accounts.first(); it; it = accounts.next() ) {
- it->read();
- }
-}
-
-Account::Account()
-{
- accountName = "changeMe";
- type = "changeMe";
- ssl = false;
-}
-
-void Account::remove()
-{
- QFile file( getFileName() );
- file.remove();
-}
-
-IMAPaccount::IMAPaccount()
- : Account()
-{
- file = IMAPaccount::getUniqueFileName();
- accountName = "New IMAP Account";
- ssl = false;
- type = "IMAP";
- port = IMAP_PORT;
-}
-
-IMAPaccount::IMAPaccount( QString filename )
- : Account()
-{
- file = filename;
- accountName = "New IMAP Account";
- ssl = false;
- type = "IMAP";
- port = IMAP_PORT;
-}
-
-QString IMAPaccount::getUniqueFileName()
-{
- int num = 0;
- QString unique;
-
- QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
-
- QStringList imap = dir.entryList( "imap-*" );
- do {
- unique.setNum( num++ );
- } while ( imap.contains( "imap-" + unique ) > 0 );
-
- return unique;
-}
-
-void IMAPaccount::read()
-{
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "IMAP Account" );
- accountName = conf->readEntry( "Account","" );
- if (accountName.isNull()) accountName = "";
- server = conf->readEntry( "Server","" );
- if (server.isNull()) server="";
- port = conf->readEntry( "Port","" );
- if (port.isNull()) port="143";
- ssl = conf->readBoolEntry( "SSL",false );
- user = conf->readEntry( "User","" );
- if (user.isNull()) user = "";
- password = conf->readEntryCrypt( "Password","" );
- if (password.isNull()) password = "";
- prefix = conf->readEntry("MailPrefix","");
- if (prefix.isNull()) prefix = "";
-}
-
-void IMAPaccount::save()
-{
- qDebug( "saving " + getFileName() );
- Settings::checkDirectory();
-
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "IMAP Account" );
- conf->writeEntry( "Account", accountName );
- conf->writeEntry( "Server", server );
- conf->writeEntry( "Port", port );
- conf->writeEntry( "SSL", ssl );
- conf->writeEntry( "User", user );
- conf->writeEntryCrypt( "Password", password );
- conf->writeEntry( "MailPrefix",prefix);
- conf->write();
-}
-
-
-QString IMAPaccount::getFileName()
-{
- return (QString) getenv( "HOME" ) + "/Applications/opiemail/imap-" + file;
-}
-
-POP3account::POP3account()
- : Account()
-{
- file = POP3account::getUniqueFileName();
- accountName = "New POP3 Account";
- ssl = false;
- type = "POP3";
- port = POP3_PORT;
-}
-
-POP3account::POP3account( QString filename )
- : Account()
-{
- file = filename;
- accountName = "New POP3 Account";
- ssl = false;
- type = "POP3";
- port = POP3_PORT;
-}
-
-QString POP3account::getUniqueFileName()
-{
- int num = 0;
- QString unique;
-
- QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
-
- QStringList imap = dir.entryList( "pop3-*" );
- do {
- unique.setNum( num++ );
- } while ( imap.contains( "pop3-" + unique ) > 0 );
-
- return unique;
-}
-
-void POP3account::read()
-{
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "POP3 Account" );
- accountName = conf->readEntry( "Account" );
- server = conf->readEntry( "Server" );
- port = conf->readEntry( "Port" );
- ssl = conf->readBoolEntry( "SSL" );
- user = conf->readEntry( "User" );
- password = conf->readEntryCrypt( "Password" );
-}
-
-void POP3account::save()
-{
- qDebug( "saving " + getFileName() );
- Settings::checkDirectory();
-
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "POP3 Account" );
- conf->writeEntry( "Account", accountName );
- conf->writeEntry( "Server", server );
- conf->writeEntry( "Port", port );
- conf->writeEntry( "SSL", ssl );
- conf->writeEntry( "User", user );
- conf->writeEntryCrypt( "Password", password );
- conf->write();
-}
-
-
-QString POP3account::getFileName()
-{
- return (QString) getenv( "HOME" ) + "/Applications/opiemail/pop3-" + file;
-}
-
-SMTPaccount::SMTPaccount()
- : Account()
-{
- file = SMTPaccount::getUniqueFileName();
- accountName = "New SMTP Account";
- ssl = false;
- login = false;
- useCC = false;
- useBCC = false;
- useReply = false;
- type = "SMTP";
- port = SMTP_PORT;
-}
-
-SMTPaccount::SMTPaccount( QString filename )
- : Account()
-{
- file = filename;
- accountName = "New SMTP Account";
- ssl = false;
- login = false;
- type = "SMTP";
- port = SMTP_PORT;
-}
-
-QString SMTPaccount::getUniqueFileName()
-{
- int num = 0;
- QString unique;
-
- QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
-
- QStringList imap = dir.entryList( "smtp-*" );
- do {
- unique.setNum( num++ );
- } while ( imap.contains( "smtp-" + unique ) > 0 );
-
- return unique;
-}
-
-void SMTPaccount::read()
-{
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "SMTP Account" );
- accountName = conf->readEntry( "Account" );
- server = conf->readEntry( "Server" );
- port = conf->readEntry( "Port" );
- ssl = conf->readBoolEntry( "SSL" );
- login = conf->readBoolEntry( "Login" );
- user = conf->readEntry( "User" );
- password = conf->readEntryCrypt( "Password" );
-}
-
-void SMTPaccount::save()
-{
- qDebug( "saving " + getFileName() );
- Settings::checkDirectory();
-
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "SMTP Account" );
- conf->writeEntry( "Account", accountName );
- conf->writeEntry( "Server", server );
- conf->writeEntry( "Port", port );
- conf->writeEntry( "SSL", ssl );
- conf->writeEntry( "Login", login );
- conf->writeEntry( "User", user );
- conf->writeEntryCrypt( "Password", password );
- conf->write();
-}
-
-
-QString SMTPaccount::getFileName()
-{
- return (QString) getenv( "HOME" ) + "/Applications/opiemail/smtp-" + file;
-}
-
-NNTPaccount::NNTPaccount()
- : Account()
-{
- file = NNTPaccount::getUniqueFileName();
- accountName = "New NNTP Account";
- ssl = false;
- login = false;
- type = "NNTP";
- port = NNTP_PORT;
-}
-
-NNTPaccount::NNTPaccount( QString filename )
- : Account()
-{
- file = filename;
- accountName = "New NNTP Account";
- ssl = false;
- login = false;
- type = "NNTP";
- port = NNTP_PORT;
-}
-
-QString NNTPaccount::getUniqueFileName()
-{
- int num = 0;
- QString unique;
-
- QDir dir( (QString) getenv( "HOME" ) + "/Applications/opiemail" );
-
- QStringList imap = dir.entryList( "nntp-*" );
- do {
- unique.setNum( num++ );
- } while ( imap.contains( "nntp-" + unique ) > 0 );
-
- return unique;
-}
-
-void NNTPaccount::read()
-{
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "NNTP Account" );
- accountName = conf->readEntry( "Account" );
- server = conf->readEntry( "Server" );
- port = conf->readEntry( "Port" );
- ssl = conf->readBoolEntry( "SSL" );
- login = conf->readBoolEntry( "Login" );
- user = conf->readEntry( "User" );
- password = conf->readEntryCrypt( "Password" );
-}
-
-void NNTPaccount::save()
-{
- qDebug( "saving " + getFileName() );
- Settings::checkDirectory();
-
- Config *conf = new Config( getFileName(), Config::File );
- conf->setGroup( "NNTP Account" );
- conf->writeEntry( "Account", accountName );
- conf->writeEntry( "Server", server );
- conf->writeEntry( "Port", port );
- conf->writeEntry( "SSL", ssl );
- conf->writeEntry( "Login", login );
- conf->writeEntry( "User", user );
- conf->writeEntryCrypt( "Password", password );
- conf->write();
-}
-
-
-QString NNTPaccount::getFileName()
-{
- return (QString) getenv( "HOME" ) + "/Applications/opiemail/nntp-" + file;
-}
-
diff --git a/noncore/net/mail/settings.h b/noncore/net/mail/settings.h
deleted file mode 100644
index caa5dfc..0000000
--- a/noncore/net/mail/settings.h
+++ b/dev/null
@@ -1,146 +0,0 @@
-#ifndef SETTINGS_H
-#define SETTINGS_H
-
-#include <qobject.h>
-#include <qlist.h>
-
-class Account
-{
-
-public:
- Account();
- virtual ~Account() {}
-
- void remove();
- void setAccountName( QString name ) { accountName = name; }
- const QString&getAccountName()const{ return accountName; }
- const QString&getType()const{ return type; }
-
- void setServer(const QString&str){ server = str; }
- const QString&getServer()const{ return server; }
-
- void setPort(const QString&str) { port = str; }
- const QString&getPort()const{ return port; }
-
- void setUser(const QString&str){ user = str; }
- const QString&getUser()const{ return user; }
-
- void setPassword(const QString&str) { password = str; }
- const QString&getPassword()const { return password; }
-
- void setSSL( bool b ) { ssl = b; }
- bool getSSL() { return ssl; }
-
- virtual QString getFileName() { return accountName; }
- virtual void read() { qDebug( "base reading..." ); }
- virtual void save() { qDebug( "base saving..." ); }
-
-protected:
- QString accountName, type, server, port, user, password;
- bool ssl;
-
-};
-
-class IMAPaccount : public Account
-{
-
-public:
- IMAPaccount();
- IMAPaccount( QString filename );
-
- static QString getUniqueFileName();
-
- virtual void read();
- virtual void save();
- virtual QString getFileName();
-
- void setPrefix(const QString&str) {prefix=str;}
- const QString&getPrefix()const{return prefix;}
-
-private:
- QString file,prefix;
-
-};
-
-class POP3account : public Account
-{
-
-public:
- POP3account();
- POP3account( QString filename );
-
- static QString getUniqueFileName();
-
- virtual void read();
- virtual void save();
- virtual QString getFileName();
-
-private:
- QString file;
-
-};
-
-class SMTPaccount : public Account
-{
-
-public:
- SMTPaccount();
- SMTPaccount( QString filename );
-
- 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; }
-
-private:
- QString file;
- bool login;
-
-};
-
-class Settings : public QObject
-{
- Q_OBJECT
-
-public:
- 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