-rw-r--r-- | library/backend/categories.cpp | 146 | ||||
-rw-r--r-- | library/backend/categories.h | 12 | ||||
-rw-r--r-- | library/backend/contact.cpp | 107 | ||||
-rw-r--r-- | library/backend/contact.h | 7 | ||||
-rw-r--r-- | library/backend/event.h | 5 | ||||
-rw-r--r-- | library/backend/recordfields.h | 46 | ||||
-rw-r--r-- | library/backend/task.h | 4 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 9 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 3 |
9 files changed, 182 insertions, 157 deletions
diff --git a/library/backend/categories.cpp b/library/backend/categories.cpp index 91331db..6e011c4 100644 --- a/library/backend/categories.cpp +++ b/library/backend/categories.cpp @@ -126,126 +126,96 @@ bool CategoryGroup::contains(int uid) const bool CategoryGroup::contains(const QString &label) const { return ( mLabelIdMap.find( label ) != mLabelIdMap.end() ); } /** Returns label associated with the uid or QString::null if * not found */ const QString &CategoryGroup::label(int uid) const { QMap<int,QString>::ConstIterator idIt = mIdLabelMap.find( uid ); if ( idIt == mIdLabelMap.end() ) return QString::null; return *idIt; } /** Returns the uid associated with label or 0 if not found */ int CategoryGroup::id(const QString &label) const { QMap<QString,int>::ConstIterator labelIt = mLabelIdMap.find( label ); if ( labelIt == mLabelIdMap.end() ) return 0; return *labelIt; } QStringList CategoryGroup::labels() const { QStringList labels; for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); it != mIdLabelMap.end(); ++it ) labels += *it; // ### I don't think this is the place for this... // labels.sort(); return labels; } QStringList CategoryGroup::labels(const QArray<int> &catids ) const { QStringList labels; if ( catids.count() == 0 ) return labels; for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); it != mIdLabelMap.end(); ++it ) if ( catids.find( it.key() ) != -1 ) labels += *it; return labels; } -QArray<int> CategoryGroup::ids( const QStringList &cats ) const -{ - QArray<int> results; - - for ( QStringList::ConstIterator catIt = cats.begin(); - catIt != cats.end(); ++catIt ) { - if ( *catIt == QObject::tr("All") || *catIt == QObject::tr("Unfiled") ) - continue; - int value = id( *catIt ); - if ( value != 0 ) { - int tmp = results.size(); - results.resize( tmp + 1 ); - results[ tmp ] = value; - } - } - - return results; -} - -QArray<int> CategoryGroup::ids() const -{ - QArray<int> results( mIdLabelMap.count() ); - int i = 0; - for ( QMap<int, QString>::ConstIterator it = mIdLabelMap.begin(); - it != mIdLabelMap.end(); ++it ) - results[i++] = it.key(); - - return results; -} - /*********************************************************** * * Categories * **********************************************************/ /** Add the category name as long as it doesn't already exist locally * or globally. Return TRUE if added, FALSE if conflicts. */ int Categories::addCategory( const QString &appname, const QString &catname, int uid ) { if ( mGlobalCats.contains(catname) ) return 0; QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt == mAppCats.end() ) { CategoryGroup newgroup; newgroup.add( uid, catname ); mAppCats.insert( appname, newgroup ); emit categoryAdded( *this, appname, uid ); return uid; } CategoryGroup &cats = *appIt; cats.add( uid, catname ); emit categoryAdded( *this, appname, uid ); return uid; } int Categories::addCategory( const QString &appname, const QString &catname ) { if ( mGlobalCats.contains(catname) ) return 0; QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt == mAppCats.end() ) { CategoryGroup newgroup; int uid = newgroup.add( catname ); mAppCats.insert( appname, newgroup ); emit categoryAdded( *this, appname, uid ); return uid; @@ -298,331 +268,337 @@ bool Categories::removeCategory( const QString &appname, return removeGlobalCategory( catname ); } bool Categories::removeCategory( const QString &appname, int uid ) { QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt != mAppCats.end() ) { CategoryGroup &cats = *appIt; if ( cats.remove( uid ) ) { emit categoryRemoved( *this, appname, uid ); return TRUE; } } return FALSE; } bool Categories::removeGlobalCategory( const QString &catname ) { int uid = mGlobalCats.id( catname ); if ( mGlobalCats.remove( uid ) ) { emit categoryRemoved( *this, QString::null, uid ); return TRUE; } return FALSE; } bool Categories::removeGlobalCategory( int uid ) { if ( mGlobalCats.remove( uid ) ) { emit categoryRemoved( *this, QString::null, uid ); return TRUE; } return FALSE; } /** Returns the sorted list of all categories that are associated with * the app. If includeGlobal parameter is TRUE then the returned * categories will include the global category items. */ QStringList Categories::labels( const QString &app, bool includeGlobal, ExtraLabels extra ) const { QMap< QString, CategoryGroup >::ConstIterator appIt = mAppCats.find( app ); QStringList cats; + + if ( appIt != mAppCats.end() ) + cats += (*appIt).labels(); + else qDebug("Categories::labels didn't find app %s", app.latin1() ); + if ( includeGlobal ) + cats += mGlobalCats.labels(); + + cats.sort(); switch ( extra ) { case NoExtra: break; case AllUnfiled: cats.append( tr("All") ); cats.append( tr("Unfiled") ); break; case AllLabel: cats.append( tr("All") ); break; case UnfiledLabel: cats.append( tr("Unfiled") ); break; } - if ( appIt != mAppCats.end() ) - cats += (*appIt).labels(); - else qDebug("Categories::labels didn't find app %s", app.latin1() ); - if ( includeGlobal ) - cats += mGlobalCats.labels(); - // I don't think a sorted list is useful, the user might find prefer - // it in the original order. -// cats.sort(); + return cats; } QString Categories::label( const QString &app, int id ) const { if ( mGlobalCats.contains( id ) ) return mGlobalCats.label( id ); QMap< QString, CategoryGroup >::ConstIterator appIt = mAppCats.find( app ); if ( appIt == mAppCats.end() ) return QString::null; return (*appIt).label( id ); } -QStringList Categories::labels( const QString & app, - const QArray<int> &catids ) const -{ - QStringList strs = mGlobalCats.labels( catids ); - strs += mAppCats[app].labels( catids ); - return strs; -} - /** Returns a single string associated with the cat ids for display in * a combobox or any area that requires one string. If catids are empty * then "Unfiled" will be returned. If multiple categories are assigned * the first cat id is shown with " (multi)" appended to the string. */ QString Categories::displaySingle( const QString &app, const QArray<int> &catids, DisplaySingle display ) const { QStringList strs = labels( app, catids ); if ( !strs.count() ) return tr("Unfiled"); strs.sort(); QString r; if ( strs.count() > 1 ) { switch ( display ) { case ShowFirst: r = strs.first(); break; case ShowMulti: r = strs.first() + tr(" (multi.)"); break; case ShowAll: r = strs.join(" "); break; } } else r = strs.first(); return r; } -QArray<int> Categories::ids( const QString &app ) const -{ - QArray<int> allIds = mGlobalCats.ids(); - QArray<int> appIds = mAppCats[app].ids(); - - // we should make the guarentee that the ids are in the - // same order as the labels, (i.e. app cats then global) - // otherwise there is no point in having these two separate functions. - uint appSize = appIds.size(); - appIds.resize( appSize + allIds.size() ); - for ( uint i = appSize; i < appIds.size(); ++i ) - appIds[int(i)] = allIds[int(i - appSize)]; - - return appIds; -} - -QArray<int> Categories::ids( const QString &app, const QStringList &cats ) const +QArray<int> Categories::ids( const QString &app, const QStringList &labels) const { - QArray<int> allIds = mGlobalCats.ids( cats ); - QArray<int> appIds = mAppCats[app].ids( cats ); - - uint appSize = appIds.size(); - appIds.resize( appSize + allIds.size() ); - for ( uint i = appSize; i < appIds.size(); ++i ) - appIds[int(i)] = allIds[int(i - appSize)]; - - return appIds; + QArray<int> results; + QStringList::ConstIterator it; + int i; + + for ( i=0, it=labels.begin(); it!=labels.end(); i++, ++it ) { + int value = id( app, *it ); + if ( value != 0 ) { + int tmp = results.size(); + results.resize( tmp + 1 ); + results[ tmp ] = value; + } + } + return results; } int Categories::id( const QString &app, const QString &cat ) const { if ( cat == tr("Unfiled") || cat.contains( tr(" (multi.)") ) ) return 0; int uid = mGlobalCats.id( cat ); if ( uid != 0 ) return uid; return mAppCats[app].id( cat ); } /** Return TRUE if renaming succeeded; FALSE if app name not found, * or if there was a name conflict */ bool Categories::renameCategory( const QString &appname, const QString &oldName, const QString &newName ) { QMap< QString, CategoryGroup >::Iterator appIt = mAppCats.find( appname ); if ( appIt != mAppCats.end() ) { CategoryGroup &cats = *appIt; int id = cats.id( oldName ); if ( id != 0 && cats.rename( id, newName ) ) { emit categoryRenamed( *this, appname, id ); return TRUE; } } return renameGlobalCategory( oldName, newName ); } bool Categories::renameGlobalCategory( const QString &oldName, const QString &newName ) { int uid = mGlobalCats.id( oldName ); if ( uid != 0 && mGlobalCats.rename( uid, newName ) ) { emit categoryRenamed( *this, QString::null, uid ); return TRUE; } return FALSE; } void Categories::setGlobal( const QString &appname, const QString &catname, bool global ) { // if in global and should be in app; then move it if ( mGlobalCats.contains( catname ) && !global ) { mGlobalCats.remove( catname ); addCategory( appname, catname ); return ; } // if in app and should be in global, then move it if ( !global ) return; if ( removeCategory( appname, catname, FALSE ) ) addGlobalCategory( catname ); } bool Categories::isGlobal( const QString &catname ) const { return mGlobalCats.contains( catname ); } /** Returns true if the catname is associated with any application */ bool Categories::exists( const QString &catname ) const { if ( isGlobal(catname) ) return TRUE; for ( QMap<QString, CategoryGroup>::ConstIterator appsIt = mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) if ( exists( appsIt.key(), catname ) ) return TRUE; return FALSE; } bool Categories::exists( const QString &appname, const QString &catname) const { QMap< QString, CategoryGroup >::ConstIterator appIt = mAppCats.find( appname ); if ( appIt == mAppCats.end() ) return FALSE; return (*appIt).contains( catname ); } + bool Categories::save( const QString &fname ) const { - QFile file( fname ); - if ( !file.open( IO_WriteOnly ) ) { + QString strNewFile = fname + ".new"; + QFile f( strNewFile ); + QString out; + int total_written; + + if ( !f.open( IO_WriteOnly|IO_Raw ) ) { qWarning("Unable to write to %s", fname.latin1()); return FALSE; } - QTextStream ts( &file ); - ts << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; - ts << "<!DOCTYPE CategoryList>" << endl; + out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; + out += "<!DOCTYPE CategoryList>\n"; + + out += "<Categories>\n"; - ts << "<Categories>" << endl; for ( QMap<int, QString>::ConstIterator git = mGlobalCats.idMap().begin(); git != mGlobalCats.idMap().end(); ++git ) - ts << "<Category id=\"" << git.key() << "\"" - << " name=\"" << escapeString(*git) << "\" />" << endl; + out += "<Category id=\"" + QString::number(git.key()) + "\"" + + " name=\"" + escapeString(*git) + "\" />\n"; for ( QMap<QString, CategoryGroup>::ConstIterator appsIt=mAppCats.begin(); appsIt != mAppCats.end(); ++appsIt ) { const QString &app = appsIt.key(); const QMap<int, QString> &appcats = (*appsIt).idMap(); for ( QMap<int, QString>::ConstIterator appcatit = appcats.begin(); appcatit != appcats.end(); ++appcatit ) - ts << "<Category id=\"" << appcatit.key() << "\"" - << " app=\"" << escapeString(app) << "\"" - << " name=\"" << escapeString(*appcatit) << "\" />" << endl; + out += "<Category id=\"" + QString::number(appcatit.key()) + "\"" + + " app=\"" + escapeString(app) + "\"" + + " name=\"" + escapeString(*appcatit) + "\" />\n"; + } + out += "</Categories>\n"; + + QCString cstr = out.utf8(); + total_written = f.writeBlock( cstr.data(), cstr.length() ); + if ( total_written != int(cstr.length()) ) { + f.close(); + QFile::remove( strNewFile ); + return FALSE; + } + f.close(); + + if ( ::rename( strNewFile.latin1(), fname.latin1() ) < 0 ) { + qWarning( "problem renaming file %s to %s", + strNewFile.latin1(), fname.latin1()); + // remove the tmp file... + QFile::remove( strNewFile ); } - ts << "</Categories>" << endl; - file.close(); return TRUE; } bool Categories::load( const QString &fname ) { QFile file( fname ); if ( !file.open( IO_ReadOnly ) ) { qWarning("Unable to open %s", fname.latin1()); + + addGlobalCategory(tr("Business")); + addGlobalCategory(tr("Personal")); + save(fname); + return FALSE; } clear(); QByteArray ba = file.readAll(); QString data = QString::fromUtf8( ba.data(), ba.size() ); QChar *uc = (QChar *)data.unicode(); int len = data.length(); // QTime t; // t.start(); QString name; QString id; QString app; int i = 0; while ( (i = data.find( "<Category ", i)) != -1 ) { i += 10; name = QString::null; app = QString::null; while ( 1 ) { // skip white space while ( i < len && (uc[i] == ' ' || uc[i] == '\n' || uc[i] == '\r') ) i++; // if at the end, then done if ( i >= len-2 || (uc[i] == '/' && uc[i+1] == '>') ) break; // we have another attribute read it. int j = i; while ( j < len && uc[j] != '=' ) j++; QString attr = QConstString( uc+i, j-i ).string(); i = ++j; // skip = while ( i < len && uc[i] != '"' ) i++; j = ++i; while ( j < len && uc[j] != '"' ) j++; QString value = Qtopia::plainString( QConstString( uc+i, j-i ).string() ); i = j + 1; // qDebug("attr='%s' value='%s'", attr.latin1(), value.latin1() ); if ( attr == "id" ) id = value; else if ( attr == "app" ) app = value; diff --git a/library/backend/categories.h b/library/backend/categories.h index 82d765b..ba65ee3 100644 --- a/library/backend/categories.h +++ b/library/backend/categories.h @@ -26,182 +26,176 @@ #include <qstringlist.h> #include <qmap.h> #include <qlistview.h> #include <qarray.h> #include "qpcglobal.h" #include "palmtopuidgen.h" class CategoryGroup; #if defined(QPC_TEMPLATEDLL) // MOC_SKIP_BEGIN template class QPC_EXPORT QMap<int, QString>; template class QPC_EXPORT QMap<QString, int>; template class QPC_EXPORT QMap< QString, CategoryGroup >; // MOC_SKIP_END #endif class QPC_EXPORT CategoryGroup { friend class Categories; public: CategoryGroup(): mIdLabelMap(), mLabelIdMap() { } CategoryGroup( const CategoryGroup &c ) : mIdLabelMap( c.mIdLabelMap), mLabelIdMap( c.mLabelIdMap ) { } void clear() { mIdLabelMap.clear(); mLabelIdMap.clear(); } int add( const QString &label ); bool add( int uid, const QString &label ); bool remove( const QString &label ); bool remove( int uid ); bool rename( int uid, const QString &newLabel ); bool rename( const QString &oldLabel, const QString &newLabel ); bool contains(int id) const; bool contains(const QString &label) const; /** Returns label associated with the uid or QString::null if * not found */ const QString &label(int id) const; /** Returns the uid associated with label or 0 if not found */ int id(const QString &label) const; /** Returns a sorted list of labels */ QStringList labels() const; - QArray<int> ids( const QStringList &cats ) const; - QArray<int> ids() const; + QStringList labels( const QArray<int> &catids ) const; const QMap<int, QString> &idMap() const { return mIdLabelMap; } private: void insert( int uid, const QString &label ); QMap<int, QString> mIdLabelMap; QMap<QString, int> mLabelIdMap; static Qtopia::UidGen &uidGen() { return sUidGen; } static Qtopia::UidGen sUidGen; }; /** Map from application name to categories */ class QPC_EXPORT Categories : public QObject { Q_OBJECT public: Categories( QObject *parent=0, const char *name = 0 ) : QObject( parent, name ), mGlobalCats(), mAppCats() { } Categories( const Categories ©From ) : QObject( copyFrom.parent() ), mGlobalCats( copyFrom.mGlobalCats ), mAppCats( copyFrom.mAppCats ) { } virtual ~Categories() { } Categories &operator= ( const Categories &c ) { mAppCats = c.mAppCats; mGlobalCats = c.mGlobalCats; return *this; } void clear(); /** Add the category name as long as it doesn't already exist * locally or globally. Return UID if added, 0 if conflicts * (error). */ int addCategory( const QString &appname, const QString &catname); /** Add the category name as long as it doesn't already exist * locally or globally. Return UID if added, 0 if conflicts * (error). */ int addCategory( const QString &appname, const QString &catname, int uid); /** Add the global category just checking that it doesn't * already exist globally. Return UID if added, 0 if conflicts. */ int addGlobalCategory( const QString &catname ); /** Add the global category just checking that it doesn't * already exist globally. Return UID if added, 0 if conflicts. */ int addGlobalCategory( const QString &catname, int uid ); /** Removes the category from the application; if it is not found * in the application, then it removes it from the global list */ bool removeCategory( const QString &appName, const QString &catName, bool checkGlobal = TRUE); bool removeCategory( const QString &appName, int uid ); bool removeGlobalCategory( const QString &catName ); bool removeGlobalCategory( int uid ); - QArray<int> ids( const QString &app ) const; - QArray<int> ids( const QString &app, - const QStringList &cats ) const; + QArray<int> ids( const QString &app, const QStringList &labels) const; + /** Returns the id associated with the app */ int id( const QString &app, const QString &cat ) const; /** Returns the label associated with the id */ QString label( const QString &app, int id ) const; enum ExtraLabels { NoExtra, AllUnfiled, AllLabel, UnfiledLabel }; /** Returns the sorted list of all categories that are * associated with the app. * If includeGlobal parameter is TRUE then the returned * categories will include the global category items. * If extra = NoExtra, then * If extra = AllUnfiled, then All and Unfiled will be prepended to * the list * If extra = AllLabel, then All is prepended * If extra = UnfiledLabel, then Unfiled is prepended */ QStringList labels( const QString &app, bool includeGlobal = TRUE, ExtraLabels extra = NoExtra ) const; - /** Returns the labels of the categories associated with the uids */ - QStringList labels( const QString & app, - const QArray<int> &catids ) const; - enum DisplaySingle { ShowMulti, ShowAll, ShowFirst }; /** Returns a single string associated with the cat ids for display in * a combobox or any area that requires one string. If catids are empty * then "Unfiled" will be returned. If multiple categories are assigned * then the behavior depends on the DisplaySingle type. * If /a display is set to ShowMulti then " (multi)" appended to the * first string. If /a display is set to ShowAll, then a space seperated * string is returned with all categories. If ShowFirst is returned, * the just the first string is returned. */ QString displaySingle( const QString &app, const QArray<int> &catids, DisplaySingle display ) const; QStringList globalCategories() const { return mGlobalCats.labels();} bool renameCategory( const QString &appname, const QString &oldName, const QString &newName ); bool renameGlobalCategory( const QString &oldName, const QString &newName ); void setGlobal( const QString &appname, const QString &catname, bool value ); bool isGlobal( const QString &catname ) const; /** Returns true if the catname is associated with any application */ bool exists( const QString &catname ) const; bool exists( const QString &appname, const QString &catname) const; bool save( const QString &fname ) const; bool load( const QString &fname ); // for debugging void dump() const; const QMap<QString, CategoryGroup> &appGroupMap() const{ return mAppCats; } const CategoryGroup &globalGroup() const { return mGlobalCats; } signals: /** emitted if added a category; * the second param is the application the category was added to * or null if global * the third param is the uid of the newly added category */ diff --git a/library/backend/contact.cpp b/library/backend/contact.cpp index a5f10ab..b10b19a 100644 --- a/library/backend/contact.cpp +++ b/library/backend/contact.cpp @@ -1,71 +1,73 @@ /********************************************************************** ** Copyright (C) 2001 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +#define QTOPIA_INTERNAL_CONTACT_MRE + #include "contact.h" -#include "vobject_p.h"
-#include "qfiledirect_p.h"
+#include "vobject_p.h" +#include "qfiledirect_p.h" #include <qpe/stringutil.h> #include <qpe/timeconversion.h> #include <qobject.h> #include <qregexp.h> #include <qstylesheet.h> #include <qfileinfo.h> #include <stdio.h> Qtopia::UidGen Contact::sUidGen( Qtopia::UidGen::Qtopia ); Contact::Contact() : Record(), mMap(), d( 0 ) { } Contact::Contact( const QMap<int, QString> &fromMap ) : Record(), mMap( fromMap ), d( 0 ) { QString cats = mMap[ Qtopia::AddressCategory ]; if ( !cats.isEmpty() ) setCategories( idsFromString( cats ) ); QString uidStr = find( Qtopia::AddressUid ); if ( uidStr.isEmpty() ) setUid( uidGen().generate() ); else setUid( uidStr.toInt() ); } Contact::~Contact() { } QMap<int, QString> Contact::toMap() const { QMap<int, QString> map = mMap; map.insert( Qtopia::AddressCategory, idsToString( categories() )); return map; } /*! Returns a rich text formatted QString of the Contact. */ QString Contact::toRichText() const { QString text; @@ -341,189 +343,197 @@ void Contact::setFileAs() && !middleName.isEmpty() ) fileas = lastName + ", " + firstName + " " + middleName; else if ( !lastName.isEmpty() && !firstName.isEmpty() ) fileas = lastName + ", " + firstName; else if ( !lastName.isEmpty() || !firstName.isEmpty() || !middleName.isEmpty() ) fileas = firstName + ( firstName.isEmpty() ? "" : " " ) + middleName + ( middleName.isEmpty() ? "" : " " ) + lastName; replace( Qtopia::FileAs, fileas ); } void Contact::save( QString &buf ) const { static const QStringList SLFIELDS = fields(); // I'm expecting "<Contact " in front of this... for ( QMap<int, QString>::ConstIterator it = mMap.begin(); it != mMap.end(); ++it ) { const QString &value = it.data(); int key = it.key(); if ( !value.isEmpty() ) { if ( key == Qtopia::AddressCategory || key == Qtopia::AddressUid) continue; key -= Qtopia::AddressCategory+1; buf += SLFIELDS[key]; buf += "=\"" + Qtopia::escapeString(value) + "\" "; } } buf += customToXml(); if ( categories().count() > 0 ) buf += "Categories=\"" + idsToString( categories() ) + "\" "; buf += "Uid=\"" + QString::number( uid() ) + "\" "; // You need to close this yourself } QStringList Contact::fields() { QStringList list; list.append( "Title" ); // Not Used! list.append( "FirstName" ); list.append( "MiddleName" ); list.append( "LastName" ); list.append( "Suffix" ); list.append( "FileAs" ); + list.append( "JobTitle" ); + list.append( "Department" ); + list.append( "Company" ); + list.append( "BusinessPhone" ); + list.append( "BusinessFax" ); + list.append( "BusinessMobile" ); + list.append( "DefaultEmail" ); list.append( "Emails" ); - list.append( "HomeStreet" ); - list.append( "HomeCity" ); - list.append( "HomeState" ); - list.append( "HomeZip" ); - list.append( "HomeCountry" ); list.append( "HomePhone" ); list.append( "HomeFax" ); list.append( "HomeMobile" ); - list.append( "HomeWebPage" ); - list.append( "Company" ); list.append( "BusinessStreet" ); list.append( "BusinessCity" ); list.append( "BusinessState" ); list.append( "BusinessZip" ); list.append( "BusinessCountry" ); + list.append( "BusinessPager" ); list.append( "BusinessWebPage" ); - list.append( "JobTitle" ); - list.append( "Department" ); + list.append( "Office" ); - list.append( "BusinessPhone" ); - list.append( "BusinessFax" ); - list.append( "BusinessMobile" ); - list.append( "BusinessPager" ); list.append( "Profession" ); list.append( "Assistant" ); list.append( "Manager" ); + list.append( "HomeStreet" ); + list.append( "HomeCity" ); + list.append( "HomeState" ); + list.append( "HomeZip" ); + list.append( "HomeCountry" ); + list.append( "HomeWebPage" ); + list.append( "Spouse" ); list.append( "Gender" ); list.append( "Birthday" ); list.append( "Anniversary" ); list.append( "Nickname" ); - list.append( "Children" ); + list.append( "Notes" ); + list.append( "Groups" ); return list; } QStringList Contact::trfields() { QStringList list; list.append( QObject::tr( "Name Title") ); list.append( QObject::tr( "First Name" ) ); list.append( QObject::tr( "Middle Name" ) ); list.append( QObject::tr( "Last Name" ) ); list.append( QObject::tr( "Suffix" ) ); list.append( QObject::tr( "File As" ) ); + list.append( QObject::tr( "Job Title" ) ); + list.append( QObject::tr( "Department" ) ); + list.append( QObject::tr( "Company" ) ); + list.append( QObject::tr( "Business Phone" ) ); + list.append( QObject::tr( "Business Fax" ) ); + list.append( QObject::tr( "Business Mobile" ) ); + list.append( QObject::tr( "Default Email" ) ); list.append( QObject::tr( "Emails" ) ); - list.append( QObject::tr( "Home Street" ) ); - list.append( QObject::tr( "Home City" ) ); - list.append( QObject::tr( "Home State" ) ); - list.append( QObject::tr( "Home Zip" ) ); - list.append( QObject::tr( "Home Country" ) ); list.append( QObject::tr( "Home Phone" ) ); list.append( QObject::tr( "Home Fax" ) ); list.append( QObject::tr( "Home Mobile" ) ); - list.append( QObject::tr( "Home Web Page" ) ); - list.append( QObject::tr( "Company" ) ); list.append( QObject::tr( "Business Street" ) ); list.append( QObject::tr( "Business City" ) ); list.append( QObject::tr( "Business State" ) ); list.append( QObject::tr( "Business Zip" ) ); list.append( QObject::tr( "Business Country" ) ); + list.append( QObject::tr( "Business Pager" ) ); list.append( QObject::tr( "Business WebPage" ) ); - list.append( QObject::tr( "Job Title" ) ); - list.append( QObject::tr( "Department" ) ); + list.append( QObject::tr( "Office" ) ); - list.append( QObject::tr( "Business Phone" ) ); - list.append( QObject::tr( "Business Fax" ) ); - list.append( QObject::tr( "Business Mobile" ) ); - list.append( QObject::tr( "Business Pager" ) ); list.append( QObject::tr( "Profession" ) ); list.append( QObject::tr( "Assistant" ) ); list.append( QObject::tr( "Manager" ) ); + list.append( QObject::tr( "Home Street" ) ); + list.append( QObject::tr( "Home City" ) ); + list.append( QObject::tr( "Home State" ) ); + list.append( QObject::tr( "Home Zip" ) ); + list.append( QObject::tr( "Home Country" ) ); + list.append( QObject::tr( "Home Web Page" ) ); + list.append( QObject::tr( "Spouse" ) ); list.append( QObject::tr( "Gender" ) ); list.append( QObject::tr( "Birthday" ) ); list.append( QObject::tr( "Anniversary" ) ); list.append( QObject::tr( "Nickname" ) ); - list.append( QObject::tr( "Children" ) ); + list.append( QObject::tr( "Notes" ) ); + list.append( QObject::tr( "Groups" ) ); return list; } void Contact::setEmails( const QString &v ) { replace( Qtopia::Emails, v ); if ( v.isEmpty() ) setDefaultEmail( QString::null ); } void Contact::setChildren( const QString &v ) { replace( Qtopia::Children, v ); } // vcard conversion code static inline VObject *safeAddPropValue( VObject *o, const char *prop, const QString &value ) { VObject *ret = 0; if ( o && !value.isEmpty() ) ret = addPropValue( o, prop, value.latin1() ); return ret; } static inline VObject *safeAddProp( VObject *o, const char *prop) { VObject *ret = 0; if ( o ) ret = addProp( o, prop ); return ret; } static VObject *createVObject( const Contact &c ) { VObject *vcard = newVObject( VCCardProp ); safeAddPropValue( vcard, VCVersionProp, "2.1" ); safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); // full name safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); // name properties VObject *name = safeAddProp( vcard, VCNameProp ); safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); safeAddPropValue( name, VCGivenNameProp, c.firstName() ); safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); @@ -584,326 +594,331 @@ static VObject *createVObject( const Contact &c ) for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); safeAddProp( email, VCInternetProp ); } safeAddPropValue( vcard, VCNoteProp, c.notes() ); safeAddPropValue( vcard, VCBirthDateProp, c.birthday() ); if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { VObject *org = safeAddProp( vcard, VCOrgProp ); safeAddPropValue( org, VCOrgNameProp, c.company() ); safeAddPropValue( org, VCOrgUnitProp, c.department() ); safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); } // some values we have to export as custom fields safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); safeAddPropValue( vcard, "X-Qtopia-Anniversary", c.anniversary() ); safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); return vcard; } static Contact parseVObject( VObject *obj ) { Contact c; bool haveDefaultEmail = FALSE; VObjectIterator it; initPropIterator( &it, obj ); while( moreIteration( &it ) ) { VObject *o = nextVObject( &it ); QCString name = vObjectName( o ); QCString value = vObjectStringZValue( o ); if ( name == VCNameProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); QString value = vObjectStringZValue( o ); if ( name == VCNamePrefixesProp ) c.setTitle( value ); else if ( name == VCNameSuffixesProp ) c.setSuffix( value ); else if ( name == VCFamilyNameProp ) c.setLastName( value ); else if ( name == VCGivenNameProp ) c.setFirstName( value ); else if ( name == VCAdditionalNamesProp ) c.setMiddleName( value ); } } else if ( name == VCAdrProp ) { bool work = TRUE; // default address is work address QString street; QString city; QString region; QString postal; QString country; VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); if ( name == VCHomeProp ) work = FALSE; else if ( name == VCWorkProp ) work = TRUE; else if ( name == VCStreetAddressProp ) street = value; else if ( name == VCCityProp ) city = value; else if ( name == VCRegionProp ) region = value; else if ( name == VCPostalCodeProp ) postal = value; else if ( name == VCCountryNameProp ) country = value; } if ( work ) { c.setBusinessStreet( street ); c.setBusinessCity( city ); c.setBusinessCountry( country ); c.setBusinessZip( postal ); c.setBusinessState( region ); } else { c.setHomeStreet( street ); c.setHomeCity( city ); c.setHomeCountry( country ); c.setHomeZip( postal ); c.setHomeState( region ); } } else if ( name == VCTelephoneProp ) { enum { HOME = 0x01, WORK = 0x02, VOICE = 0x04, CELL = 0x08, FAX = 0x10, PAGER = 0x20, UNKNOWN = 0x80 }; int type = 0; VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); if ( name == VCHomeProp ) type |= HOME; else if ( name == VCWorkProp ) type |= WORK; else if ( name == VCVoiceProp ) type |= VOICE; else if ( name == VCCellularProp ) type |= CELL; else if ( name == VCFaxProp ) type |= FAX; else if ( name == VCPagerProp ) type |= PAGER; else if ( name == VCPreferredProp ) ; else type |= UNKNOWN; } if ( (type & UNKNOWN) != UNKNOWN ) { if ( ( type & (HOME|WORK) ) == 0 ) // default type |= HOME; if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default type |= VOICE; if ( (type & (VOICE|HOME) ) == (VOICE|HOME) ) c.setHomePhone( value ); if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) c.setHomeFax( value ); if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) c.setHomeMobile( value ); if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) ) c.setBusinessPhone( value ); if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) c.setBusinessFax( value ); if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) c.setBusinessMobile( value ); if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) c.setBusinessPager( value ); } } else if ( name == VCEmailAddressProp ) { QString email = vObjectStringZValue( o ); bool valid = TRUE; VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); if ( name != VCInternetProp && name != VCHomeProp && name != VCWorkProp && name != VCPreferredProp ) // ### preffered should map to default email valid = FALSE; } if ( valid ) { if ( haveDefaultEmail ) { QString str = c.emails(); if ( !str.isEmpty() ) str += ","+email; c.setEmails( str ); } else { c.setDefaultEmail( email ); } } } else if ( name == VCURLProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); - QCString name = vObjectName( o ); + QCString name = vObjectTypeInfo( o ); if ( name == VCHomeProp ) c.setHomeWebpage( value ); else if ( name == VCWorkProp ) c.setBusinessWebpage( value ); } } else if ( name == VCOrgProp ) { VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); if ( name == VCOrgNameProp ) c.setCompany( value ); else if ( name == VCOrgUnitProp ) c.setDepartment( value ); else if ( name == VCOrgUnit2Prop ) c.setOffice( value ); } } else if ( name == VCTitleProp ) { c.setJobTitle( value ); } else if ( name == "X-Qtopia-Profession" ) { c.setProfession( value ); } else if ( name == "X-Qtopia-Manager" ) { c.setManager( value ); } else if ( name == "X-Qtopia-Assistant" ) { c.setAssistant( value ); } else if ( name == "X-Qtopia-Spouse" ) { c.setSpouse( value ); } else if ( name == "X-Qtopia-Gender" ) { c.setGender( value ); } else if ( name == "X-Qtopia-Anniversary" ) { c.setAnniversary( value ); } else if ( name == "X-Qtopia-Nickname" ) { c.setNickname( value ); } else if ( name == "X-Qtopia-Children" ) { c.setChildren( value ); } #if 0 else { printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); VObjectIterator nit; initPropIterator( &nit, o ); while( moreIteration( &nit ) ) { VObject *o = nextVObject( &nit ); QCString name = vObjectName( o ); QString value = vObjectStringZValue( o ); printf(" subprop: %s = %s\n", name.data(), value.latin1() ); } } #endif } c.setFileAs(); return c; } void Contact::writeVCard( const QString &filename, const QValueList<Contact> &contacts) -{
- QFileDirect f( filename.utf8().data() );
- if ( !f.open( IO_WriteOnly ) ) {
- qWarning("Unable to open vcard write");
- return;
- }
+{ + QFileDirect f( filename.utf8().data() ); + if ( !f.open( IO_WriteOnly ) ) { + qWarning("Unable to open vcard write"); + return; + } QValueList<Contact>::ConstIterator it; for( it = contacts.begin(); it != contacts.end(); ++it ) { VObject *obj = createVObject( *it ); writeVObject(f.directHandle() , obj ); cleanVObject( obj ); } cleanStrTbl(); } void Contact::writeVCard( const QString &filename, const Contact &contact) -{
- QFileDirect f( filename.utf8().data() );
- if ( !f.open( IO_WriteOnly ) ) {
- qWarning("Unable to open vcard write");
- return;
- }
+{ + QFileDirect f( filename.utf8().data() ); + if ( !f.open( IO_WriteOnly ) ) { + qWarning("Unable to open vcard write"); + return; + } VObject *obj = createVObject( contact ); writeVObject( f.directHandle() , obj ); cleanVObject( obj ); cleanStrTbl(); } QValueList<Contact> Contact::readVCard( const QString &filename ) { qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); qDebug("vobject = %p", obj ); QValueList<Contact> contacts; while ( obj ) { contacts.append( parseVObject( obj ) ); VObject *t = obj; obj = nextVObjectInList(obj); cleanVObject( t ); } return contacts; } +bool Contact::match( const QString ®exp ) const +{ + return match(QRegExp(regexp)); +} + bool Contact::match( const QRegExp &r ) const { bool match; match = false; QMap<int, QString>::ConstIterator it; for ( it = mMap.begin(); it != mMap.end(); ++it ) { if ( (*it).find( r ) > -1 ) { match = true; break; } } return match; } diff --git a/library/backend/contact.h b/library/backend/contact.h index 6abdab6..a74cbbe 100644 --- a/library/backend/contact.h +++ b/library/backend/contact.h @@ -56,97 +56,102 @@ public: void setFileAs(); // default email address void setDefaultEmail( const QString &v ) { replace( Qtopia::DefaultEmail, v ); } // the emails should be seperated by a semicolon void setEmails( const QString &v ); // home void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } // business void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } // personal void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } void setBirthday( const QString &v ) { replace( Qtopia::Birthday, v ); } void setAnniversary( const QString &v ) { replace( Qtopia::Anniversary, v ); } void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } void setChildren( const QString &v ); // other void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } - bool match( const QRegExp &r ) const; + bool match( const QString ®exp ) const; + +// DON'T ATTEMPT TO USE THIS +#ifdef QTOPIA_INTERNAL_CONTACT_MRE + bool match( const QRegExp ®exp ) const; +#endif // // custom // void setCustomField( const QString &key, const QString &v ) // { replace(Custom- + key, v ); } // name QString fullName() const; QString title() const { return find( Qtopia::Title ); } QString firstName() const { return find( Qtopia::FirstName ); } QString middleName() const { return find( Qtopia::MiddleName ); } QString lastName() const { return find( Qtopia::LastName ); } QString suffix() const { return find( Qtopia::Suffix ); } QString fileAs() const { return find( Qtopia::FileAs ); } // email QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } QString emails() const { return find( Qtopia::Emails ); } QStringList emailList() const; // home QString homeStreet() const { return find( Qtopia::HomeStreet ); } QString homeCity() const { return find( Qtopia::HomeCity ); } QString homeState() const { return find( Qtopia::HomeState ); } QString homeZip() const { return find( Qtopia::HomeZip ); } QString homeCountry() const { return find( Qtopia::HomeCountry ); } QString homePhone() const { return find( Qtopia::HomePhone ); } QString homeFax() const { return find( Qtopia::HomeFax ); } QString homeMobile() const { return find( Qtopia::HomeMobile ); } QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } /** Multi line string containing all non-empty address info in the form * Street * City, State Zip * Country */ QString displayHomeAddress() const; // business QString company() const { return find( Qtopia::Company ); } QString businessStreet() const { return find( Qtopia::BusinessStreet ); } QString businessCity() const { return find( Qtopia::BusinessCity ); } QString businessState() const { return find( Qtopia::BusinessState ); } QString businessZip() const { return find( Qtopia::BusinessZip ); } QString businessCountry() const { return find( Qtopia::BusinessCountry ); } QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } QString jobTitle() const { return find( Qtopia::JobTitle ); } QString department() const { return find( Qtopia::Department ); } QString office() const { return find( Qtopia::Office ); } QString businessPhone() const { return find( Qtopia::BusinessPhone ); } diff --git a/library/backend/event.h b/library/backend/event.h index 0ebe9ea..277aadd 100644 --- a/library/backend/event.h +++ b/library/backend/event.h @@ -95,97 +95,102 @@ public: time_t endTime() const { return endUTC; } void setTimeZone( const QString & ); const QString &timeZone() const; void setAlarm( bool b, int minutes, SoundTypeChoice ); bool hasAlarm() const; int alarmTime() const; SoundTypeChoice alarmSound() const; void setRepeat( bool b, const RepeatPattern &p ); void setRepeat( const RepeatPattern &p ); bool hasRepeat() const; const RepeatPattern &repeatPattern() const; RepeatPattern &repeatPattern(); void setNotes( const QString &n ); const QString ¬es() const; bool doRepeat() const { return pattern.type != NoRepeat; } void save( QString& buf ); //void load( Node *n ); // helper function to calculate the week of the given date static int week( const QDate& date ); // calculates the number of occurrences of the week day of // the given date from the start of the month static int occurrence( const QDate& date ); // returns a proper days-char for a given dayOfWeek() static char day( int dayOfWeek ) { return 1 << ( dayOfWeek - 1 ); } // returns the dayOfWeek for the *first* day it finds (ignores // any further days!). Returns 1 (Monday) if there isn't any day found static int dayOfWeek( char day ); // returns the difference of months from first to second. static int monthDiff( const QDate& first, const QDate& second ); bool match( const QRegExp &r ) const; private: Qtopia::UidGen &uidGen() { return sUidGen; } static Qtopia::UidGen sUidGen; QString descript, locat, categ; Type typ : 4; bool startTimeDirty : 1; bool endTimeDirty : 1; time_t startUTC, endUTC; QString tz; bool hAlarm, hRepeat; int aMinutes; SoundTypeChoice aSound; RepeatPattern pattern; QString note; + // ADDITION + int mRid; // Recode ID + int mRinfo; // Recode Info + // EventPrivate *d; + }; // Since an event spans multiple day, it is better to have this // class to represent a day instead of creating many // dummy events... class EffectiveEventPrivate; class QPC_EXPORT EffectiveEvent { public: // If we calculate the effective event of a multi-day event // we have to figure out whether we are at the first day, // at the end, or anywhere else ("middle"). This is important // for the start/end times (00:00/23:59) // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi- // day event // Start: start time -> 23:59 // End: 00:00 -> end time // Start | End == StartEnd: for single-day events (default) // here we draw start time -> end time enum Position { MidWay = 0, Start = 1, End = 2, StartEnd = 3 }; EffectiveEvent(); EffectiveEvent( const Event &event, const QDate &startDate, Position pos = StartEnd ); EffectiveEvent( const EffectiveEvent & ); EffectiveEvent& operator=( const EffectiveEvent & ); ~EffectiveEvent(); bool operator<( const EffectiveEvent &e ) const; bool operator<=( const EffectiveEvent &e ) const; bool operator==( const EffectiveEvent &e ) const; bool operator!=( const EffectiveEvent &e ) const; bool operator>( const EffectiveEvent &e ) const; bool operator>= ( const EffectiveEvent &e ) const; void setStart( const QTime &start ); void setEnd( const QTime &end ); void setEvent( Event e ); void setDate( const QDate &date ); void setEffectiveDates( const QDate &from, const QDate &to ); // QString category() const; const QString &description() const; const QString &location() const; const QString ¬es() const; const Event &event() const; const QTime &start() const; diff --git a/library/backend/recordfields.h b/library/backend/recordfields.h index 3cddde2..4196c8b 100644 --- a/library/backend/recordfields.h +++ b/library/backend/recordfields.h @@ -1,135 +1,149 @@ /********************************************************************** ** Copyright (C) 2000 Trolltech AS. All rights reserved. ** ** This file is part of Qtopia Environment. ** ** Licensees holding valid Qtopia Developer license may use this ** file in accordance with the Qtopia Developer License Agreement ** provided with the Software. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING ** THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR ** PURPOSE. ** ** email sales@trolltech.com for information about Qtopia License ** Agreements. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QPC_RECORD_FIELDS_H #define QPC_RECORD_FIELDS_H #include "qpcglobal.h" // dataset = "addressbook" namespace Qtopia { static const int UID_ID = 0; static const int CATEGORY_ID = 1; enum AddressBookFields { AddressUid = UID_ID, AddressCategory = CATEGORY_ID, - + + // NOTE: Order of fields dependency in backend/contact.cpp + Title, FirstName, MiddleName, LastName, Suffix, FileAs, + JobTitle, + Department, + Company, + BusinessPhone, + BusinessFax, + BusinessMobile, + // email DefaultEmail, Emails, - // home - HomeStreet, - HomeCity, - HomeState, - HomeZip, - HomeCountry, HomePhone, HomeFax, HomeMobile, - HomeWebPage, // business - Company, BusinessStreet, BusinessCity, BusinessState, BusinessZip, BusinessCountry, + BusinessPager, BusinessWebPage, - JobTitle, - Department, + Office, - BusinessPhone, - BusinessFax, - BusinessMobile, - BusinessPager, Profession, Assistant, Manager, + // home + HomeStreet, + HomeCity, + HomeState, + HomeZip, + HomeCountry, + HomeWebPage, + //personal Spouse, Gender, Birthday, Anniversary, Nickname, Children, // other Notes, Groups + + ,rid, + rinfo }; // dataset = "todolist" enum TaskFields { TaskUid = UID_ID, TaskCategory = CATEGORY_ID, HasDate, Completed, TaskDescription, Priority, - Date + Date, + + TaskRid, + TaskRinfo }; // dataset = "categories" for todos enum CategoryFields { CatUid = UID_ID, CatName, CatAppGroup }; // dataset = "datebook" enum DatebookFields { DatebookUid = UID_ID, DatebookCategory = CATEGORY_ID, DatebookDescription, Location, TimeZone, Note, StartDateTime, EndDateTime, DatebookType, HasAlarm, SoundType, AlarmTime, RepeatPatternType, RepeatPatternFrequency, RepeatPatternPosition, RepeatPatternDays, RepeatPatternHasEndDate, RepeatPatternEndDate, + + DateBookRid, + DateBookRinfo }; }; #endif diff --git a/library/backend/task.h b/library/backend/task.h index ffe26b0..6f383b8 100644 --- a/library/backend/task.h +++ b/library/backend/task.h @@ -27,51 +27,55 @@ #include <qdatetime.h> class TaskPrivate; class QPC_EXPORT Task : public Qtopia::Record { public: Task(); Task( const QMap<int, QString> &fromMap ); ~Task(); QMap<int, QString> toMap() const; static void writeVCalendar( const QString &filename, const QValueList<Task> &tasks); static void writeVCalendar( const QString &filename, const Task &task); static QValueList<Task> readVCalendar( const QString &filename ); void setPriority( int priority ) { mPriority = priority; } int priority() const { return mPriority; } // void setCategory( const QString& category ) // { mCategory = category.stripWhiteSpace(); } // const QString &category() const { return mCategory; } void setDescription( const QString& description ) { mDesc = Qtopia::simplifyMultiLineSpace(description); } const QString &description() const { return mDesc; } void setDueDate( const QDate& date, bool hasDue ) { mDueDate = date; mDue = hasDue; } const QDate &dueDate() const { return mDueDate; } bool hasDueDate() const { return mDue; } void setHasDueDate( bool b ) { mDue = b; } void setCompleted( bool b ) { mCompleted = b; } bool isCompleted() const { return mCompleted; } void save( QString& buf ) const; bool match( const QRegExp &r ) const; private: Qtopia::UidGen &uidGen() { return sUidGen; } static Qtopia::UidGen sUidGen; bool mDue; QDate mDueDate; bool mCompleted; int mPriority; QString mDesc; TaskPrivate *d; + // ADDITION + int recordId; + int recordInfo; + // }; #endif diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index af112a7..9c2ba3b 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp @@ -1162,49 +1162,58 @@ static void writeVObject_(OFile *fp, VObject *o) appendsOFile(fp,begin);
appendcOFile(fp,'\n');
initPropIterator(&t,o);
while (moreIteration(&t)) {
VObject *eachProp = nextVObject(&t);
writeProp(fp, eachProp);
}
appendsOFile(fp,"END:");
appendsOFile(fp,begin);
appendsOFile(fp,"\n\n");
}
}
}
void writeVObject(FILE *fp, VObject *o)
{
OFile ofp;
// #####
//_setmode(_fileno(fp), _O_BINARY);
initOFile(&ofp,fp);
writeVObject_(&ofp,o);
}
DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
{
QFileDirect f( fname);
if ( !f.open( IO_WriteOnly ) ) {
qWarning("Unable to open vobject write %s", fname);
return;
}
writeVObject( f.directHandle(),o );
}
DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
{
QFileDirect f( fname);
if ( !f.open( IO_WriteOnly ) ) {
qWarning("Unable to open vobject write %s", fname);
return;
}
while (list) {
writeVObject(f.directHandle(),list);
list = nextVObjectInList(list);
}
}
+DLLEXPORT(const char *) vObjectTypeInfo(VObject *o)
+{
+ const char *type = vObjectName( o );
+ if ( strcmp( type, "TYPE" ) == 0 )
+ type = vObjectStringZValue( o );
+ return type;
+}
+
+
// end of source file vobject.c
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index b6a2c0a..a0d921e 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h @@ -351,51 +351,54 @@ extern DLLEXPORT(int) vObjectValueType(VObject *o); extern const char** fieldedProp;
/***************************************************
* The methods below are implemented in vcc.c (generated from vcc.y )
***************************************************/
/* NOTE regarding printVObject and writeVObject
The functions below are not exported from the DLL because they
take a FILE* as a parameter, which cannot be passed across a DLL
interface (at least that is my experience). Instead you can use
their companion functions which take file names or pointers
to memory. However, if you are linking this code into
your build directly then you may find them a more convenient API
and you can go ahead and use them. If you try to use them with
the DLL LIB you will get a link error.
*/
extern void writeVObject(FILE *fp, VObject *o);
typedef void (*MimeErrorHandler)(char *);
extern DLLEXPORT(void) registerMimeErrorHandler(MimeErrorHandler);
extern DLLEXPORT(VObject*) Parse_MIME(const char *input, unsigned long len);
extern DLLEXPORT(VObject*) Parse_MIME_FromFileName(char* fname);
/* NOTE regarding Parse_MIME_FromFile
The function above, Parse_MIME_FromFile, comes in two flavors,
neither of which is exported from the DLL. Each version takes
a CFile or FILE* as a parameter, neither of which can be
passed across a DLL interface (at least that is my experience).
If you are linking this code into your build directly then
you may find them a more convenient API that the other flavors
that take a file name. If you use them with the DLL LIB you
will get a link error.
*/
#if INCLUDEMFC
extern VObject* Parse_MIME_FromFile(CFile *file);
#else
extern VObject* Parse_MIME_FromFile(FILE *file);
#endif
+extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
+
+
#endif /* __VOBJECT_H__ */
|