summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index b569f8b..ffa6a7d 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -8,55 +8,60 @@
.> <`_, > . <= redistribute it and/or modify it under
:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
.="- .-=="i, .._ License as published by the Free Software
- . .-<_> .<> Foundation; either version 2 of the License,
._= =} : or (at your option) any later version.
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
* VCard Backend for the OPIE-Contact Database.
*/
-#include <opie2/ocontactaccessbackend_vcard.h>
-#include "../../../../library/backend/vobject_p.h"
-#include "../../../../library/backend/qfiledirect_p.h"
+
+#include "vobject_p.h"
+
+/* OPIE */
+#include <opie2/ocontactaccessbackend_vcard.h>
#include <qpe/timeconversion.h>
+//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
+#define protected public
#include <qfile.h>
+#undef protected
namespace Opie {
OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ):
m_dirty( false ),
m_file( filename )
{
load();
}
bool OPimContactAccessBackend_VCard::load ()
{
m_map.clear();
m_dirty = false;
VObject* obj = 0l;
if ( QFile::exists(m_file) ){
obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
if ( !obj )
return false;
}else{
qWarning("File \"%s\" not found !", m_file.latin1() );
@@ -73,60 +78,60 @@ bool OPimContactAccessBackend_VCard::load ()
if ( con.uid() == 0 ){
con.setUid( 1 );
qWarning("assigned new uid %d",con.uid() );
}
m_map.insert( con.uid(), con );
VObject *t = obj;
obj = nextVObjectInList(obj);
cleanVObject( t );
}
return true;
}
bool OPimContactAccessBackend_VCard::reload()
{
return load();
}
bool OPimContactAccessBackend_VCard::save()
{
if (!m_dirty )
return true;
- QFileDirect file( m_file );
+ QFile file( m_file );
if (!file.open(IO_WriteOnly ) )
return false;
VObject *obj;
obj = newVObject( VCCalProp );
addPropValue( obj, VCVersionProp, "1.0" );
VObject *vo;
for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
vo = createVObject( *it );
- writeVObject( file.directHandle() , vo );
+ writeVObject( file.fh, vo ); //FIXME: HACK!!!
cleanVObject( vo );
}
cleanStrTbl();
deleteVObject( obj );
m_dirty = false;
return true;
}
void OPimContactAccessBackend_VCard::clear ()
{
m_map.clear();
m_dirty = true; // ??? sure ? (se)
}
bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact )
{
m_map.insert( newcontact.uid(), newcontact );
m_dirty = true;
return true;
}
bool OPimContactAccessBackend_VCard::remove ( int uid )