summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 18113c2..5df7253 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -105,13 +105,12 @@ bool OPimContactAccessBackend_XML::save()
idx_offset += cstr.length();
out = "";
// Write all contacts
QListIterator<OPimContact> it( m_contactList );
for ( ; it.current(); ++it ) {
- // owarn << " Uid " << (*it)->uid() << " at Offset: " << idx_offset << "" << oendl;
out += "<Contact ";
(*it)->save( out );
out += "/>\n";
cstr = out.utf8();
total_written = f.writeBlock( cstr.data(), cstr.length() );
idx_offset += cstr.length();
@@ -134,14 +133,12 @@ bool OPimContactAccessBackend_XML::save()
}
f.close();
// move the file over, I'm just going to use the system call
// because, I don't feel like using QDir.
if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
- owarn << "problem renaming file " << strNewFile << " to " << m_journalName
- << ", errno: " << errno << oendl;
// remove the tmp file...
QFile::remove( strNewFile );
}
/* The journalfile should be removed now... */
removeJournal();
@@ -210,15 +207,14 @@ OPimContact OPimContactAccessBackend_XML::find ( int uid ) const
}
return ( foundContact );
}
QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings,
- const QDateTime& d )
+ const QDateTime& d )const
{
-
QArray<int> m_currentQuery( m_contactList.count() );
QListIterator<OPimContact> it( m_contactList );
uint arraycounter = 0;
for( ; it.current(); ++it ){
/* Search all fields and compare them with query object. Store them into list
@@ -275,19 +271,16 @@ QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &qu
checkDate->month(),
checkDate->day() );
// Check whether the birthday/anniversary date is between
// the current/given date and the maximum date
// ( maximum time range ) !
- owarn << "Checking if " << checkDate->toString() << " is between " << current.toString()
- << " and " << queryDate->toString() << " ! " << oendl;
if ( current.daysTo( *queryDate ) >= 0 ){
if ( !( ( *checkDate >= current ) &&
( *checkDate <= *queryDate ) ) ){
allcorrect = false;
- owarn << " Nope!.." << oendl;
}
}
}
} else{
// checkDate is invalid. Therefore this entry is always rejected
allcorrect = false;
@@ -427,12 +420,13 @@ bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
return ( true );
default:
return ( false );
}
}
+#if 0
// Currently only asc implemented..
QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
{
QMap<QString, int> nameToUid;
QStringList names;
QArray<int> m_currentQuery( m_contactList.count() );
@@ -455,16 +449,17 @@ QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
m_currentQuery[i++] = nameToUid[ (*it) ];
}
return m_currentQuery;
}
+#endif
+
bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact )
{
- //owarn << "odefaultbackend: ACTION::ADD" << oendl;
updateJournal (newcontact, ACTION_ADD);
addContact_p( newcontact );
m_changed = true;
return true;
@@ -482,14 +477,12 @@ bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact )
updateJournal ( *newCont, ACTION_REPLACE);
m_contactList.removeRef ( found );
m_contactList.append ( newCont );
m_uidToContact.remove( QString().setNum( contact.uid() ) );
m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
- owarn << "Nur zur Sicherheit: " << contact.uid() << " == " << newCont->uid() << " ?" << oendl;
-
return true;
} else
return false;
}
bool OPimContactAccessBackend_XML::remove ( int uid )
@@ -588,61 +581,49 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
dict.insert( "Nickname", new int(Qtopia::Nickname) );
dict.insert( "Notes", new int(Qtopia::Notes) );
dict.insert( "action", new int(JOURNALACTION) );
dict.insert( "actionrow", new int(JOURNALROW) );
- //owarn << "OPimContactDefaultBackEnd::loading " << filename << "" << oendl;
-
XMLElement *root = XMLElement::load( filename );
if(root != 0l ){ // start parsing
/* Parse all XML-Elements and put the data into the
* Contact-Class
*/
XMLElement *element = root->firstChild();
- //owarn << "OPimContactAccess::load tagName(): " << root->tagName() << "" << oendl;
element = element ? element->firstChild() : 0;
/* Search Tag "Contacts" which is the parent of all Contacts */
while( element && !isJournal ){
if( element->tagName() != QString::fromLatin1("Contacts") ){
- //owarn << "OPimContactDefBack::Searching for Tag \"Contacts\"! Found: "
- // << element->tagName() << oendl;
element = element->nextChild();
} else {
element = element->firstChild();
break;
}
}
/* Parse all Contacts and ignore unknown tags */
while( element ){
if( element->tagName() != QString::fromLatin1("Contact") ){
- //owarn << "OPimContactDefBack::Searching for Tag \"Contact\"! Found: "
- // << element->tagName() << oendl;
element = element->nextChild();
continue;
}
/* Found alement with tagname "contact", now parse and store all
* attributes contained
*/
- //owarn << "OPimContactDefBack::load element tagName() : "
- // << element->tagName() << oendl;
QString dummy;
foundAction = false;
XMLElement::AttributeMap aMap = element->attributes();
XMLElement::AttributeMap::Iterator it;
contactMap.clear();
customMap.clear();
for( it = aMap.begin(); it != aMap.end(); ++it ){
- // owarn << "Read Attribute: " << it.key() << "=" << it.data() << oendl;
-
int *find = dict[ it.key() ];
/* Unknown attributes will be stored as "Custom" elements */
if ( !find ) {
- // owarn << "Attribute " << it.key() << " not known." << oendl;
//contact.setCustomField(it.key(), it.data());
customMap.insert( it.key(), it.data() );
continue;
}
/* Check if special conversion is needed and add attribute
@@ -701,16 +682,14 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
}
/* Move to next element */
element = element->nextChild();
}
}else {
- owarn << "ODefBack::could not load" << oendl;
}
delete root;
- owarn << "returning from loading" << oendl;
return true;
}
void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt,
journal_action action )