summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/mail/addresspicker.cpp91
1 files changed, 30 insertions, 61 deletions
diff --git a/noncore/net/mail/addresspicker.cpp b/noncore/net/mail/addresspicker.cpp
index 2c15bb4..581de62 100644
--- a/noncore/net/mail/addresspicker.cpp
+++ b/noncore/net/mail/addresspicker.cpp
@@ -7,2 +7,5 @@
7#include <qpe/resource.h> 7#include <qpe/resource.h>
8#include <opie/ocontactaccess.h>
9#include <opie/ocontact.h>
10
8 11
@@ -20,63 +23,24 @@ AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFl
20 connect(cancelButton, SIGNAL(clicked()), SLOT(close())); 23 connect(cancelButton, SIGNAL(clicked()), SLOT(close()));
21 24 OContactAccess::List::Iterator it;
22 QFile f((QString) getenv("HOME") + "/Applications/" 25
23 + "addressbook/addressbook.xml"); 26 QString lineEmail, lineName, contactLine;
24 27 /* what name has to set here???? */
25 if ( f.open( IO_ReadOnly ) ) { 28 OContactAccess m_contactdb("addressbook");
26 QTextStream stream( &f ); 29 QStringList mails;
27 stream.setEncoding( QTextStream::UnicodeUTF8 ); 30 QString pre,suf;
28 QString content; 31 OContactAccess::List m_list = m_contactdb.sorted( true, 0, 0, 0 );
29 while ( !f.atEnd() ) { 32 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
30 content += stream.readLine() + "\n"; 33 if ((*it).defaultEmail().length()!=0) {
31 } 34 mails = (*it).emailList();
32 QStringList lines = QStringList::split( QRegExp( "\\n" ), content ); 35 if ((*it).fileAs().length()>0) {
33 QStringList::Iterator it; 36 pre = "\""+(*it).fileAs()+"\" <";
34 for ( it = lines.begin(); it != lines.end(); it++ ) { 37 suf = ">";
35 if ( (*it).find( QRegExp( "^<Contact.*" ) ) != -1 ) { 38 } else {
36 int pos = (*it).find( "FirstName=\"" ); 39 pre = "";
37 QString fname; 40 suf = "";
38 if ( pos != -1 ) { 41 }
39 int i = 1; 42 QStringList::ConstIterator sit = mails.begin();
40 QChar c; 43 for (;sit!=mails.end();++sit) {
41 while ( c != '"' ) { 44 contactLine=pre+(*sit)+suf;
42 c = (*it)[pos + 10 + i]; 45 addressList->insertItem(contactLine);
43 if ( c != '"' ) fname += c;
44 i++;
45 }
46 }
47 pos = (*it).find( "LastName=\"" );
48 QString lname;
49 if ( pos != -1 ) {
50 int i = 1;
51 QChar c;
52 while ( c != '"' ) {
53 c = (*it)[pos + 9 + i];
54 if ( c != '"' ) lname += c;
55 i++;
56 }
57 }
58 pos = (*it).find( "DefaultEmail=\"" );
59 QString email;
60 if ( pos != -1 ) {
61 int i = 1;
62 QChar c;
63 while ( c != '"' ) {
64 c = (*it)[pos + 13 + i];
65 if ( c != '"' ) email += c;
66 i++;
67 }
68 }
69 QString tname, temail;
70 if ( !fname.isEmpty() ) {
71 tname += fname;
72 }
73 if ( !lname.isEmpty() ) {
74 tname += fname.isEmpty() ? lname : (" " + lname);
75 }
76 if ( !email.isEmpty() ) {
77 temail += tname.isEmpty() ? email : (" <" + email + ">");
78 }
79 if ( !email.isEmpty() ) {
80 addressList->insertItem( tname + temail );
81 }
82 } 46 }
@@ -85,6 +49,11 @@ AddressPicker::AddressPicker( QWidget *parent, const char *name, bool modal, WFl
85 if ( addressList->count() <= 0 ) { 49 if ( addressList->count() <= 0 ) {
50#if 0
51 // makes this realy sense??
86 addressList->insertItem( 52 addressList->insertItem(
87 tr( "There are no entries in the addressbook." ) ); 53 tr( "There are no entries in the addressbook." ) );
54#endif
88 addressList->setEnabled( false ); 55 addressList->setEnabled( false );
89 okButton->setEnabled( false ); 56 okButton->setEnabled( false );
57 } else {
58// addressList->sort();
90 } 59 }