summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontact.cpp4
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.cpp7
2 files changed, 7 insertions, 4 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp
index e34feeb..0f05b65 100644
--- a/libopie/pim/ocontact.cpp
+++ b/libopie/pim/ocontact.cpp
@@ -1086,64 +1086,64 @@ void OContact::setBirthday( const QDate &v )
1086 1086
1087 1087
1088/*! \fn void OContact::setAnniversary( const QDate &date ) 1088/*! \fn void OContact::setAnniversary( const QDate &date )
1089 Sets the anniversary of the contact to \a date. If date is 1089 Sets the anniversary of the contact to \a date. If date is
1090 null, the current stored date will be removed. 1090 null, the current stored date will be removed.
1091*/ 1091*/
1092void OContact::setAnniversary( const QDate &v ) 1092void OContact::setAnniversary( const QDate &v )
1093{ 1093{
1094 if ( v.isNull() ){ 1094 if ( v.isNull() ){
1095 qWarning( "Remove Anniversary"); 1095 qWarning( "Remove Anniversary");
1096 replace( Qtopia::Anniversary, QString::null ); 1096 replace( Qtopia::Anniversary, QString::null );
1097 return; 1097 return;
1098 } 1098 }
1099 1099
1100 if ( v.isValid() ) 1100 if ( v.isValid() )
1101 replace( Qtopia::Anniversary, OConversion::dateToString( v ) ); 1101 replace( Qtopia::Anniversary, OConversion::dateToString( v ) );
1102} 1102}
1103 1103
1104/*! \fn QDate OContact::birthday() const 1104/*! \fn QDate OContact::birthday() const
1105 Returns the birthday of the contact. 1105 Returns the birthday of the contact.
1106*/ 1106*/
1107QDate OContact::birthday() const 1107QDate OContact::birthday() const
1108{ 1108{
1109 QString str = find( Qtopia::Birthday ); 1109 QString str = find( Qtopia::Birthday );
1110 qWarning ("Birthday %s", str.latin1() ); 1110 // qWarning ("Birthday %s", str.latin1() );
1111 if ( !str.isEmpty() ) 1111 if ( !str.isEmpty() )
1112 return OConversion::dateFromString ( str ); 1112 return OConversion::dateFromString ( str );
1113 else 1113 else
1114 return QDate(); 1114 return QDate();
1115} 1115}
1116 1116
1117 1117
1118/*! \fn QDate OContact::anniversary() const 1118/*! \fn QDate OContact::anniversary() const
1119 Returns the anniversary of the contact. 1119 Returns the anniversary of the contact.
1120*/ 1120*/
1121QDate OContact::anniversary() const 1121QDate OContact::anniversary() const
1122{ 1122{
1123 QDate empty; 1123 QDate empty;
1124 QString str = find( Qtopia::Anniversary ); 1124 QString str = find( Qtopia::Anniversary );
1125 qWarning ("Anniversary %s", str.latin1() ); 1125 // qWarning ("Anniversary %s", str.latin1() );
1126 if ( !str.isEmpty() ) 1126 if ( !str.isEmpty() )
1127 return OConversion::dateFromString ( str ); 1127 return OConversion::dateFromString ( str );
1128 else 1128 else
1129 return empty; 1129 return empty;
1130} 1130}
1131 1131
1132 1132
1133void OContact::insertEmail( const QString &v ) 1133void OContact::insertEmail( const QString &v )
1134{ 1134{
1135 //qDebug("insertEmail %s", v.latin1()); 1135 //qDebug("insertEmail %s", v.latin1());
1136 QString e = v.simplifyWhiteSpace(); 1136 QString e = v.simplifyWhiteSpace();
1137 QString def = defaultEmail(); 1137 QString def = defaultEmail();
1138 1138
1139 // if no default, set it as the default email and don't insert 1139 // if no default, set it as the default email and don't insert
1140 if ( def.isEmpty() ) { 1140 if ( def.isEmpty() ) {
1141 setDefaultEmail( e ); // will insert into the list for us 1141 setDefaultEmail( e ); // will insert into the list for us
1142 return; 1142 return;
1143 } 1143 }
1144 1144
1145 // otherwise, insert assuming doesn't already exist 1145 // otherwise, insert assuming doesn't already exist
1146 QString emailsStr = find( Qtopia::Emails ); 1146 QString emailsStr = find( Qtopia::Emails );
1147 if ( emailsStr.contains( e )) 1147 if ( emailsStr.contains( e ))
1148 return; 1148 return;
1149 if ( !emailsStr.isEmpty() ) 1149 if ( !emailsStr.isEmpty() )
diff --git a/libopie/pim/ocontactaccessbackend_xml.cpp b/libopie/pim/ocontactaccessbackend_xml.cpp
index 1c21619..1b5af2f 100644
--- a/libopie/pim/ocontactaccessbackend_xml.cpp
+++ b/libopie/pim/ocontactaccessbackend_xml.cpp
@@ -1,43 +1,46 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ToDo: XML-Backend: Automatic reload if something was changed... 12 * ToDo: XML-Backend: Automatic reload if something was changed...
13 * 13 *
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.8 2003/08/30 15:28:26 eilers
21 * Removed some unimportant debug output which causes slow down..
22 *
20 * Revision 1.7 2003/08/01 12:30:16 eilers 23 * Revision 1.7 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD 24 * Merging changes from BRANCH_1_0 to HEAD
22 * 25 *
23 * Revision 1.6 2003/07/07 16:19:47 eilers 26 * Revision 1.6 2003/07/07 16:19:47 eilers
24 * Fixing serious bug in hasQuerySettings() 27 * Fixing serious bug in hasQuerySettings()
25 * 28 *
26 * Revision 1.5 2003/04/13 18:07:10 zecke 29 * Revision 1.5 2003/04/13 18:07:10 zecke
27 * More API doc 30 * More API doc
28 * QString -> const QString& 31 * QString -> const QString&
29 * QString = 0l -> QString::null 32 * QString = 0l -> QString::null
30 * 33 *
31 * Revision 1.4 2003/03/21 14:32:54 mickeyl 34 * Revision 1.4 2003/03/21 14:32:54 mickeyl
32 * g++ compliance fix: default arguments belong into the declaration, but not the definition 35 * g++ compliance fix: default arguments belong into the declaration, but not the definition
33 * 36 *
34 * Revision 1.3 2003/03/21 12:26:28 eilers 37 * Revision 1.3 2003/03/21 12:26:28 eilers
35 * Fixing small bug: If we search a birthday from today to today, it returned 38 * Fixing small bug: If we search a birthday from today to today, it returned
36 * every contact .. 39 * every contact ..
37 * 40 *
38 * Revision 1.2 2003/03/21 10:33:09 eilers 41 * Revision 1.2 2003/03/21 10:33:09 eilers
39 * Merged speed optimized xml backend for contacts to main. 42 * Merged speed optimized xml backend for contacts to main.
40 * Added QDateTime to querybyexample. For instance, it is now possible to get 43 * Added QDateTime to querybyexample. For instance, it is now possible to get
41 * all Birthdays/Anniversaries between two dates. This should be used 44 * all Birthdays/Anniversaries between two dates. This should be used
42 * to show all birthdays in the datebook.. 45 * to show all birthdays in the datebook..
43 * This change is sourcecode backward compatible but you have to upgrade 46 * This change is sourcecode backward compatible but you have to upgrade
@@ -149,49 +152,49 @@ bool OContactAccessBackend_XML::save()
149 return true; 152 return true;
150 153
151 QString strNewFile = m_fileName + ".new"; 154 QString strNewFile = m_fileName + ".new";
152 QFile f( strNewFile ); 155 QFile f( strNewFile );
153 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 156 if ( !f.open( IO_WriteOnly|IO_Raw ) )
154 return false; 157 return false;
155 158
156 int total_written; 159 int total_written;
157 int idx_offset = 0; 160 int idx_offset = 0;
158 QString out; 161 QString out;
159 162
160 // Write Header 163 // Write Header
161 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 164 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
162 " <Groups>\n" 165 " <Groups>\n"
163 " </Groups>\n" 166 " </Groups>\n"
164 " <Contacts>\n"; 167 " <Contacts>\n";
165 QCString cstr = out.utf8(); 168 QCString cstr = out.utf8();
166 f.writeBlock( cstr.data(), cstr.length() ); 169 f.writeBlock( cstr.data(), cstr.length() );
167 idx_offset += cstr.length(); 170 idx_offset += cstr.length();
168 out = ""; 171 out = "";
169 172
170 // Write all contacts 173 // Write all contacts
171 QListIterator<OContact> it( m_contactList ); 174 QListIterator<OContact> it( m_contactList );
172 for ( ; it.current(); ++it ) { 175 for ( ; it.current(); ++it ) {
173 qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); 176 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset );
174 out += "<Contact "; 177 out += "<Contact ";
175 (*it)->save( out ); 178 (*it)->save( out );
176 out += "/>\n"; 179 out += "/>\n";
177 cstr = out.utf8(); 180 cstr = out.utf8();
178 total_written = f.writeBlock( cstr.data(), cstr.length() ); 181 total_written = f.writeBlock( cstr.data(), cstr.length() );
179 idx_offset += cstr.length(); 182 idx_offset += cstr.length();
180 if ( total_written != int(cstr.length()) ) { 183 if ( total_written != int(cstr.length()) ) {
181 f.close(); 184 f.close();
182 QFile::remove( strNewFile ); 185 QFile::remove( strNewFile );
183 return false; 186 return false;
184 } 187 }
185 out = ""; 188 out = "";
186 } 189 }
187 out += " </Contacts>\n</AddressBook>\n"; 190 out += " </Contacts>\n</AddressBook>\n";
188 191
189 // Write Footer 192 // Write Footer
190 cstr = out.utf8(); 193 cstr = out.utf8();
191 total_written = f.writeBlock( cstr.data(), cstr.length() ); 194 total_written = f.writeBlock( cstr.data(), cstr.length() );
192 if ( total_written != int( cstr.length() ) ) { 195 if ( total_written != int( cstr.length() ) ) {
193 f.close(); 196 f.close();
194 QFile::remove( strNewFile ); 197 QFile::remove( strNewFile );
195 return false; 198 return false;
196 } 199 }
197 f.close(); 200 f.close();
@@ -681,49 +684,49 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
681 if( element->tagName() != QString::fromLatin1("Contact") ){ 684 if( element->tagName() != QString::fromLatin1("Contact") ){
682 //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s", 685 //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s",
683 // element->tagName().latin1()); 686 // element->tagName().latin1());
684 element = element->nextChild(); 687 element = element->nextChild();
685 continue; 688 continue;
686 } 689 }
687 /* Found alement with tagname "contact", now parse and store all 690 /* Found alement with tagname "contact", now parse and store all
688 * attributes contained 691 * attributes contained
689 */ 692 */
690 //qWarning("OContactDefBack::load element tagName() : %s", 693 //qWarning("OContactDefBack::load element tagName() : %s",
691 // element->tagName().latin1() ); 694 // element->tagName().latin1() );
692 QString dummy; 695 QString dummy;
693 foundAction = false; 696 foundAction = false;
694 697
695 XMLElement::AttributeMap aMap = element->attributes(); 698 XMLElement::AttributeMap aMap = element->attributes();
696 XMLElement::AttributeMap::Iterator it; 699 XMLElement::AttributeMap::Iterator it;
697 contactMap.clear(); 700 contactMap.clear();
698 customMap.clear(); 701 customMap.clear();
699 for( it = aMap.begin(); it != aMap.end(); ++it ){ 702 for( it = aMap.begin(); it != aMap.end(); ++it ){
700 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); 703 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
701 704
702 int *find = dict[ it.key() ]; 705 int *find = dict[ it.key() ];
703 /* Unknown attributes will be stored as "Custom" elements */ 706 /* Unknown attributes will be stored as "Custom" elements */
704 if ( !find ) { 707 if ( !find ) {
705 qWarning("Attribute %s not known.", it.key().latin1()); 708 // qWarning("Attribute %s not known.", it.key().latin1());
706 //contact.setCustomField(it.key(), it.data()); 709 //contact.setCustomField(it.key(), it.data());
707 customMap.insert( it.key(), it.data() ); 710 customMap.insert( it.key(), it.data() );
708 continue; 711 continue;
709 } 712 }
710 713
711 /* Check if special conversion is needed and add attribute 714 /* Check if special conversion is needed and add attribute
712 * into Contact class 715 * into Contact class
713 */ 716 */
714 switch( *find ) { 717 switch( *find ) {
715 /* 718 /*
716 case Qtopia::AddressUid: 719 case Qtopia::AddressUid:
717 contact.setUid( it.data().toInt() ); 720 contact.setUid( it.data().toInt() );
718 break; 721 break;
719 case Qtopia::AddressCategory: 722 case Qtopia::AddressCategory:
720 contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); 723 contact.setCategories( Qtopia::Record::idsFromString( it.data( )));
721 break; 724 break;
722 */ 725 */
723 case JOURNALACTION: 726 case JOURNALACTION:
724 action = journal_action(it.data().toInt()); 727 action = journal_action(it.data().toInt());
725 foundAction = true; 728 foundAction = true;
726 qWarning ("ODefBack(journal)::ACTION found: %d", action); 729 qWarning ("ODefBack(journal)::ACTION found: %d", action);
727 break; 730 break;
728 case JOURNALROW: 731 case JOURNALROW:
729 journalKey = it.data().toInt(); 732 journalKey = it.data().toInt();