-rw-r--r-- | noncore/net/mail/opiemail.cpp | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index b153292..5654476 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp | |||
@@ -14,25 +14,110 @@ | |||
14 | /* OPIE */ | 14 | /* OPIE */ |
15 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
18 | 18 | ||
19 | /* QT */ | 19 | /* QT */ |
20 | #include <qmap.h> | ||
21 | #include <qvaluelist.h> | ||
20 | 22 | ||
21 | /* UNIX */ | 23 | /* UNIX */ |
22 | #include <signal.h> | 24 | #include <signal.h> |
23 | 25 | ||
24 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
25 | 27 | ||
28 | typedef QMapNode<QString,QString> tkeyvalues; | ||
29 | typedef QValueList<tkeyvalues> tvaluelist; | ||
30 | |||
31 | class ValueExplode | ||
32 | { | ||
33 | protected: | ||
34 | //! what was parsed last | ||
35 | tvaluelist m_LastParsed; | ||
36 | //! the delemiter to use | ||
37 | QString mDelemiter; | ||
38 | //! the inner delemiter | ||
39 | QString m2Delemiter; | ||
40 | //! the real split routine | ||
41 | void splitit(); | ||
42 | //! the content | ||
43 | QString m_Command; | ||
44 | //! constructor | ||
45 | ValueExplode(){} | ||
46 | public: | ||
47 | //! constructor | ||
48 | /*! | ||
49 | * \param aCommand the string to be splitted | ||
50 | * \param aDelemiter which sign will be the delemiter character | ||
51 | * \param a2Delemiter which sign will delemiter the key-value-pairs between other delemiters | ||
52 | */ | ||
53 | ValueExplode(const QString&aCommand,const char aDelemiter = '&',const char a2Delemiter='='); | ||
54 | //! destructor | ||
55 | virtual ~ValueExplode(); | ||
56 | //! assigen operator | ||
57 | /*! | ||
58 | * \return a list of substrings | ||
59 | */ | ||
60 | operator const tvaluelist& (){return m_LastParsed;} | ||
61 | }; | ||
62 | |||
63 | ValueExplode::~ValueExplode() | ||
64 | { | ||
65 | } | ||
66 | |||
67 | ValueExplode::ValueExplode(const QString&aCommand,const char aDelemiter,const char a2Delemiter) | ||
68 | :m_LastParsed(),m_Command(aCommand) | ||
69 | { | ||
70 | mDelemiter = aDelemiter; | ||
71 | m2Delemiter = a2Delemiter; | ||
72 | splitit(); | ||
73 | } | ||
74 | |||
75 | void ValueExplode::splitit() | ||
76 | { | ||
77 | QString iLine; | ||
78 | m_LastParsed.clear(); | ||
79 | if (mDelemiter.isEmpty()||m2Delemiter.isEmpty()) { | ||
80 | m_LastParsed.append(tkeyvalues(m_Command,"")); | ||
81 | return; | ||
82 | } | ||
83 | int pos,pos2,startpos; | ||
84 | startpos = 0; | ||
85 | iLine = m_Command; | ||
86 | while ( (pos = iLine.find(mDelemiter,startpos))!=-1) { | ||
87 | pos2 = iLine.find(m2Delemiter,startpos); | ||
88 | if (pos2==-1||pos2>pos) { | ||
89 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos-startpos),"")); | ||
90 | } else { | ||
91 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1,pos-pos2-1))); | ||
92 | } | ||
93 | startpos = pos+1; | ||
94 | } | ||
95 | if (startpos<iLine.length()) { | ||
96 | pos2 = iLine.find(m2Delemiter,startpos); | ||
97 | if (pos2==-1) { | ||
98 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos),"")); | ||
99 | } else { | ||
100 | m_LastParsed.append(tkeyvalues(iLine.mid(startpos,pos2-startpos),iLine.mid(pos2+1))); | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
26 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) | 105 | OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) |
27 | : MainWindow( parent, name, WStyle_ContextHelp ) | 106 | : MainWindow( parent, name, WStyle_ContextHelp ) |
28 | { | 107 | { |
29 | setup_signalblocking(); | 108 | setup_signalblocking(); |
30 | settings = new Settings(); | 109 | settings = new Settings(); |
31 | 110 | ||
32 | folderView->populate( settings->getAccounts() ); | 111 | folderView->populate( settings->getAccounts() ); |
112 | #if 1 | ||
113 | tvaluelist s = ValueExplode("a=1&b=holladiewaldfee&c=3&d=&e=3450"); | ||
114 | for (int i = 0; i < s.count();++i) { | ||
115 | odebug<<"Key: " << s[i].key << " Value: " << s[i].data << oendl; | ||
116 | } | ||
117 | #endif | ||
33 | } | 118 | } |
34 | 119 | ||
35 | OpieMail::~OpieMail() | 120 | OpieMail::~OpieMail() |
36 | { | 121 | { |
37 | if (settings) delete settings; | 122 | if (settings) delete settings; |
38 | } | 123 | } |
@@ -70,13 +155,13 @@ void OpieMail::appMessage(const QCString &msg, const QByteArray &data) | |||
70 | void OpieMail::setDocument(const QString& mail) | 155 | void OpieMail::setDocument(const QString& mail) |
71 | { | 156 | { |
72 | /* | 157 | /* |
73 | * It looks like a mailto address, lets try it | 158 | * It looks like a mailto address, lets try it |
74 | */ | 159 | */ |
75 | if( mail.startsWith(QString::fromLatin1("mailto:")) ) | 160 | if( mail.startsWith(QString::fromLatin1("mailto:")) ) |
76 | slotwriteMail(QString::null, mail.mid(7)); | 161 | slotwriteMail(QString::null, mail.mid(7)); |
77 | } | 162 | } |
78 | 163 | ||
79 | void OpieMail::slotwriteMail(const QString&name,const QString&email) | 164 | void OpieMail::slotwriteMail(const QString&name,const QString&email) |
80 | { | 165 | { |
81 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); | 166 | ComposeMail compose( settings, this, 0, true , WStyle_ContextHelp ); |
82 | if (!email.isEmpty()) | 167 | if (!email.isEmpty()) |