summaryrefslogtreecommitdiff
path: root/library/backend
authorkergoth <kergoth>2002-06-07 18:53:14 (UTC)
committer kergoth <kergoth>2002-06-07 18:53:14 (UTC)
commit640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (side-by-side diff)
tree9a784686c1795f8b1f81eb344598f3b549d43467 /library/backend
parentdfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff)
downloadopie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip
opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz
opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2
Backing out unintentional merge from TT branch.
Diffstat (limited to 'library/backend') (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/categories.cpp146
-rw-r--r--library/backend/categories.h12
-rw-r--r--library/backend/contact.cpp107
-rw-r--r--library/backend/contact.h7
-rw-r--r--library/backend/event.h5
-rw-r--r--library/backend/recordfields.h46
-rw-r--r--library/backend/task.h4
-rw-r--r--library/backend/vobject.cpp9
-rw-r--r--library/backend/vobject_p.h3
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
@@ -171,36 +171,6 @@ QStringList CategoryGroup::labels(const QArray<int> &catids ) const
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
@@ -343,6 +313,14 @@ QStringList Categories::labels( const QString &app,
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:
@@ -356,14 +334,7 @@ QStringList Categories::labels( const QString &app,
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;
}
@@ -378,14 +349,6 @@ QString Categories::label( const QString &app, int id ) const
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
@@ -417,33 +380,21 @@ QString Categories::displaySingle( const QString &app,
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
@@ -539,23 +490,28 @@ bool Categories::exists( const QString &appname,
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 ) {
@@ -563,13 +519,28 @@ bool Categories::save( const QString &fname ) const
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;
}
@@ -578,6 +549,11 @@ 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;
}
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
@@ -71,8 +71,7 @@ public:
/** 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; }
@@ -130,9 +129,8 @@ public:
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 */
@@ -153,10 +151,6 @@ public:
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
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
@@ -18,9 +18,11 @@
**
**********************************************************************/
+#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>
@@ -386,45 +388,49 @@ QStringList Contact::fields()
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;
}
@@ -440,45 +446,49 @@ QStringList Contact::trfields()
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;
}
@@ -629,7 +639,7 @@ static Contact parseVObject( VObject *obj )
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 );
@@ -702,7 +712,7 @@ static Contact parseVObject( VObject *obj )
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 )
@@ -749,7 +759,7 @@ static Contact parseVObject( VObject *obj )
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 )
@@ -772,7 +782,7 @@ static Contact parseVObject( VObject *obj )
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 )
@@ -842,12 +852,12 @@ static Contact parseVObject( VObject *obj )
}
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 ) {
@@ -859,12 +869,12 @@ void Contact::writeVCard( const QString &filename, const QValueList<Contact> &co
}
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 );
@@ -894,6 +904,11 @@ QValueList<Contact> Contact::readVCard( const QString &filename )
return contacts;
}
+bool Contact::match( const QString &regexp ) const
+{
+ return match(QRegExp(regexp));
+}
+
bool Contact::match( const QRegExp &r ) const
{
bool 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
@@ -101,7 +101,12 @@ public:
// other
void setNotes( const QString &v ) { replace( Qtopia::Notes, v); }
- bool match( const QRegExp &r ) const;
+ bool match( const QString &regexp ) const;
+
+// DON'T ATTEMPT TO USE THIS
+#ifdef QTOPIA_INTERNAL_CONTACT_MRE
+ bool match( const QRegExp &regexp ) const;
+#endif
// // custom
// void setCustomField( const QString &key, const QString &v )
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
@@ -140,7 +140,12 @@ private:
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
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
@@ -31,7 +31,9 @@ namespace Qtopia
enum AddressBookFields {
AddressUid = UID_ID,
AddressCategory = CATEGORY_ID,
-
+
+ // NOTE: Order of fields dependency in backend/contact.cpp
+
Title,
FirstName,
MiddleName,
@@ -39,40 +41,43 @@ namespace Qtopia
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,
@@ -84,6 +89,9 @@ namespace Qtopia
// other
Notes,
Groups
+
+ ,rid,
+ rinfo
};
// dataset = "todolist"
@@ -95,7 +103,10 @@ namespace Qtopia
Completed,
TaskDescription,
Priority,
- Date
+ Date,
+
+ TaskRid,
+ TaskRinfo
};
// dataset = "categories" for todos
@@ -128,6 +139,9 @@ namespace Qtopia
RepeatPatternDays,
RepeatPatternHasEndDate,
RepeatPatternEndDate,
+
+ DateBookRid,
+ DateBookRinfo
};
};
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
@@ -72,6 +72,10 @@ private:
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
@@ -1207,4 +1207,13 @@ DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *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
@@ -396,6 +396,9 @@ extern VObject* Parse_MIME_FromFile(CFile *file);
extern VObject* Parse_MIME_FromFile(FILE *file);
#endif
+extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o);
+
+
#endif /* __VOBJECT_H__ */