summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mailit/addresslist.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mailit/addresslist.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mailit/addresslist.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/noncore/unsupported/mailit/addresslist.cpp b/noncore/unsupported/mailit/addresslist.cpp
index 1cf2562..43e3830 100644
--- a/noncore/unsupported/mailit/addresslist.cpp
+++ b/noncore/unsupported/mailit/addresslist.cpp
@@ -10,24 +10,26 @@
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qfile.h> 20#include <qfile.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#include <opie/ocontactaccess.h>
23#include <opie/ocontact.h>
22 24
23#include "addresslist.h" 25#include "addresslist.h"
24 26
25AddressList::AddressList(QString file) 27AddressList::AddressList(QString file)
26{ 28{
27 addresses.setAutoDelete(TRUE); 29 addresses.setAutoDelete(TRUE);
28 filename = file; 30 filename = file;
29 read(); 31 read();
30 dirty = FALSE; 32 dirty = FALSE;
31} 33}
32 34
33AddressList::~AddressList() 35AddressList::~AddressList()
@@ -107,43 +109,55 @@ int AddressList::getNameRef(QString name)
107 pos++; 109 pos++;
108 } 110 }
109 return -1; 111 return -1;
110} 112}
111 113
112QList<Contact>* AddressList::getContactList() 114QList<Contact>* AddressList::getContactList()
113{ 115{
114 return &addresses; 116 return &addresses;
115} 117}
116 118
117void AddressList::read() 119void AddressList::read()
118{ 120{
119 QFile f(filename); 121 OContactAccess::List::Iterator it;
122
123 //QFile f(filename);
120 QString lineEmail, lineName, email, name; 124 QString lineEmail, lineName, email, name;
125 OContactAccess m_contactdb("mailit");
126 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
127 //OContact* oc;
121 128
122 if (! f.open(IO_ReadOnly) ) 129 for ( it = m_list.begin(); it != m_list.end(); ++it )
130 {
131 //oc=(OContact*) it;
132 if ((*it).defaultEmail().length()!=0)
133 addContact((*it).defaultEmail(),(*it).fullName());
134 }
135
136 /*if (! f.open(IO_ReadOnly) )
123 return; 137 return;
124 138
125 QTextStream stream(&f); 139 QTextStream stream(&f);
126 140
127 while (! stream.atEnd() ) { 141 while (! stream.atEnd() ) {
128 lineEmail = stream.readLine(); 142 lineEmail = stream.readLine();
129 if (! stream.atEnd() ) 143 if (! stream.atEnd() )
130 lineName = stream.readLine(); 144 lineName = stream.readLine();
131 else return; 145 else return;
132 146
133 email = getRightString(lineEmail); 147 email = getRightString(lineEmail);
134 name = getRightString(lineName); 148 name = getRightString(lineName);
135 addContact(email, name); 149 addContact(email, name);
136 } 150 }
137 f.close(); 151 f.close();*/
138} 152}
139 153
140QString AddressList::getRightString(QString in) 154QString AddressList::getRightString(QString in)
141{ 155{
142 QString out = ""; 156 QString out = "";
143 157
144 int pos = in.find('='); 158 int pos = in.find('=');
145 if (pos != -1) { 159 if (pos != -1) {
146 out = in.mid(pos+1).stripWhiteSpace(); 160 out = in.mid(pos+1).stripWhiteSpace();
147 } 161 }
148 return out; 162 return out;
149} 163}