summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/mail/opiemail.cpp87
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
@@ -17,12 +17,91 @@
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
24using namespace Opie::Core; 26using namespace Opie::Core;
25 27
28typedef QMapNode<QString,QString> tkeyvalues;
29typedef QValueList<tkeyvalues> tvaluelist;
30
31class ValueExplode
32{
33protected:
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(){}
46public:
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
63ValueExplode::~ValueExplode()
64{
65}
66
67ValueExplode::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
75void 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
26OpieMail::OpieMail( QWidget *parent, const char *name, WFlags ) 105OpieMail::OpieMail( QWidget *parent, const char *name, WFlags )
27 : MainWindow( parent, name, WStyle_ContextHelp ) 106 : MainWindow( parent, name, WStyle_ContextHelp )
28{ 107{
@@ -30,6 +109,12 @@ OpieMail::OpieMail( QWidget *parent, const char *name, WFlags )
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
35OpieMail::~OpieMail() 120OpieMail::~OpieMail()
@@ -73,7 +158,7 @@ void OpieMail::setDocument(const QString& mail)
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
79void OpieMail::slotwriteMail(const QString&name,const QString&email) 164void OpieMail::slotwriteMail(const QString&name,const QString&email)