-rw-r--r-- | libopie/pim/ocontact.cpp | 5 | ||||
-rw-r--r-- | libopie/pim/ocontact.h | 6 | ||||
-rw-r--r-- | libopie/pim/opimrecord.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecord.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 5 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.h | 6 |
6 files changed, 8 insertions, 18 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index cd238ef..8a0930b 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -1,179 +1,178 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #define QTOPIA_INTERNAL_CONTACT_MRE | 22 | #define QTOPIA_INTERNAL_CONTACT_MRE |
23 | 23 | ||
24 | #include "ocontact.h" | 24 | #include "ocontact.h" |
25 | #include "../../library/backend/vobject_p.h" | 25 | #include "../../library/backend/vobject_p.h" |
26 | #include "../../library/backend/qfiledirect_p.h" | 26 | #include "../../library/backend/qfiledirect_p.h" |
27 | 27 | ||
28 | #include <qpe/stringutil.h> | 28 | #include <qpe/stringutil.h> |
29 | #include <qpe/timeconversion.h> | 29 | #include <qpe/timeconversion.h> |
30 | #include <qpe/timestring.h> | 30 | #include <qpe/timestring.h> |
31 | 31 | ||
32 | #include <qobject.h> | 32 | #include <qobject.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qstylesheet.h> | 34 | #include <qstylesheet.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | #include <stdio.h> | 38 | #include <stdio.h> |
39 | 39 | ||
40 | /*! | 40 | /*! |
41 | \class Contact contact.h | 41 | \class Contact contact.h |
42 | \brief The Contact class holds the data of an address book entry. | 42 | \brief The Contact class holds the data of an address book entry. |
43 | 43 | ||
44 | This data includes information the name of the person, contact | 44 | This data includes information the name of the person, contact |
45 | information, and business information such as deparment and job title. | 45 | information, and business information such as deparment and job title. |
46 | 46 | ||
47 | \ingroup qtopiaemb | 47 | \ingroup qtopiaemb |
48 | \ingroup qtopiadesktop | 48 | \ingroup qtopiadesktop |
49 | */ | 49 | */ |
50 | 50 | ||
51 | Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); | ||
52 | 51 | ||
53 | /*! | 52 | /*! |
54 | Creates a new, empty contact. | 53 | Creates a new, empty contact. |
55 | */ | 54 | */ |
56 | OContact::OContact() | 55 | OContact::OContact() |
57 | : OPimRecord(), mMap(), d( 0 ) | 56 | : OPimRecord(), mMap(), d( 0 ) |
58 | { | 57 | { |
59 | } | 58 | } |
60 | 59 | ||
61 | /*! | 60 | /*! |
62 | \internal | 61 | \internal |
63 | Creates a new contact. The properties of the contact are | 62 | Creates a new contact. The properties of the contact are |
64 | set from \a fromMap. | 63 | set from \a fromMap. |
65 | */ | 64 | */ |
66 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 65 | OContact::OContact( const QMap<int, QString> &fromMap ) : |
67 | OPimRecord(), mMap( fromMap ), d( 0 ) | 66 | OPimRecord(), mMap( fromMap ), d( 0 ) |
68 | { | 67 | { |
69 | QString cats = mMap[ Qtopia::AddressCategory ]; | 68 | QString cats = mMap[ Qtopia::AddressCategory ]; |
70 | if ( !cats.isEmpty() ) | 69 | if ( !cats.isEmpty() ) |
71 | setCategories( idsFromString( cats ) ); | 70 | setCategories( idsFromString( cats ) ); |
72 | 71 | ||
73 | QString uidStr = find( Qtopia::AddressUid ); | 72 | QString uidStr = find( Qtopia::AddressUid ); |
74 | 73 | ||
75 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ | 74 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ |
76 | qWarning( "Invalid UID found. Generate new one.." ); | 75 | qWarning( "Invalid UID found. Generate new one.." ); |
77 | setUid( uidGen().generate() ); | 76 | setUid( uidGen().generate() ); |
78 | }else | 77 | }else |
79 | setUid( uidStr.toInt() ); | 78 | setUid( uidStr.toInt() ); |
80 | 79 | ||
81 | // if ( !uidStr.isEmpty() ) | 80 | // if ( !uidStr.isEmpty() ) |
82 | // setUid( uidStr.toInt() ); | 81 | // setUid( uidStr.toInt() ); |
83 | } | 82 | } |
84 | 83 | ||
85 | /*! | 84 | /*! |
86 | Destroys a contact. | 85 | Destroys a contact. |
87 | */ | 86 | */ |
88 | OContact::~OContact() | 87 | OContact::~OContact() |
89 | { | 88 | { |
90 | } | 89 | } |
91 | 90 | ||
92 | /*! \fn void OContact::setTitle( const QString &str ) | 91 | /*! \fn void OContact::setTitle( const QString &str ) |
93 | Sets the title of the contact to \a str. | 92 | Sets the title of the contact to \a str. |
94 | */ | 93 | */ |
95 | 94 | ||
96 | /*! \fn void OContact::setFirstName( const QString &str ) | 95 | /*! \fn void OContact::setFirstName( const QString &str ) |
97 | Sets the first name of the contact to \a str. | 96 | Sets the first name of the contact to \a str. |
98 | */ | 97 | */ |
99 | 98 | ||
100 | /*! \fn void OContact::setMiddleName( const QString &str ) | 99 | /*! \fn void OContact::setMiddleName( const QString &str ) |
101 | Sets the middle name of the contact to \a str. | 100 | Sets the middle name of the contact to \a str. |
102 | */ | 101 | */ |
103 | 102 | ||
104 | /*! \fn void OContact::setLastName( const QString &str ) | 103 | /*! \fn void OContact::setLastName( const QString &str ) |
105 | Sets the last name of the contact to \a str. | 104 | Sets the last name of the contact to \a str. |
106 | */ | 105 | */ |
107 | 106 | ||
108 | /*! \fn void OContact::setSuffix( const QString &str ) | 107 | /*! \fn void OContact::setSuffix( const QString &str ) |
109 | Sets the suffix of the contact to \a str. | 108 | Sets the suffix of the contact to \a str. |
110 | */ | 109 | */ |
111 | 110 | ||
112 | /*! \fn void OContact::setFileAs( const QString &str ) | 111 | /*! \fn void OContact::setFileAs( const QString &str ) |
113 | Sets the contact to filed as \a str. | 112 | Sets the contact to filed as \a str. |
114 | */ | 113 | */ |
115 | 114 | ||
116 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 115 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
117 | Sets the default email of the contact to \a str. | 116 | Sets the default email of the contact to \a str. |
118 | */ | 117 | */ |
119 | 118 | ||
120 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 119 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
121 | Sets the home street address of the contact to \a str. | 120 | Sets the home street address of the contact to \a str. |
122 | */ | 121 | */ |
123 | 122 | ||
124 | /*! \fn void OContact::setHomeCity( const QString &str ) | 123 | /*! \fn void OContact::setHomeCity( const QString &str ) |
125 | Sets the home city of the contact to \a str. | 124 | Sets the home city of the contact to \a str. |
126 | */ | 125 | */ |
127 | 126 | ||
128 | /*! \fn void OContact::setHomeState( const QString &str ) | 127 | /*! \fn void OContact::setHomeState( const QString &str ) |
129 | Sets the home state of the contact to \a str. | 128 | Sets the home state of the contact to \a str. |
130 | */ | 129 | */ |
131 | 130 | ||
132 | /*! \fn void OContact::setHomeZip( const QString &str ) | 131 | /*! \fn void OContact::setHomeZip( const QString &str ) |
133 | Sets the home zip code of the contact to \a str. | 132 | Sets the home zip code of the contact to \a str. |
134 | */ | 133 | */ |
135 | 134 | ||
136 | /*! \fn void OContact::setHomeCountry( const QString &str ) | 135 | /*! \fn void OContact::setHomeCountry( const QString &str ) |
137 | Sets the home country of the contact to \a str. | 136 | Sets the home country of the contact to \a str. |
138 | */ | 137 | */ |
139 | 138 | ||
140 | /*! \fn void OContact::setHomePhone( const QString &str ) | 139 | /*! \fn void OContact::setHomePhone( const QString &str ) |
141 | Sets the home phone number of the contact to \a str. | 140 | Sets the home phone number of the contact to \a str. |
142 | */ | 141 | */ |
143 | 142 | ||
144 | /*! \fn void OContact::setHomeFax( const QString &str ) | 143 | /*! \fn void OContact::setHomeFax( const QString &str ) |
145 | Sets the home fax number of the contact to \a str. | 144 | Sets the home fax number of the contact to \a str. |
146 | */ | 145 | */ |
147 | 146 | ||
148 | /*! \fn void OContact::setHomeMobile( const QString &str ) | 147 | /*! \fn void OContact::setHomeMobile( const QString &str ) |
149 | Sets the home mobile phone number of the contact to \a str. | 148 | Sets the home mobile phone number of the contact to \a str. |
150 | */ | 149 | */ |
151 | 150 | ||
152 | /*! \fn void OContact::setHomeWebpage( const QString &str ) | 151 | /*! \fn void OContact::setHomeWebpage( const QString &str ) |
153 | Sets the home webpage of the contact to \a str. | 152 | Sets the home webpage of the contact to \a str. |
154 | */ | 153 | */ |
155 | 154 | ||
156 | /*! \fn void OContact::setCompany( const QString &str ) | 155 | /*! \fn void OContact::setCompany( const QString &str ) |
157 | Sets the company for contact to \a str. | 156 | Sets the company for contact to \a str. |
158 | */ | 157 | */ |
159 | 158 | ||
160 | /*! \fn void OContact::setJobTitle( const QString &str ) | 159 | /*! \fn void OContact::setJobTitle( const QString &str ) |
161 | Sets the job title of the contact to \a str. | 160 | Sets the job title of the contact to \a str. |
162 | */ | 161 | */ |
163 | 162 | ||
164 | /*! \fn void OContact::setDepartment( const QString &str ) | 163 | /*! \fn void OContact::setDepartment( const QString &str ) |
165 | Sets the department for contact to \a str. | 164 | Sets the department for contact to \a str. |
166 | */ | 165 | */ |
167 | 166 | ||
168 | /*! \fn void OContact::setOffice( const QString &str ) | 167 | /*! \fn void OContact::setOffice( const QString &str ) |
169 | Sets the office for contact to \a str. | 168 | Sets the office for contact to \a str. |
170 | */ | 169 | */ |
171 | 170 | ||
172 | /*! \fn void OContact::setBusinessStreet( const QString &str ) | 171 | /*! \fn void OContact::setBusinessStreet( const QString &str ) |
173 | Sets the business street address of the contact to \a str. | 172 | Sets the business street address of the contact to \a str. |
174 | */ | 173 | */ |
175 | 174 | ||
176 | /*! \fn void OContact::setBusinessCity( const QString &str ) | 175 | /*! \fn void OContact::setBusinessCity( const QString &str ) |
177 | Sets the business city of the contact to \a str. | 176 | Sets the business city of the contact to \a str. |
178 | */ | 177 | */ |
179 | 178 | ||
@@ -1345,258 +1344,260 @@ static OContact parseVObject( VObject *obj ) | |||
1345 | c.setHomeWebpage( value ); | 1344 | c.setHomeWebpage( value ); |
1346 | else if ( name == VCWorkProp ) | 1345 | else if ( name == VCWorkProp ) |
1347 | c.setBusinessWebpage( value ); | 1346 | c.setBusinessWebpage( value ); |
1348 | } | 1347 | } |
1349 | } | 1348 | } |
1350 | else if ( name == VCOrgProp ) { | 1349 | else if ( name == VCOrgProp ) { |
1351 | VObjectIterator nit; | 1350 | VObjectIterator nit; |
1352 | initPropIterator( &nit, o ); | 1351 | initPropIterator( &nit, o ); |
1353 | while( moreIteration( &nit ) ) { | 1352 | while( moreIteration( &nit ) ) { |
1354 | VObject *o = nextVObject( &nit ); | 1353 | VObject *o = nextVObject( &nit ); |
1355 | QCString name = vObjectName( o ); | 1354 | QCString name = vObjectName( o ); |
1356 | QString value = vObjectStringZValue( o ); | 1355 | QString value = vObjectStringZValue( o ); |
1357 | if ( name == VCOrgNameProp ) | 1356 | if ( name == VCOrgNameProp ) |
1358 | c.setCompany( value ); | 1357 | c.setCompany( value ); |
1359 | else if ( name == VCOrgUnitProp ) | 1358 | else if ( name == VCOrgUnitProp ) |
1360 | c.setDepartment( value ); | 1359 | c.setDepartment( value ); |
1361 | else if ( name == VCOrgUnit2Prop ) | 1360 | else if ( name == VCOrgUnit2Prop ) |
1362 | c.setOffice( value ); | 1361 | c.setOffice( value ); |
1363 | } | 1362 | } |
1364 | } | 1363 | } |
1365 | else if ( name == VCTitleProp ) { | 1364 | else if ( name == VCTitleProp ) { |
1366 | c.setJobTitle( value ); | 1365 | c.setJobTitle( value ); |
1367 | } | 1366 | } |
1368 | else if ( name == "X-Qtopia-Profession" ) { | 1367 | else if ( name == "X-Qtopia-Profession" ) { |
1369 | c.setProfession( value ); | 1368 | c.setProfession( value ); |
1370 | } | 1369 | } |
1371 | else if ( name == "X-Qtopia-Manager" ) { | 1370 | else if ( name == "X-Qtopia-Manager" ) { |
1372 | c.setManager( value ); | 1371 | c.setManager( value ); |
1373 | } | 1372 | } |
1374 | else if ( name == "X-Qtopia-Assistant" ) { | 1373 | else if ( name == "X-Qtopia-Assistant" ) { |
1375 | c.setAssistant( value ); | 1374 | c.setAssistant( value ); |
1376 | } | 1375 | } |
1377 | else if ( name == "X-Qtopia-Spouse" ) { | 1376 | else if ( name == "X-Qtopia-Spouse" ) { |
1378 | c.setSpouse( value ); | 1377 | c.setSpouse( value ); |
1379 | } | 1378 | } |
1380 | else if ( name == "X-Qtopia-Gender" ) { | 1379 | else if ( name == "X-Qtopia-Gender" ) { |
1381 | c.setGender( value ); | 1380 | c.setGender( value ); |
1382 | } | 1381 | } |
1383 | else if ( name == "X-Qtopia-Anniversary" ) { | 1382 | else if ( name == "X-Qtopia-Anniversary" ) { |
1384 | c.setAnniversary( TimeConversion::fromString( value ) ); | 1383 | c.setAnniversary( TimeConversion::fromString( value ) ); |
1385 | } | 1384 | } |
1386 | else if ( name == "X-Qtopia-Nickname" ) { | 1385 | else if ( name == "X-Qtopia-Nickname" ) { |
1387 | c.setNickname( value ); | 1386 | c.setNickname( value ); |
1388 | } | 1387 | } |
1389 | else if ( name == "X-Qtopia-Children" ) { | 1388 | else if ( name == "X-Qtopia-Children" ) { |
1390 | c.setChildren( value ); | 1389 | c.setChildren( value ); |
1391 | } | 1390 | } |
1392 | else if ( name == VCBirthDateProp ) { | 1391 | else if ( name == VCBirthDateProp ) { |
1393 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 1392 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
1394 | c.setBirthday( convVCardDateToDate( value ) ); | 1393 | c.setBirthday( convVCardDateToDate( value ) ); |
1395 | 1394 | ||
1396 | } | 1395 | } |
1397 | 1396 | ||
1398 | #if 0 | 1397 | #if 0 |
1399 | else { | 1398 | else { |
1400 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 1399 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
1401 | VObjectIterator nit; | 1400 | VObjectIterator nit; |
1402 | initPropIterator( &nit, o ); | 1401 | initPropIterator( &nit, o ); |
1403 | while( moreIteration( &nit ) ) { | 1402 | while( moreIteration( &nit ) ) { |
1404 | VObject *o = nextVObject( &nit ); | 1403 | VObject *o = nextVObject( &nit ); |
1405 | QCString name = vObjectName( o ); | 1404 | QCString name = vObjectName( o ); |
1406 | QString value = vObjectStringZValue( o ); | 1405 | QString value = vObjectStringZValue( o ); |
1407 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 1406 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
1408 | } | 1407 | } |
1409 | } | 1408 | } |
1410 | #endif | 1409 | #endif |
1411 | } | 1410 | } |
1412 | c.setFileAs(); | 1411 | c.setFileAs(); |
1413 | return c; | 1412 | return c; |
1414 | } | 1413 | } |
1415 | 1414 | ||
1416 | /*! | 1415 | /*! |
1417 | Writes the list of \a contacts as a set of VCards to the file \a filename. | 1416 | Writes the list of \a contacts as a set of VCards to the file \a filename. |
1418 | */ | 1417 | */ |
1419 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) | 1418 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) |
1420 | { | 1419 | { |
1421 | QFileDirect f( filename.utf8().data() ); | 1420 | QFileDirect f( filename.utf8().data() ); |
1422 | if ( !f.open( IO_WriteOnly ) ) { | 1421 | if ( !f.open( IO_WriteOnly ) ) { |
1423 | qWarning("Unable to open vcard write"); | 1422 | qWarning("Unable to open vcard write"); |
1424 | return; | 1423 | return; |
1425 | } | 1424 | } |
1426 | 1425 | ||
1427 | QValueList<OContact>::ConstIterator it; | 1426 | QValueList<OContact>::ConstIterator it; |
1428 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 1427 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
1429 | VObject *obj = createVObject( *it ); | 1428 | VObject *obj = createVObject( *it ); |
1430 | writeVObject(f.directHandle() , obj ); | 1429 | writeVObject(f.directHandle() , obj ); |
1431 | cleanVObject( obj ); | 1430 | cleanVObject( obj ); |
1432 | } | 1431 | } |
1433 | cleanStrTbl(); | 1432 | cleanStrTbl(); |
1434 | } | 1433 | } |
1435 | 1434 | ||
1436 | /*! | 1435 | /*! |
1437 | writes \a contact as a VCard to the file \a filename. | 1436 | writes \a contact as a VCard to the file \a filename. |
1438 | */ | 1437 | */ |
1439 | void OContact::writeVCard( const QString &filename, const OContact &contact) | 1438 | void OContact::writeVCard( const QString &filename, const OContact &contact) |
1440 | { | 1439 | { |
1441 | QFileDirect f( filename.utf8().data() ); | 1440 | QFileDirect f( filename.utf8().data() ); |
1442 | if ( !f.open( IO_WriteOnly ) ) { | 1441 | if ( !f.open( IO_WriteOnly ) ) { |
1443 | qWarning("Unable to open vcard write"); | 1442 | qWarning("Unable to open vcard write"); |
1444 | return; | 1443 | return; |
1445 | } | 1444 | } |
1446 | 1445 | ||
1447 | VObject *obj = createVObject( contact ); | 1446 | VObject *obj = createVObject( contact ); |
1448 | writeVObject( f.directHandle() , obj ); | 1447 | writeVObject( f.directHandle() , obj ); |
1449 | cleanVObject( obj ); | 1448 | cleanVObject( obj ); |
1450 | 1449 | ||
1451 | cleanStrTbl(); | 1450 | cleanStrTbl(); |
1452 | } | 1451 | } |
1453 | 1452 | ||
1454 | /*! | 1453 | /*! |
1455 | Returns the set of contacts read as VCards from the file \a filename. | 1454 | Returns the set of contacts read as VCards from the file \a filename. |
1456 | */ | 1455 | */ |
1457 | QValueList<OContact> OContact::readVCard( const QString &filename ) | 1456 | QValueList<OContact> OContact::readVCard( const QString &filename ) |
1458 | { | 1457 | { |
1459 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1458 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
1460 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1459 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
1461 | 1460 | ||
1462 | qDebug("vobject = %p", obj ); | 1461 | qDebug("vobject = %p", obj ); |
1463 | 1462 | ||
1464 | QValueList<OContact> contacts; | 1463 | QValueList<OContact> contacts; |
1465 | 1464 | ||
1466 | while ( obj ) { | 1465 | while ( obj ) { |
1467 | OContact con = parseVObject( obj ); | 1466 | OContact con = parseVObject( obj ); |
1468 | /* | 1467 | /* |
1469 | * if uid is 0 assign a new one | 1468 | * if uid is 0 assign a new one |
1470 | * this at least happens on | 1469 | * this at least happens on |
1471 | * Nokia6210 | 1470 | * Nokia6210 |
1472 | */ | 1471 | */ |
1473 | if ( con.uid() == 0 ) | 1472 | if ( con.uid() == 0 ){ |
1474 | con.setUid( 1 ); | 1473 | con.setUid( 1 ); |
1474 | qWarning("assigned new uid %d",con.uid() ); | ||
1475 | } | ||
1475 | 1476 | ||
1476 | contacts.append(con ); | 1477 | contacts.append(con ); |
1477 | 1478 | ||
1478 | VObject *t = obj; | 1479 | VObject *t = obj; |
1479 | obj = nextVObjectInList(obj); | 1480 | obj = nextVObjectInList(obj); |
1480 | cleanVObject( t ); | 1481 | cleanVObject( t ); |
1481 | } | 1482 | } |
1482 | 1483 | ||
1483 | return contacts; | 1484 | return contacts; |
1484 | } | 1485 | } |
1485 | 1486 | ||
1486 | /*! | 1487 | /*! |
1487 | Returns TRUE if the contact matches the regular expression \a regexp. | 1488 | Returns TRUE if the contact matches the regular expression \a regexp. |
1488 | Otherwise returns FALSE. | 1489 | Otherwise returns FALSE. |
1489 | */ | 1490 | */ |
1490 | bool OContact::match( const QString ®exp ) const | 1491 | bool OContact::match( const QString ®exp ) const |
1491 | { | 1492 | { |
1492 | return match(QRegExp(regexp)); | 1493 | return match(QRegExp(regexp)); |
1493 | } | 1494 | } |
1494 | 1495 | ||
1495 | /*! | 1496 | /*! |
1496 | \overload | 1497 | \overload |
1497 | Returns TRUE if the contact matches the regular expression \a regexp. | 1498 | Returns TRUE if the contact matches the regular expression \a regexp. |
1498 | Otherwise returns FALSE. | 1499 | Otherwise returns FALSE. |
1499 | */ | 1500 | */ |
1500 | bool OContact::match( const QRegExp &r ) const | 1501 | bool OContact::match( const QRegExp &r ) const |
1501 | { | 1502 | { |
1502 | bool match; | 1503 | bool match; |
1503 | match = false; | 1504 | match = false; |
1504 | QMap<int, QString>::ConstIterator it; | 1505 | QMap<int, QString>::ConstIterator it; |
1505 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1506 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
1506 | if ( (*it).find( r ) > -1 ) { | 1507 | if ( (*it).find( r ) > -1 ) { |
1507 | match = true; | 1508 | match = true; |
1508 | break; | 1509 | break; |
1509 | } | 1510 | } |
1510 | } | 1511 | } |
1511 | return match; | 1512 | return match; |
1512 | } | 1513 | } |
1513 | 1514 | ||
1514 | 1515 | ||
1515 | QString OContact::toShortText() const | 1516 | QString OContact::toShortText() const |
1516 | { | 1517 | { |
1517 | return ( fullName() ); | 1518 | return ( fullName() ); |
1518 | } | 1519 | } |
1519 | QString OContact::type() const | 1520 | QString OContact::type() const |
1520 | { | 1521 | { |
1521 | return QString::fromLatin1( "OContact" ); | 1522 | return QString::fromLatin1( "OContact" ); |
1522 | } | 1523 | } |
1523 | 1524 | ||
1524 | // Definition is missing ! (se) | 1525 | // Definition is missing ! (se) |
1525 | QMap<QString,QString> OContact::toExtraMap() const | 1526 | QMap<QString,QString> OContact::toExtraMap() const |
1526 | { | 1527 | { |
1527 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 1528 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
1528 | QMap <QString,QString> useless; | 1529 | QMap <QString,QString> useless; |
1529 | return useless; | 1530 | return useless; |
1530 | } | 1531 | } |
1531 | 1532 | ||
1532 | class QString OContact::recordField( int pos ) const | 1533 | class QString OContact::recordField( int pos ) const |
1533 | { | 1534 | { |
1534 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1535 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1535 | return SLFIELDS[pos]; | 1536 | return SLFIELDS[pos]; |
1536 | } | 1537 | } |
1537 | 1538 | ||
1538 | // In future releases, we should store birthday and anniversary | 1539 | // In future releases, we should store birthday and anniversary |
1539 | // internally as QDate instead of QString ! | 1540 | // internally as QDate instead of QString ! |
1540 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1541 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1541 | 1542 | ||
1542 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1543 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1543 | Sets the birthday for the contact to \a date. | 1544 | Sets the birthday for the contact to \a date. |
1544 | */ | 1545 | */ |
1545 | void OContact::setBirthday( const QDate &v ) | 1546 | void OContact::setBirthday( const QDate &v ) |
1546 | { | 1547 | { |
1547 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1548 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1548 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); | 1549 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); |
1549 | 1550 | ||
1550 | } | 1551 | } |
1551 | 1552 | ||
1552 | 1553 | ||
1553 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1554 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1554 | Sets the anniversary of the contact to \a date. | 1555 | Sets the anniversary of the contact to \a date. |
1555 | */ | 1556 | */ |
1556 | void OContact::setAnniversary( const QDate &v ) | 1557 | void OContact::setAnniversary( const QDate &v ) |
1557 | { | 1558 | { |
1558 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1559 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1559 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); | 1560 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); |
1560 | } | 1561 | } |
1561 | 1562 | ||
1562 | /*! \fn QDate OContact::birthday() const | 1563 | /*! \fn QDate OContact::birthday() const |
1563 | Returns the birthday of the contact. | 1564 | Returns the birthday of the contact. |
1564 | */ | 1565 | */ |
1565 | QDate OContact::birthday() const | 1566 | QDate OContact::birthday() const |
1566 | { | 1567 | { |
1567 | QString str = find( Qtopia::Birthday ); | 1568 | QString str = find( Qtopia::Birthday ); |
1568 | qWarning ("Birthday %s", str.latin1() ); | 1569 | qWarning ("Birthday %s", str.latin1() ); |
1569 | if ( !str.isEmpty() ) | 1570 | if ( !str.isEmpty() ) |
1570 | return TimeConversion::fromString ( str ); | 1571 | return TimeConversion::fromString ( str ); |
1571 | else | 1572 | else |
1572 | return QDate(); | 1573 | return QDate(); |
1573 | } | 1574 | } |
1574 | 1575 | ||
1575 | 1576 | ||
1576 | /*! \fn QDate OContact::anniversary() const | 1577 | /*! \fn QDate OContact::anniversary() const |
1577 | Returns the anniversary of the contact. | 1578 | Returns the anniversary of the contact. |
1578 | */ | 1579 | */ |
1579 | QDate OContact::anniversary() const | 1580 | QDate OContact::anniversary() const |
1580 | { | 1581 | { |
1581 | QDate empty; | 1582 | QDate empty; |
1582 | QString str = find( Qtopia::Anniversary ); | 1583 | QString str = find( Qtopia::Anniversary ); |
1583 | qWarning ("Anniversary %s", str.latin1() ); | 1584 | qWarning ("Anniversary %s", str.latin1() ); |
1584 | if ( !str.isEmpty() ) | 1585 | if ( !str.isEmpty() ) |
1585 | return TimeConversion::fromString ( str ); | 1586 | return TimeConversion::fromString ( str ); |
1586 | else | 1587 | else |
1587 | return empty; | 1588 | return empty; |
1588 | } | 1589 | } |
1589 | 1590 | ||
1590 | 1591 | ||
1591 | void OContact::insertEmail( const QString &v ) | 1592 | void OContact::insertEmail( const QString &v ) |
1592 | { | 1593 | { |
1593 | //qDebug("insertEmail %s", v.latin1()); | 1594 | //qDebug("insertEmail %s", v.latin1()); |
1594 | QString e = v.simplifyWhiteSpace(); | 1595 | QString e = v.simplifyWhiteSpace(); |
1595 | QString def = defaultEmail(); | 1596 | QString def = defaultEmail(); |
1596 | 1597 | ||
1597 | // if no default, set it as the default email and don't insert | 1598 | // if no default, set it as the default email and don't insert |
1598 | if ( def.isEmpty() ) { | 1599 | if ( def.isEmpty() ) { |
1599 | setDefaultEmail( e ); // will insert into the list for us | 1600 | setDefaultEmail( e ); // will insert into the list for us |
1600 | return; | 1601 | return; |
1601 | } | 1602 | } |
1602 | 1603 | ||
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 038a59f..81ac1c1 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -75,168 +75,164 @@ public: | |||
75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
78 | 78 | ||
79 | // business | 79 | // business |
80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
97 | 97 | ||
98 | // personal | 98 | // personal |
99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
101 | void setBirthday( const QDate &v ); | 101 | void setBirthday( const QDate &v ); |
102 | void setAnniversary( const QDate &v ); | 102 | void setAnniversary( const QDate &v ); |
103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
104 | void setChildren( const QString &v ); | 104 | void setChildren( const QString &v ); |
105 | 105 | ||
106 | // other | 106 | // other |
107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
108 | 108 | ||
109 | bool match( const QString ®exp ) const; | 109 | bool match( const QString ®exp ) const; |
110 | bool match( const QRegExp ®exp ) const; | 110 | bool match( const QRegExp ®exp ) const; |
111 | 111 | ||
112 | // // custom | 112 | // // custom |
113 | // void setCustomField( const QString &key, const QString &v ) | 113 | // void setCustomField( const QString &key, const QString &v ) |
114 | // { replace(Custom- + key, v ); } | 114 | // { replace(Custom- + key, v ); } |
115 | 115 | ||
116 | // name | 116 | // name |
117 | QString fullName() const; | 117 | QString fullName() const; |
118 | QString title() const { return find( Qtopia::Title ); } | 118 | QString title() const { return find( Qtopia::Title ); } |
119 | QString firstName() const { return find( Qtopia::FirstName ); } | 119 | QString firstName() const { return find( Qtopia::FirstName ); } |
120 | QString middleName() const { return find( Qtopia::MiddleName ); } | 120 | QString middleName() const { return find( Qtopia::MiddleName ); } |
121 | QString lastName() const { return find( Qtopia::LastName ); } | 121 | QString lastName() const { return find( Qtopia::LastName ); } |
122 | QString suffix() const { return find( Qtopia::Suffix ); } | 122 | QString suffix() const { return find( Qtopia::Suffix ); } |
123 | QString fileAs() const { return find( Qtopia::FileAs ); } | 123 | QString fileAs() const { return find( Qtopia::FileAs ); } |
124 | 124 | ||
125 | 125 | ||
126 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 126 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
127 | QStringList emailList() const; | 127 | QStringList emailList() const; |
128 | 128 | ||
129 | // home | 129 | // home |
130 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 130 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
131 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 131 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
132 | QString homeState() const { return find( Qtopia::HomeState ); } | 132 | QString homeState() const { return find( Qtopia::HomeState ); } |
133 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 133 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
134 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 134 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
135 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 135 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
136 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 136 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
137 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 137 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
138 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 138 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
139 | /** Multi line string containing all non-empty address info in the form | 139 | /** Multi line string containing all non-empty address info in the form |
140 | * Street | 140 | * Street |
141 | * City, State Zip | 141 | * City, State Zip |
142 | * Country | 142 | * Country |
143 | */ | 143 | */ |
144 | QString displayHomeAddress() const; | 144 | QString displayHomeAddress() const; |
145 | 145 | ||
146 | // business | 146 | // business |
147 | QString company() const { return find( Qtopia::Company ); } | 147 | QString company() const { return find( Qtopia::Company ); } |
148 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 148 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
149 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 149 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
150 | QString businessState() const { return find( Qtopia::BusinessState ); } | 150 | QString businessState() const { return find( Qtopia::BusinessState ); } |
151 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 151 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
152 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 152 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
153 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 153 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
154 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 154 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
155 | QString department() const { return find( Qtopia::Department ); } | 155 | QString department() const { return find( Qtopia::Department ); } |
156 | QString office() const { return find( Qtopia::Office ); } | 156 | QString office() const { return find( Qtopia::Office ); } |
157 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 157 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
158 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 158 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
159 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 159 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
160 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 160 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
161 | QString profession() const { return find( Qtopia::Profession ); } | 161 | QString profession() const { return find( Qtopia::Profession ); } |
162 | QString assistant() const { return find( Qtopia::Assistant ); } | 162 | QString assistant() const { return find( Qtopia::Assistant ); } |
163 | QString manager() const { return find( Qtopia::Manager ); } | 163 | QString manager() const { return find( Qtopia::Manager ); } |
164 | /** Multi line string containing all non-empty address info in the form | 164 | /** Multi line string containing all non-empty address info in the form |
165 | * Street | 165 | * Street |
166 | * City, State Zip | 166 | * City, State Zip |
167 | * Country | 167 | * Country |
168 | */ | 168 | */ |
169 | QString displayBusinessAddress() const; | 169 | QString displayBusinessAddress() const; |
170 | 170 | ||
171 | //personal | 171 | //personal |
172 | QString spouse() const { return find( Qtopia::Spouse ); } | 172 | QString spouse() const { return find( Qtopia::Spouse ); } |
173 | QString gender() const { return find( Qtopia::Gender ); } | 173 | QString gender() const { return find( Qtopia::Gender ); } |
174 | QDate birthday() const; | 174 | QDate birthday() const; |
175 | QDate anniversary() const; | 175 | QDate anniversary() const; |
176 | QString nickname() const { return find( Qtopia::Nickname ); } | 176 | QString nickname() const { return find( Qtopia::Nickname ); } |
177 | QString children() const { return find( Qtopia::Children ); } | 177 | QString children() const { return find( Qtopia::Children ); } |
178 | QStringList childrenList() const; | 178 | QStringList childrenList() const; |
179 | 179 | ||
180 | // other | 180 | // other |
181 | QString notes() const { return find( Qtopia::Notes ); } | 181 | QString notes() const { return find( Qtopia::Notes ); } |
182 | QString groups() const { return find( Qtopia::Groups ); } | 182 | QString groups() const { return find( Qtopia::Groups ); } |
183 | QStringList groupList() const; | 183 | QStringList groupList() const; |
184 | 184 | ||
185 | // // custom | 185 | // // custom |
186 | // const QString &customField( const QString &key ) | 186 | // const QString &customField( const QString &key ) |
187 | // { return find( Custom- + key ); } | 187 | // { return find( Custom- + key ); } |
188 | 188 | ||
189 | static QStringList fields(); | 189 | static QStringList fields(); |
190 | static QStringList trfields(); | 190 | static QStringList trfields(); |
191 | static QStringList untrfields(); | 191 | static QStringList untrfields(); |
192 | 192 | ||
193 | QString toRichText() const; | 193 | QString toRichText() const; |
194 | QMap<int, QString> toMap() const; | 194 | QMap<int, QString> toMap() const; |
195 | QString field( int key ) const { return find( key ); } | 195 | QString field( int key ) const { return find( key ); } |
196 | 196 | ||
197 | 197 | ||
198 | // journaling... | 198 | // journaling... |
199 | void saveJournal( journal_action action, const QString &key = QString::null ); | 199 | void saveJournal( journal_action action, const QString &key = QString::null ); |
200 | void save( QString &buf ) const; | 200 | void save( QString &buf ) const; |
201 | 201 | ||
202 | void setUid( int i ) | 202 | void setUid( int i ) |
203 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 203 | { OPimRecord::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
204 | 204 | ||
205 | QString toShortText()const; | 205 | QString toShortText()const; |
206 | QString OContact::type()const; | 206 | QString OContact::type()const; |
207 | QMap<QString,QString> OContact::toExtraMap() const; | 207 | QMap<QString,QString> OContact::toExtraMap() const; |
208 | class QString OContact::recordField(int) const; | 208 | class QString OContact::recordField(int) const; |
209 | 209 | ||
210 | // Why private ? (eilers,se) | 210 | // Why private ? (eilers,se) |
211 | QString emailSeparator() const { return " "; } | 211 | QString emailSeparator() const { return " "; } |
212 | // the emails should be seperated by a comma | 212 | // the emails should be seperated by a comma |
213 | void setEmails( const QString &v ); | 213 | void setEmails( const QString &v ); |
214 | QString emails() const { return find( Qtopia::Emails ); } | 214 | QString emails() const { return find( Qtopia::Emails ); } |
215 | 215 | ||
216 | 216 | ||
217 | private: | 217 | private: |
218 | friend class AbEditor; | 218 | friend class AbEditor; |
219 | friend class AbTable; | 219 | friend class AbTable; |
220 | friend class AddressBookAccessPrivate; | 220 | friend class AddressBookAccessPrivate; |
221 | friend class XMLIO; | 221 | friend class XMLIO; |
222 | 222 | ||
223 | void insert( int key, const QString &value ); | 223 | void insert( int key, const QString &value ); |
224 | void replace( int key, const QString &value ); | 224 | void replace( int key, const QString &value ); |
225 | QString find( int key ) const; | 225 | QString find( int key ) const; |
226 | 226 | ||
227 | QString displayAddress( const QString &street, | 227 | QString displayAddress( const QString &street, |
228 | const QString &city, | 228 | const QString &city, |
229 | const QString &state, | 229 | const QString &state, |
230 | const QString &zip, | 230 | const QString &zip, |
231 | const QString &country ) const; | 231 | const QString &country ) const; |
232 | 232 | ||
233 | Qtopia::UidGen &uidGen() { return sUidGen; } | ||
234 | |||
235 | |||
236 | static Qtopia::UidGen sUidGen; | ||
237 | QMap<int, QString> mMap; | 233 | QMap<int, QString> mMap; |
238 | ContactPrivate *d; | 234 | ContactPrivate *d; |
239 | }; | 235 | }; |
240 | 236 | ||
241 | 237 | ||
242 | #endif | 238 | #endif |
diff --git a/libopie/pim/opimrecord.cpp b/libopie/pim/opimrecord.cpp index 62dc353..21cf131 100644 --- a/libopie/pim/opimrecord.cpp +++ b/libopie/pim/opimrecord.cpp | |||
@@ -1,134 +1,132 @@ | |||
1 | #include <qpe/categories.h> | 1 | #include <qpe/categories.h> |
2 | #include <qpe/categoryselect.h> | 2 | #include <qpe/categoryselect.h> |
3 | 3 | ||
4 | #include "opimrecord.h" | 4 | #include "opimrecord.h" |
5 | 5 | ||
6 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 6 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
7 | 7 | ||
8 | 8 | ||
9 | OPimRecord::OPimRecord( int uid ) | 9 | OPimRecord::OPimRecord( int uid ) |
10 | : Qtopia::Record() { | 10 | : Qtopia::Record() { |
11 | 11 | ||
12 | setUid( uid ); | 12 | setUid( uid ); |
13 | } | 13 | } |
14 | OPimRecord::~OPimRecord() { | 14 | OPimRecord::~OPimRecord() { |
15 | } | 15 | } |
16 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 16 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
17 | : Qtopia::Record( rec ) | 17 | : Qtopia::Record( rec ) |
18 | { | 18 | { |
19 | (*this) = rec; | 19 | (*this) = rec; |
20 | } | 20 | } |
21 | 21 | ||
22 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 22 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
23 | Qtopia::Record::operator=( rec ); | 23 | Qtopia::Record::operator=( rec ); |
24 | m_relations = rec.m_relations; | 24 | m_relations = rec.m_relations; |
25 | 25 | ||
26 | return *this; | 26 | return *this; |
27 | } | 27 | } |
28 | /* | 28 | /* |
29 | * category names | 29 | * category names |
30 | */ | 30 | */ |
31 | QStringList OPimRecord::categoryNames()const { | 31 | QStringList OPimRecord::categoryNames()const { |
32 | QStringList list; | 32 | QStringList list; |
33 | QArray<int> cats = categories(); | 33 | QArray<int> cats = categories(); |
34 | Categories catDB; | 34 | Categories catDB; |
35 | catDB.load( categoryFileName() ); | 35 | catDB.load( categoryFileName() ); |
36 | 36 | ||
37 | for (uint i = 0; i < cats.count(); i++ ) { | 37 | for (uint i = 0; i < cats.count(); i++ ) { |
38 | list << catDB.label("Todo List", cats[i] ); | 38 | list << catDB.label("Todo List", cats[i] ); |
39 | } | 39 | } |
40 | 40 | ||
41 | return list; | 41 | return list; |
42 | } | 42 | } |
43 | void OPimRecord::setCategoryNames( const QStringList& ) { | 43 | void OPimRecord::setCategoryNames( const QStringList& ) { |
44 | 44 | ||
45 | } | 45 | } |
46 | void OPimRecord::addCategoryName( const QString& ) { | 46 | void OPimRecord::addCategoryName( const QString& ) { |
47 | Categories catDB; | 47 | Categories catDB; |
48 | catDB.load( categoryFileName() ); | 48 | catDB.load( categoryFileName() ); |
49 | 49 | ||
50 | 50 | ||
51 | } | 51 | } |
52 | bool OPimRecord::isEmpty()const { | 52 | bool OPimRecord::isEmpty()const { |
53 | return ( uid() == 0 ); | 53 | return ( uid() == 0 ); |
54 | } | 54 | } |
55 | QStringList OPimRecord::relatedApps()const{ | 55 | QStringList OPimRecord::relatedApps()const{ |
56 | QStringList list; | 56 | QStringList list; |
57 | QMap<QString, QArray<int> >::ConstIterator it; | 57 | QMap<QString, QArray<int> >::ConstIterator it; |
58 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { | 58 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { |
59 | list << it.key(); | 59 | list << it.key(); |
60 | } | 60 | } |
61 | return list; | 61 | return list; |
62 | } | 62 | } |
63 | QArray<int> OPimRecord::relations(const QString& app )const { | 63 | QArray<int> OPimRecord::relations(const QString& app )const { |
64 | QArray<int> tmp; | 64 | QArray<int> tmp; |
65 | QMap<QString, QArray<int> >::ConstIterator it; | 65 | QMap<QString, QArray<int> >::ConstIterator it; |
66 | it = m_relations.find( app); | 66 | it = m_relations.find( app); |
67 | if ( it != m_relations.end() ) | 67 | if ( it != m_relations.end() ) |
68 | tmp = it.data(); | 68 | tmp = it.data(); |
69 | return tmp; | 69 | return tmp; |
70 | } | 70 | } |
71 | void OPimRecord::clearRelation( const QString& app ) { | 71 | void OPimRecord::clearRelation( const QString& app ) { |
72 | m_relations.remove( app ); | 72 | m_relations.remove( app ); |
73 | } | 73 | } |
74 | void OPimRecord::addRelation( const QString& app, int id ) { | 74 | void OPimRecord::addRelation( const QString& app, int id ) { |
75 | 75 | ||
76 | QMap<QString, QArray<int> >::Iterator it; | 76 | QMap<QString, QArray<int> >::Iterator it; |
77 | QArray<int> tmp; | 77 | QArray<int> tmp; |
78 | 78 | ||
79 | it = m_relations.find( app ); | 79 | it = m_relations.find( app ); |
80 | if ( it == m_relations.end() ) { | 80 | if ( it == m_relations.end() ) { |
81 | tmp.resize(1 ); | 81 | tmp.resize(1 ); |
82 | tmp[0] = id; | 82 | tmp[0] = id; |
83 | }else{ | 83 | }else{ |
84 | tmp = it.data(); | 84 | tmp = it.data(); |
85 | tmp.resize( tmp.size() + 1 ); | 85 | tmp.resize( tmp.size() + 1 ); |
86 | tmp[tmp.size() - 1] = id; | 86 | tmp[tmp.size() - 1] = id; |
87 | } | 87 | } |
88 | m_relations.replace( app, tmp ); | 88 | m_relations.replace( app, tmp ); |
89 | } | 89 | } |
90 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { | 90 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { |
91 | 91 | ||
92 | QMap<QString, QArray<int> >::Iterator it; | 92 | QMap<QString, QArray<int> >::Iterator it; |
93 | QArray<int> tmp; | 93 | QArray<int> tmp; |
94 | 94 | ||
95 | it = m_relations.find( app); | 95 | it = m_relations.find( app); |
96 | if ( it == m_relations.end() ) { | 96 | if ( it == m_relations.end() ) { |
97 | tmp = ids; | 97 | tmp = ids; |
98 | }else{ | 98 | }else{ |
99 | tmp = it.data(); | 99 | tmp = it.data(); |
100 | int offset = tmp.size()-1; | 100 | int offset = tmp.size()-1; |
101 | tmp.resize( tmp.size() + ids.size() ); | 101 | tmp.resize( tmp.size() + ids.size() ); |
102 | for (uint i = 0; i < ids.size(); i++ ) { | 102 | for (uint i = 0; i < ids.size(); i++ ) { |
103 | tmp[offset+i] = ids[i]; | 103 | tmp[offset+i] = ids[i]; |
104 | } | 104 | } |
105 | 105 | ||
106 | } | 106 | } |
107 | m_relations.replace( app, tmp ); | 107 | m_relations.replace( app, tmp ); |
108 | } | 108 | } |
109 | QString OPimRecord::crossToString()const { | 109 | QString OPimRecord::crossToString()const { |
110 | QString str; | 110 | QString str; |
111 | QMap<QString, QArray<int> >::ConstIterator it; | 111 | QMap<QString, QArray<int> >::ConstIterator it; |
112 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | 112 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { |
113 | QArray<int> id = it.data(); | 113 | QArray<int> id = it.data(); |
114 | for ( uint i = 0; i < id.size(); ++i ) { | 114 | for ( uint i = 0; i < id.size(); ++i ) { |
115 | str += it.key() + "," + QString::number( i ) + ";"; | 115 | str += it.key() + "," + QString::number( i ) + ";"; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | str = str.remove( str.length()-1, 1); // strip the ; | 118 | str = str.remove( str.length()-1, 1); // strip the ; |
119 | //qWarning("IDS " + str ); | 119 | //qWarning("IDS " + str ); |
120 | 120 | ||
121 | return str; | 121 | return str; |
122 | } | 122 | } |
123 | /* if uid = 1 assign a new one */ | 123 | /* if uid = 1 assign a new one */ |
124 | void OPimRecord::setUid( int uid ) { | 124 | void OPimRecord::setUid( int uid ) { |
125 | // qWarning("setting uid" ); | ||
126 | if ( uid == 1) | 125 | if ( uid == 1) |
127 | uid = uidGen().generate(); | 126 | uid = uidGen().generate(); |
128 | 127 | ||
129 | // qWarning(" uid %d", uid); | ||
130 | Qtopia::Record::setUid( uid ); | 128 | Qtopia::Record::setUid( uid ); |
131 | }; | 129 | }; |
132 | Qtopia::UidGen &OPimRecord::uidGen() { | 130 | Qtopia::UidGen &OPimRecord::uidGen() { |
133 | return m_uidGen; | 131 | return m_uidGen; |
134 | } | 132 | } |
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp index 62dc353..21cf131 100644 --- a/libopie2/opiepim/core/opimrecord.cpp +++ b/libopie2/opiepim/core/opimrecord.cpp | |||
@@ -1,134 +1,132 @@ | |||
1 | #include <qpe/categories.h> | 1 | #include <qpe/categories.h> |
2 | #include <qpe/categoryselect.h> | 2 | #include <qpe/categoryselect.h> |
3 | 3 | ||
4 | #include "opimrecord.h" | 4 | #include "opimrecord.h" |
5 | 5 | ||
6 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); | 6 | Qtopia::UidGen OPimRecord::m_uidGen( Qtopia::UidGen::Qtopia ); |
7 | 7 | ||
8 | 8 | ||
9 | OPimRecord::OPimRecord( int uid ) | 9 | OPimRecord::OPimRecord( int uid ) |
10 | : Qtopia::Record() { | 10 | : Qtopia::Record() { |
11 | 11 | ||
12 | setUid( uid ); | 12 | setUid( uid ); |
13 | } | 13 | } |
14 | OPimRecord::~OPimRecord() { | 14 | OPimRecord::~OPimRecord() { |
15 | } | 15 | } |
16 | OPimRecord::OPimRecord( const OPimRecord& rec ) | 16 | OPimRecord::OPimRecord( const OPimRecord& rec ) |
17 | : Qtopia::Record( rec ) | 17 | : Qtopia::Record( rec ) |
18 | { | 18 | { |
19 | (*this) = rec; | 19 | (*this) = rec; |
20 | } | 20 | } |
21 | 21 | ||
22 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { | 22 | OPimRecord &OPimRecord::operator=( const OPimRecord& rec) { |
23 | Qtopia::Record::operator=( rec ); | 23 | Qtopia::Record::operator=( rec ); |
24 | m_relations = rec.m_relations; | 24 | m_relations = rec.m_relations; |
25 | 25 | ||
26 | return *this; | 26 | return *this; |
27 | } | 27 | } |
28 | /* | 28 | /* |
29 | * category names | 29 | * category names |
30 | */ | 30 | */ |
31 | QStringList OPimRecord::categoryNames()const { | 31 | QStringList OPimRecord::categoryNames()const { |
32 | QStringList list; | 32 | QStringList list; |
33 | QArray<int> cats = categories(); | 33 | QArray<int> cats = categories(); |
34 | Categories catDB; | 34 | Categories catDB; |
35 | catDB.load( categoryFileName() ); | 35 | catDB.load( categoryFileName() ); |
36 | 36 | ||
37 | for (uint i = 0; i < cats.count(); i++ ) { | 37 | for (uint i = 0; i < cats.count(); i++ ) { |
38 | list << catDB.label("Todo List", cats[i] ); | 38 | list << catDB.label("Todo List", cats[i] ); |
39 | } | 39 | } |
40 | 40 | ||
41 | return list; | 41 | return list; |
42 | } | 42 | } |
43 | void OPimRecord::setCategoryNames( const QStringList& ) { | 43 | void OPimRecord::setCategoryNames( const QStringList& ) { |
44 | 44 | ||
45 | } | 45 | } |
46 | void OPimRecord::addCategoryName( const QString& ) { | 46 | void OPimRecord::addCategoryName( const QString& ) { |
47 | Categories catDB; | 47 | Categories catDB; |
48 | catDB.load( categoryFileName() ); | 48 | catDB.load( categoryFileName() ); |
49 | 49 | ||
50 | 50 | ||
51 | } | 51 | } |
52 | bool OPimRecord::isEmpty()const { | 52 | bool OPimRecord::isEmpty()const { |
53 | return ( uid() == 0 ); | 53 | return ( uid() == 0 ); |
54 | } | 54 | } |
55 | QStringList OPimRecord::relatedApps()const{ | 55 | QStringList OPimRecord::relatedApps()const{ |
56 | QStringList list; | 56 | QStringList list; |
57 | QMap<QString, QArray<int> >::ConstIterator it; | 57 | QMap<QString, QArray<int> >::ConstIterator it; |
58 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { | 58 | for ( it = m_relations.begin(); it != m_relations.end(); ++it ) { |
59 | list << it.key(); | 59 | list << it.key(); |
60 | } | 60 | } |
61 | return list; | 61 | return list; |
62 | } | 62 | } |
63 | QArray<int> OPimRecord::relations(const QString& app )const { | 63 | QArray<int> OPimRecord::relations(const QString& app )const { |
64 | QArray<int> tmp; | 64 | QArray<int> tmp; |
65 | QMap<QString, QArray<int> >::ConstIterator it; | 65 | QMap<QString, QArray<int> >::ConstIterator it; |
66 | it = m_relations.find( app); | 66 | it = m_relations.find( app); |
67 | if ( it != m_relations.end() ) | 67 | if ( it != m_relations.end() ) |
68 | tmp = it.data(); | 68 | tmp = it.data(); |
69 | return tmp; | 69 | return tmp; |
70 | } | 70 | } |
71 | void OPimRecord::clearRelation( const QString& app ) { | 71 | void OPimRecord::clearRelation( const QString& app ) { |
72 | m_relations.remove( app ); | 72 | m_relations.remove( app ); |
73 | } | 73 | } |
74 | void OPimRecord::addRelation( const QString& app, int id ) { | 74 | void OPimRecord::addRelation( const QString& app, int id ) { |
75 | 75 | ||
76 | QMap<QString, QArray<int> >::Iterator it; | 76 | QMap<QString, QArray<int> >::Iterator it; |
77 | QArray<int> tmp; | 77 | QArray<int> tmp; |
78 | 78 | ||
79 | it = m_relations.find( app ); | 79 | it = m_relations.find( app ); |
80 | if ( it == m_relations.end() ) { | 80 | if ( it == m_relations.end() ) { |
81 | tmp.resize(1 ); | 81 | tmp.resize(1 ); |
82 | tmp[0] = id; | 82 | tmp[0] = id; |
83 | }else{ | 83 | }else{ |
84 | tmp = it.data(); | 84 | tmp = it.data(); |
85 | tmp.resize( tmp.size() + 1 ); | 85 | tmp.resize( tmp.size() + 1 ); |
86 | tmp[tmp.size() - 1] = id; | 86 | tmp[tmp.size() - 1] = id; |
87 | } | 87 | } |
88 | m_relations.replace( app, tmp ); | 88 | m_relations.replace( app, tmp ); |
89 | } | 89 | } |
90 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { | 90 | void OPimRecord::setRelations( const QString& app, QArray<int> ids ) { |
91 | 91 | ||
92 | QMap<QString, QArray<int> >::Iterator it; | 92 | QMap<QString, QArray<int> >::Iterator it; |
93 | QArray<int> tmp; | 93 | QArray<int> tmp; |
94 | 94 | ||
95 | it = m_relations.find( app); | 95 | it = m_relations.find( app); |
96 | if ( it == m_relations.end() ) { | 96 | if ( it == m_relations.end() ) { |
97 | tmp = ids; | 97 | tmp = ids; |
98 | }else{ | 98 | }else{ |
99 | tmp = it.data(); | 99 | tmp = it.data(); |
100 | int offset = tmp.size()-1; | 100 | int offset = tmp.size()-1; |
101 | tmp.resize( tmp.size() + ids.size() ); | 101 | tmp.resize( tmp.size() + ids.size() ); |
102 | for (uint i = 0; i < ids.size(); i++ ) { | 102 | for (uint i = 0; i < ids.size(); i++ ) { |
103 | tmp[offset+i] = ids[i]; | 103 | tmp[offset+i] = ids[i]; |
104 | } | 104 | } |
105 | 105 | ||
106 | } | 106 | } |
107 | m_relations.replace( app, tmp ); | 107 | m_relations.replace( app, tmp ); |
108 | } | 108 | } |
109 | QString OPimRecord::crossToString()const { | 109 | QString OPimRecord::crossToString()const { |
110 | QString str; | 110 | QString str; |
111 | QMap<QString, QArray<int> >::ConstIterator it; | 111 | QMap<QString, QArray<int> >::ConstIterator it; |
112 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { | 112 | for (it = m_relations.begin(); it != m_relations.end(); ++it ) { |
113 | QArray<int> id = it.data(); | 113 | QArray<int> id = it.data(); |
114 | for ( uint i = 0; i < id.size(); ++i ) { | 114 | for ( uint i = 0; i < id.size(); ++i ) { |
115 | str += it.key() + "," + QString::number( i ) + ";"; | 115 | str += it.key() + "," + QString::number( i ) + ";"; |
116 | } | 116 | } |
117 | } | 117 | } |
118 | str = str.remove( str.length()-1, 1); // strip the ; | 118 | str = str.remove( str.length()-1, 1); // strip the ; |
119 | //qWarning("IDS " + str ); | 119 | //qWarning("IDS " + str ); |
120 | 120 | ||
121 | return str; | 121 | return str; |
122 | } | 122 | } |
123 | /* if uid = 1 assign a new one */ | 123 | /* if uid = 1 assign a new one */ |
124 | void OPimRecord::setUid( int uid ) { | 124 | void OPimRecord::setUid( int uid ) { |
125 | // qWarning("setting uid" ); | ||
126 | if ( uid == 1) | 125 | if ( uid == 1) |
127 | uid = uidGen().generate(); | 126 | uid = uidGen().generate(); |
128 | 127 | ||
129 | // qWarning(" uid %d", uid); | ||
130 | Qtopia::Record::setUid( uid ); | 128 | Qtopia::Record::setUid( uid ); |
131 | }; | 129 | }; |
132 | Qtopia::UidGen &OPimRecord::uidGen() { | 130 | Qtopia::UidGen &OPimRecord::uidGen() { |
133 | return m_uidGen; | 131 | return m_uidGen; |
134 | } | 132 | } |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index cd238ef..8a0930b 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -1,179 +1,178 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #define QTOPIA_INTERNAL_CONTACT_MRE | 22 | #define QTOPIA_INTERNAL_CONTACT_MRE |
23 | 23 | ||
24 | #include "ocontact.h" | 24 | #include "ocontact.h" |
25 | #include "../../library/backend/vobject_p.h" | 25 | #include "../../library/backend/vobject_p.h" |
26 | #include "../../library/backend/qfiledirect_p.h" | 26 | #include "../../library/backend/qfiledirect_p.h" |
27 | 27 | ||
28 | #include <qpe/stringutil.h> | 28 | #include <qpe/stringutil.h> |
29 | #include <qpe/timeconversion.h> | 29 | #include <qpe/timeconversion.h> |
30 | #include <qpe/timestring.h> | 30 | #include <qpe/timestring.h> |
31 | 31 | ||
32 | #include <qobject.h> | 32 | #include <qobject.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qstylesheet.h> | 34 | #include <qstylesheet.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <qmap.h> | 36 | #include <qmap.h> |
37 | 37 | ||
38 | #include <stdio.h> | 38 | #include <stdio.h> |
39 | 39 | ||
40 | /*! | 40 | /*! |
41 | \class Contact contact.h | 41 | \class Contact contact.h |
42 | \brief The Contact class holds the data of an address book entry. | 42 | \brief The Contact class holds the data of an address book entry. |
43 | 43 | ||
44 | This data includes information the name of the person, contact | 44 | This data includes information the name of the person, contact |
45 | information, and business information such as deparment and job title. | 45 | information, and business information such as deparment and job title. |
46 | 46 | ||
47 | \ingroup qtopiaemb | 47 | \ingroup qtopiaemb |
48 | \ingroup qtopiadesktop | 48 | \ingroup qtopiadesktop |
49 | */ | 49 | */ |
50 | 50 | ||
51 | Qtopia::UidGen OContact::sUidGen( Qtopia::UidGen::Qtopia ); | ||
52 | 51 | ||
53 | /*! | 52 | /*! |
54 | Creates a new, empty contact. | 53 | Creates a new, empty contact. |
55 | */ | 54 | */ |
56 | OContact::OContact() | 55 | OContact::OContact() |
57 | : OPimRecord(), mMap(), d( 0 ) | 56 | : OPimRecord(), mMap(), d( 0 ) |
58 | { | 57 | { |
59 | } | 58 | } |
60 | 59 | ||
61 | /*! | 60 | /*! |
62 | \internal | 61 | \internal |
63 | Creates a new contact. The properties of the contact are | 62 | Creates a new contact. The properties of the contact are |
64 | set from \a fromMap. | 63 | set from \a fromMap. |
65 | */ | 64 | */ |
66 | OContact::OContact( const QMap<int, QString> &fromMap ) : | 65 | OContact::OContact( const QMap<int, QString> &fromMap ) : |
67 | OPimRecord(), mMap( fromMap ), d( 0 ) | 66 | OPimRecord(), mMap( fromMap ), d( 0 ) |
68 | { | 67 | { |
69 | QString cats = mMap[ Qtopia::AddressCategory ]; | 68 | QString cats = mMap[ Qtopia::AddressCategory ]; |
70 | if ( !cats.isEmpty() ) | 69 | if ( !cats.isEmpty() ) |
71 | setCategories( idsFromString( cats ) ); | 70 | setCategories( idsFromString( cats ) ); |
72 | 71 | ||
73 | QString uidStr = find( Qtopia::AddressUid ); | 72 | QString uidStr = find( Qtopia::AddressUid ); |
74 | 73 | ||
75 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ | 74 | if ( uidStr.isEmpty() || (uidStr.toInt() == 0) ){ |
76 | qWarning( "Invalid UID found. Generate new one.." ); | 75 | qWarning( "Invalid UID found. Generate new one.." ); |
77 | setUid( uidGen().generate() ); | 76 | setUid( uidGen().generate() ); |
78 | }else | 77 | }else |
79 | setUid( uidStr.toInt() ); | 78 | setUid( uidStr.toInt() ); |
80 | 79 | ||
81 | // if ( !uidStr.isEmpty() ) | 80 | // if ( !uidStr.isEmpty() ) |
82 | // setUid( uidStr.toInt() ); | 81 | // setUid( uidStr.toInt() ); |
83 | } | 82 | } |
84 | 83 | ||
85 | /*! | 84 | /*! |
86 | Destroys a contact. | 85 | Destroys a contact. |
87 | */ | 86 | */ |
88 | OContact::~OContact() | 87 | OContact::~OContact() |
89 | { | 88 | { |
90 | } | 89 | } |
91 | 90 | ||
92 | /*! \fn void OContact::setTitle( const QString &str ) | 91 | /*! \fn void OContact::setTitle( const QString &str ) |
93 | Sets the title of the contact to \a str. | 92 | Sets the title of the contact to \a str. |
94 | */ | 93 | */ |
95 | 94 | ||
96 | /*! \fn void OContact::setFirstName( const QString &str ) | 95 | /*! \fn void OContact::setFirstName( const QString &str ) |
97 | Sets the first name of the contact to \a str. | 96 | Sets the first name of the contact to \a str. |
98 | */ | 97 | */ |
99 | 98 | ||
100 | /*! \fn void OContact::setMiddleName( const QString &str ) | 99 | /*! \fn void OContact::setMiddleName( const QString &str ) |
101 | Sets the middle name of the contact to \a str. | 100 | Sets the middle name of the contact to \a str. |
102 | */ | 101 | */ |
103 | 102 | ||
104 | /*! \fn void OContact::setLastName( const QString &str ) | 103 | /*! \fn void OContact::setLastName( const QString &str ) |
105 | Sets the last name of the contact to \a str. | 104 | Sets the last name of the contact to \a str. |
106 | */ | 105 | */ |
107 | 106 | ||
108 | /*! \fn void OContact::setSuffix( const QString &str ) | 107 | /*! \fn void OContact::setSuffix( const QString &str ) |
109 | Sets the suffix of the contact to \a str. | 108 | Sets the suffix of the contact to \a str. |
110 | */ | 109 | */ |
111 | 110 | ||
112 | /*! \fn void OContact::setFileAs( const QString &str ) | 111 | /*! \fn void OContact::setFileAs( const QString &str ) |
113 | Sets the contact to filed as \a str. | 112 | Sets the contact to filed as \a str. |
114 | */ | 113 | */ |
115 | 114 | ||
116 | /*! \fn void OContact::setDefaultEmail( const QString &str ) | 115 | /*! \fn void OContact::setDefaultEmail( const QString &str ) |
117 | Sets the default email of the contact to \a str. | 116 | Sets the default email of the contact to \a str. |
118 | */ | 117 | */ |
119 | 118 | ||
120 | /*! \fn void OContact::setHomeStreet( const QString &str ) | 119 | /*! \fn void OContact::setHomeStreet( const QString &str ) |
121 | Sets the home street address of the contact to \a str. | 120 | Sets the home street address of the contact to \a str. |
122 | */ | 121 | */ |
123 | 122 | ||
124 | /*! \fn void OContact::setHomeCity( const QString &str ) | 123 | /*! \fn void OContact::setHomeCity( const QString &str ) |
125 | Sets the home city of the contact to \a str. | 124 | Sets the home city of the contact to \a str. |
126 | */ | 125 | */ |
127 | 126 | ||
128 | /*! \fn void OContact::setHomeState( const QString &str ) | 127 | /*! \fn void OContact::setHomeState( const QString &str ) |
129 | Sets the home state of the contact to \a str. | 128 | Sets the home state of the contact to \a str. |
130 | */ | 129 | */ |
131 | 130 | ||
132 | /*! \fn void OContact::setHomeZip( const QString &str ) | 131 | /*! \fn void OContact::setHomeZip( const QString &str ) |
133 | Sets the home zip code of the contact to \a str. | 132 | Sets the home zip code of the contact to \a str. |
134 | */ | 133 | */ |
135 | 134 | ||
136 | /*! \fn void OContact::setHomeCountry( const QString &str ) | 135 | /*! \fn void OContact::setHomeCountry( const QString &str ) |
137 | Sets the home country of the contact to \a str. | 136 | Sets the home country of the contact to \a str. |
138 | */ | 137 | */ |
139 | 138 | ||
140 | /*! \fn void OContact::setHomePhone( const QString &str ) | 139 | /*! \fn void OContact::setHomePhone( const QString &str ) |
141 | Sets the home phone number of the contact to \a str. | 140 | Sets the home phone number of the contact to \a str. |
142 | */ | 141 | */ |
143 | 142 | ||
144 | /*! \fn void OContact::setHomeFax( const QString &str ) | 143 | /*! \fn void OContact::setHomeFax( const QString &str ) |
145 | Sets the home fax number of the contact to \a str. | 144 | Sets the home fax number of the contact to \a str. |
146 | */ | 145 | */ |
147 | 146 | ||
148 | /*! \fn void OContact::setHomeMobile( const QString &str ) | 147 | /*! \fn void OContact::setHomeMobile( const QString &str ) |
149 | Sets the home mobile phone number of the contact to \a str. | 148 | Sets the home mobile phone number of the contact to \a str. |
150 | */ | 149 | */ |
151 | 150 | ||
152 | /*! \fn void OContact::setHomeWebpage( const QString &str ) | 151 | /*! \fn void OContact::setHomeWebpage( const QString &str ) |
153 | Sets the home webpage of the contact to \a str. | 152 | Sets the home webpage of the contact to \a str. |
154 | */ | 153 | */ |
155 | 154 | ||
156 | /*! \fn void OContact::setCompany( const QString &str ) | 155 | /*! \fn void OContact::setCompany( const QString &str ) |
157 | Sets the company for contact to \a str. | 156 | Sets the company for contact to \a str. |
158 | */ | 157 | */ |
159 | 158 | ||
160 | /*! \fn void OContact::setJobTitle( const QString &str ) | 159 | /*! \fn void OContact::setJobTitle( const QString &str ) |
161 | Sets the job title of the contact to \a str. | 160 | Sets the job title of the contact to \a str. |
162 | */ | 161 | */ |
163 | 162 | ||
164 | /*! \fn void OContact::setDepartment( const QString &str ) | 163 | /*! \fn void OContact::setDepartment( const QString &str ) |
165 | Sets the department for contact to \a str. | 164 | Sets the department for contact to \a str. |
166 | */ | 165 | */ |
167 | 166 | ||
168 | /*! \fn void OContact::setOffice( const QString &str ) | 167 | /*! \fn void OContact::setOffice( const QString &str ) |
169 | Sets the office for contact to \a str. | 168 | Sets the office for contact to \a str. |
170 | */ | 169 | */ |
171 | 170 | ||
172 | /*! \fn void OContact::setBusinessStreet( const QString &str ) | 171 | /*! \fn void OContact::setBusinessStreet( const QString &str ) |
173 | Sets the business street address of the contact to \a str. | 172 | Sets the business street address of the contact to \a str. |
174 | */ | 173 | */ |
175 | 174 | ||
176 | /*! \fn void OContact::setBusinessCity( const QString &str ) | 175 | /*! \fn void OContact::setBusinessCity( const QString &str ) |
177 | Sets the business city of the contact to \a str. | 176 | Sets the business city of the contact to \a str. |
178 | */ | 177 | */ |
179 | 178 | ||
@@ -1345,258 +1344,260 @@ static OContact parseVObject( VObject *obj ) | |||
1345 | c.setHomeWebpage( value ); | 1344 | c.setHomeWebpage( value ); |
1346 | else if ( name == VCWorkProp ) | 1345 | else if ( name == VCWorkProp ) |
1347 | c.setBusinessWebpage( value ); | 1346 | c.setBusinessWebpage( value ); |
1348 | } | 1347 | } |
1349 | } | 1348 | } |
1350 | else if ( name == VCOrgProp ) { | 1349 | else if ( name == VCOrgProp ) { |
1351 | VObjectIterator nit; | 1350 | VObjectIterator nit; |
1352 | initPropIterator( &nit, o ); | 1351 | initPropIterator( &nit, o ); |
1353 | while( moreIteration( &nit ) ) { | 1352 | while( moreIteration( &nit ) ) { |
1354 | VObject *o = nextVObject( &nit ); | 1353 | VObject *o = nextVObject( &nit ); |
1355 | QCString name = vObjectName( o ); | 1354 | QCString name = vObjectName( o ); |
1356 | QString value = vObjectStringZValue( o ); | 1355 | QString value = vObjectStringZValue( o ); |
1357 | if ( name == VCOrgNameProp ) | 1356 | if ( name == VCOrgNameProp ) |
1358 | c.setCompany( value ); | 1357 | c.setCompany( value ); |
1359 | else if ( name == VCOrgUnitProp ) | 1358 | else if ( name == VCOrgUnitProp ) |
1360 | c.setDepartment( value ); | 1359 | c.setDepartment( value ); |
1361 | else if ( name == VCOrgUnit2Prop ) | 1360 | else if ( name == VCOrgUnit2Prop ) |
1362 | c.setOffice( value ); | 1361 | c.setOffice( value ); |
1363 | } | 1362 | } |
1364 | } | 1363 | } |
1365 | else if ( name == VCTitleProp ) { | 1364 | else if ( name == VCTitleProp ) { |
1366 | c.setJobTitle( value ); | 1365 | c.setJobTitle( value ); |
1367 | } | 1366 | } |
1368 | else if ( name == "X-Qtopia-Profession" ) { | 1367 | else if ( name == "X-Qtopia-Profession" ) { |
1369 | c.setProfession( value ); | 1368 | c.setProfession( value ); |
1370 | } | 1369 | } |
1371 | else if ( name == "X-Qtopia-Manager" ) { | 1370 | else if ( name == "X-Qtopia-Manager" ) { |
1372 | c.setManager( value ); | 1371 | c.setManager( value ); |
1373 | } | 1372 | } |
1374 | else if ( name == "X-Qtopia-Assistant" ) { | 1373 | else if ( name == "X-Qtopia-Assistant" ) { |
1375 | c.setAssistant( value ); | 1374 | c.setAssistant( value ); |
1376 | } | 1375 | } |
1377 | else if ( name == "X-Qtopia-Spouse" ) { | 1376 | else if ( name == "X-Qtopia-Spouse" ) { |
1378 | c.setSpouse( value ); | 1377 | c.setSpouse( value ); |
1379 | } | 1378 | } |
1380 | else if ( name == "X-Qtopia-Gender" ) { | 1379 | else if ( name == "X-Qtopia-Gender" ) { |
1381 | c.setGender( value ); | 1380 | c.setGender( value ); |
1382 | } | 1381 | } |
1383 | else if ( name == "X-Qtopia-Anniversary" ) { | 1382 | else if ( name == "X-Qtopia-Anniversary" ) { |
1384 | c.setAnniversary( TimeConversion::fromString( value ) ); | 1383 | c.setAnniversary( TimeConversion::fromString( value ) ); |
1385 | } | 1384 | } |
1386 | else if ( name == "X-Qtopia-Nickname" ) { | 1385 | else if ( name == "X-Qtopia-Nickname" ) { |
1387 | c.setNickname( value ); | 1386 | c.setNickname( value ); |
1388 | } | 1387 | } |
1389 | else if ( name == "X-Qtopia-Children" ) { | 1388 | else if ( name == "X-Qtopia-Children" ) { |
1390 | c.setChildren( value ); | 1389 | c.setChildren( value ); |
1391 | } | 1390 | } |
1392 | else if ( name == VCBirthDateProp ) { | 1391 | else if ( name == VCBirthDateProp ) { |
1393 | // Reading Birthdate regarding RFC 2425 (5.8.4) | 1392 | // Reading Birthdate regarding RFC 2425 (5.8.4) |
1394 | c.setBirthday( convVCardDateToDate( value ) ); | 1393 | c.setBirthday( convVCardDateToDate( value ) ); |
1395 | 1394 | ||
1396 | } | 1395 | } |
1397 | 1396 | ||
1398 | #if 0 | 1397 | #if 0 |
1399 | else { | 1398 | else { |
1400 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); | 1399 | printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); |
1401 | VObjectIterator nit; | 1400 | VObjectIterator nit; |
1402 | initPropIterator( &nit, o ); | 1401 | initPropIterator( &nit, o ); |
1403 | while( moreIteration( &nit ) ) { | 1402 | while( moreIteration( &nit ) ) { |
1404 | VObject *o = nextVObject( &nit ); | 1403 | VObject *o = nextVObject( &nit ); |
1405 | QCString name = vObjectName( o ); | 1404 | QCString name = vObjectName( o ); |
1406 | QString value = vObjectStringZValue( o ); | 1405 | QString value = vObjectStringZValue( o ); |
1407 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); | 1406 | printf(" subprop: %s = %s\n", name.data(), value.latin1() ); |
1408 | } | 1407 | } |
1409 | } | 1408 | } |
1410 | #endif | 1409 | #endif |
1411 | } | 1410 | } |
1412 | c.setFileAs(); | 1411 | c.setFileAs(); |
1413 | return c; | 1412 | return c; |
1414 | } | 1413 | } |
1415 | 1414 | ||
1416 | /*! | 1415 | /*! |
1417 | Writes the list of \a contacts as a set of VCards to the file \a filename. | 1416 | Writes the list of \a contacts as a set of VCards to the file \a filename. |
1418 | */ | 1417 | */ |
1419 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) | 1418 | void OContact::writeVCard( const QString &filename, const QValueList<OContact> &contacts) |
1420 | { | 1419 | { |
1421 | QFileDirect f( filename.utf8().data() ); | 1420 | QFileDirect f( filename.utf8().data() ); |
1422 | if ( !f.open( IO_WriteOnly ) ) { | 1421 | if ( !f.open( IO_WriteOnly ) ) { |
1423 | qWarning("Unable to open vcard write"); | 1422 | qWarning("Unable to open vcard write"); |
1424 | return; | 1423 | return; |
1425 | } | 1424 | } |
1426 | 1425 | ||
1427 | QValueList<OContact>::ConstIterator it; | 1426 | QValueList<OContact>::ConstIterator it; |
1428 | for( it = contacts.begin(); it != contacts.end(); ++it ) { | 1427 | for( it = contacts.begin(); it != contacts.end(); ++it ) { |
1429 | VObject *obj = createVObject( *it ); | 1428 | VObject *obj = createVObject( *it ); |
1430 | writeVObject(f.directHandle() , obj ); | 1429 | writeVObject(f.directHandle() , obj ); |
1431 | cleanVObject( obj ); | 1430 | cleanVObject( obj ); |
1432 | } | 1431 | } |
1433 | cleanStrTbl(); | 1432 | cleanStrTbl(); |
1434 | } | 1433 | } |
1435 | 1434 | ||
1436 | /*! | 1435 | /*! |
1437 | writes \a contact as a VCard to the file \a filename. | 1436 | writes \a contact as a VCard to the file \a filename. |
1438 | */ | 1437 | */ |
1439 | void OContact::writeVCard( const QString &filename, const OContact &contact) | 1438 | void OContact::writeVCard( const QString &filename, const OContact &contact) |
1440 | { | 1439 | { |
1441 | QFileDirect f( filename.utf8().data() ); | 1440 | QFileDirect f( filename.utf8().data() ); |
1442 | if ( !f.open( IO_WriteOnly ) ) { | 1441 | if ( !f.open( IO_WriteOnly ) ) { |
1443 | qWarning("Unable to open vcard write"); | 1442 | qWarning("Unable to open vcard write"); |
1444 | return; | 1443 | return; |
1445 | } | 1444 | } |
1446 | 1445 | ||
1447 | VObject *obj = createVObject( contact ); | 1446 | VObject *obj = createVObject( contact ); |
1448 | writeVObject( f.directHandle() , obj ); | 1447 | writeVObject( f.directHandle() , obj ); |
1449 | cleanVObject( obj ); | 1448 | cleanVObject( obj ); |
1450 | 1449 | ||
1451 | cleanStrTbl(); | 1450 | cleanStrTbl(); |
1452 | } | 1451 | } |
1453 | 1452 | ||
1454 | /*! | 1453 | /*! |
1455 | Returns the set of contacts read as VCards from the file \a filename. | 1454 | Returns the set of contacts read as VCards from the file \a filename. |
1456 | */ | 1455 | */ |
1457 | QValueList<OContact> OContact::readVCard( const QString &filename ) | 1456 | QValueList<OContact> OContact::readVCard( const QString &filename ) |
1458 | { | 1457 | { |
1459 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); | 1458 | qDebug("trying to open %s, exists=%d", filename.utf8().data(), QFileInfo( filename.utf8().data() ).size() ); |
1460 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); | 1459 | VObject *obj = Parse_MIME_FromFileName( (char *)filename.utf8().data() ); |
1461 | 1460 | ||
1462 | qDebug("vobject = %p", obj ); | 1461 | qDebug("vobject = %p", obj ); |
1463 | 1462 | ||
1464 | QValueList<OContact> contacts; | 1463 | QValueList<OContact> contacts; |
1465 | 1464 | ||
1466 | while ( obj ) { | 1465 | while ( obj ) { |
1467 | OContact con = parseVObject( obj ); | 1466 | OContact con = parseVObject( obj ); |
1468 | /* | 1467 | /* |
1469 | * if uid is 0 assign a new one | 1468 | * if uid is 0 assign a new one |
1470 | * this at least happens on | 1469 | * this at least happens on |
1471 | * Nokia6210 | 1470 | * Nokia6210 |
1472 | */ | 1471 | */ |
1473 | if ( con.uid() == 0 ) | 1472 | if ( con.uid() == 0 ){ |
1474 | con.setUid( 1 ); | 1473 | con.setUid( 1 ); |
1474 | qWarning("assigned new uid %d",con.uid() ); | ||
1475 | } | ||
1475 | 1476 | ||
1476 | contacts.append(con ); | 1477 | contacts.append(con ); |
1477 | 1478 | ||
1478 | VObject *t = obj; | 1479 | VObject *t = obj; |
1479 | obj = nextVObjectInList(obj); | 1480 | obj = nextVObjectInList(obj); |
1480 | cleanVObject( t ); | 1481 | cleanVObject( t ); |
1481 | } | 1482 | } |
1482 | 1483 | ||
1483 | return contacts; | 1484 | return contacts; |
1484 | } | 1485 | } |
1485 | 1486 | ||
1486 | /*! | 1487 | /*! |
1487 | Returns TRUE if the contact matches the regular expression \a regexp. | 1488 | Returns TRUE if the contact matches the regular expression \a regexp. |
1488 | Otherwise returns FALSE. | 1489 | Otherwise returns FALSE. |
1489 | */ | 1490 | */ |
1490 | bool OContact::match( const QString ®exp ) const | 1491 | bool OContact::match( const QString ®exp ) const |
1491 | { | 1492 | { |
1492 | return match(QRegExp(regexp)); | 1493 | return match(QRegExp(regexp)); |
1493 | } | 1494 | } |
1494 | 1495 | ||
1495 | /*! | 1496 | /*! |
1496 | \overload | 1497 | \overload |
1497 | Returns TRUE if the contact matches the regular expression \a regexp. | 1498 | Returns TRUE if the contact matches the regular expression \a regexp. |
1498 | Otherwise returns FALSE. | 1499 | Otherwise returns FALSE. |
1499 | */ | 1500 | */ |
1500 | bool OContact::match( const QRegExp &r ) const | 1501 | bool OContact::match( const QRegExp &r ) const |
1501 | { | 1502 | { |
1502 | bool match; | 1503 | bool match; |
1503 | match = false; | 1504 | match = false; |
1504 | QMap<int, QString>::ConstIterator it; | 1505 | QMap<int, QString>::ConstIterator it; |
1505 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { | 1506 | for ( it = mMap.begin(); it != mMap.end(); ++it ) { |
1506 | if ( (*it).find( r ) > -1 ) { | 1507 | if ( (*it).find( r ) > -1 ) { |
1507 | match = true; | 1508 | match = true; |
1508 | break; | 1509 | break; |
1509 | } | 1510 | } |
1510 | } | 1511 | } |
1511 | return match; | 1512 | return match; |
1512 | } | 1513 | } |
1513 | 1514 | ||
1514 | 1515 | ||
1515 | QString OContact::toShortText() const | 1516 | QString OContact::toShortText() const |
1516 | { | 1517 | { |
1517 | return ( fullName() ); | 1518 | return ( fullName() ); |
1518 | } | 1519 | } |
1519 | QString OContact::type() const | 1520 | QString OContact::type() const |
1520 | { | 1521 | { |
1521 | return QString::fromLatin1( "OContact" ); | 1522 | return QString::fromLatin1( "OContact" ); |
1522 | } | 1523 | } |
1523 | 1524 | ||
1524 | // Definition is missing ! (se) | 1525 | // Definition is missing ! (se) |
1525 | QMap<QString,QString> OContact::toExtraMap() const | 1526 | QMap<QString,QString> OContact::toExtraMap() const |
1526 | { | 1527 | { |
1527 | qWarning ("Function not implemented: OContact::toExtraMap()"); | 1528 | qWarning ("Function not implemented: OContact::toExtraMap()"); |
1528 | QMap <QString,QString> useless; | 1529 | QMap <QString,QString> useless; |
1529 | return useless; | 1530 | return useless; |
1530 | } | 1531 | } |
1531 | 1532 | ||
1532 | class QString OContact::recordField( int pos ) const | 1533 | class QString OContact::recordField( int pos ) const |
1533 | { | 1534 | { |
1534 | QStringList SLFIELDS = fields(); // ?? why this ? (se) | 1535 | QStringList SLFIELDS = fields(); // ?? why this ? (se) |
1535 | return SLFIELDS[pos]; | 1536 | return SLFIELDS[pos]; |
1536 | } | 1537 | } |
1537 | 1538 | ||
1538 | // In future releases, we should store birthday and anniversary | 1539 | // In future releases, we should store birthday and anniversary |
1539 | // internally as QDate instead of QString ! | 1540 | // internally as QDate instead of QString ! |
1540 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) | 1541 | // QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) |
1541 | 1542 | ||
1542 | /*! \fn void OContact::setBirthday( const QDate& date ) | 1543 | /*! \fn void OContact::setBirthday( const QDate& date ) |
1543 | Sets the birthday for the contact to \a date. | 1544 | Sets the birthday for the contact to \a date. |
1544 | */ | 1545 | */ |
1545 | void OContact::setBirthday( const QDate &v ) | 1546 | void OContact::setBirthday( const QDate &v ) |
1546 | { | 1547 | { |
1547 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1548 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1548 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); | 1549 | replace( Qtopia::Birthday, TimeConversion::toString( v ) ); |
1549 | 1550 | ||
1550 | } | 1551 | } |
1551 | 1552 | ||
1552 | 1553 | ||
1553 | /*! \fn void OContact::setAnniversary( const QDate &date ) | 1554 | /*! \fn void OContact::setAnniversary( const QDate &date ) |
1554 | Sets the anniversary of the contact to \a date. | 1555 | Sets the anniversary of the contact to \a date. |
1555 | */ | 1556 | */ |
1556 | void OContact::setAnniversary( const QDate &v ) | 1557 | void OContact::setAnniversary( const QDate &v ) |
1557 | { | 1558 | { |
1558 | if ( ( !v.isNull() ) && ( v.isValid() ) ) | 1559 | if ( ( !v.isNull() ) && ( v.isValid() ) ) |
1559 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); | 1560 | replace( Qtopia::Anniversary, TimeConversion::toString( v ) ); |
1560 | } | 1561 | } |
1561 | 1562 | ||
1562 | /*! \fn QDate OContact::birthday() const | 1563 | /*! \fn QDate OContact::birthday() const |
1563 | Returns the birthday of the contact. | 1564 | Returns the birthday of the contact. |
1564 | */ | 1565 | */ |
1565 | QDate OContact::birthday() const | 1566 | QDate OContact::birthday() const |
1566 | { | 1567 | { |
1567 | QString str = find( Qtopia::Birthday ); | 1568 | QString str = find( Qtopia::Birthday ); |
1568 | qWarning ("Birthday %s", str.latin1() ); | 1569 | qWarning ("Birthday %s", str.latin1() ); |
1569 | if ( !str.isEmpty() ) | 1570 | if ( !str.isEmpty() ) |
1570 | return TimeConversion::fromString ( str ); | 1571 | return TimeConversion::fromString ( str ); |
1571 | else | 1572 | else |
1572 | return QDate(); | 1573 | return QDate(); |
1573 | } | 1574 | } |
1574 | 1575 | ||
1575 | 1576 | ||
1576 | /*! \fn QDate OContact::anniversary() const | 1577 | /*! \fn QDate OContact::anniversary() const |
1577 | Returns the anniversary of the contact. | 1578 | Returns the anniversary of the contact. |
1578 | */ | 1579 | */ |
1579 | QDate OContact::anniversary() const | 1580 | QDate OContact::anniversary() const |
1580 | { | 1581 | { |
1581 | QDate empty; | 1582 | QDate empty; |
1582 | QString str = find( Qtopia::Anniversary ); | 1583 | QString str = find( Qtopia::Anniversary ); |
1583 | qWarning ("Anniversary %s", str.latin1() ); | 1584 | qWarning ("Anniversary %s", str.latin1() ); |
1584 | if ( !str.isEmpty() ) | 1585 | if ( !str.isEmpty() ) |
1585 | return TimeConversion::fromString ( str ); | 1586 | return TimeConversion::fromString ( str ); |
1586 | else | 1587 | else |
1587 | return empty; | 1588 | return empty; |
1588 | } | 1589 | } |
1589 | 1590 | ||
1590 | 1591 | ||
1591 | void OContact::insertEmail( const QString &v ) | 1592 | void OContact::insertEmail( const QString &v ) |
1592 | { | 1593 | { |
1593 | //qDebug("insertEmail %s", v.latin1()); | 1594 | //qDebug("insertEmail %s", v.latin1()); |
1594 | QString e = v.simplifyWhiteSpace(); | 1595 | QString e = v.simplifyWhiteSpace(); |
1595 | QString def = defaultEmail(); | 1596 | QString def = defaultEmail(); |
1596 | 1597 | ||
1597 | // if no default, set it as the default email and don't insert | 1598 | // if no default, set it as the default email and don't insert |
1598 | if ( def.isEmpty() ) { | 1599 | if ( def.isEmpty() ) { |
1599 | setDefaultEmail( e ); // will insert into the list for us | 1600 | setDefaultEmail( e ); // will insert into the list for us |
1600 | return; | 1601 | return; |
1601 | } | 1602 | } |
1602 | 1603 | ||
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h index 038a59f..81ac1c1 100644 --- a/libopie2/opiepim/ocontact.h +++ b/libopie2/opiepim/ocontact.h | |||
@@ -75,168 +75,164 @@ public: | |||
75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
78 | 78 | ||
79 | // business | 79 | // business |
80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
97 | 97 | ||
98 | // personal | 98 | // personal |
99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
101 | void setBirthday( const QDate &v ); | 101 | void setBirthday( const QDate &v ); |
102 | void setAnniversary( const QDate &v ); | 102 | void setAnniversary( const QDate &v ); |
103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
104 | void setChildren( const QString &v ); | 104 | void setChildren( const QString &v ); |
105 | 105 | ||
106 | // other | 106 | // other |
107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
108 | 108 | ||
109 | bool match( const QString ®exp ) const; | 109 | bool match( const QString ®exp ) const; |
110 | bool match( const QRegExp ®exp ) const; | 110 | bool match( const QRegExp ®exp ) const; |
111 | 111 | ||
112 | // // custom | 112 | // // custom |
113 | // void setCustomField( const QString &key, const QString &v ) | 113 | // void setCustomField( const QString &key, const QString &v ) |
114 | // { replace(Custom- + key, v ); } | 114 | // { replace(Custom- + key, v ); } |
115 | 115 | ||
116 | // name | 116 | // name |
117 | QString fullName() const; | 117 | QString fullName() const; |
118 | QString title() const { return find( Qtopia::Title ); } | 118 | QString title() const { return find( Qtopia::Title ); } |
119 | QString firstName() const { return find( Qtopia::FirstName ); } | 119 | QString firstName() const { return find( Qtopia::FirstName ); } |
120 | QString middleName() const { return find( Qtopia::MiddleName ); } | 120 | QString middleName() const { return find( Qtopia::MiddleName ); } |
121 | QString lastName() const { return find( Qtopia::LastName ); } | 121 | QString lastName() const { return find( Qtopia::LastName ); } |
122 | QString suffix() const { return find( Qtopia::Suffix ); } | 122 | QString suffix() const { return find( Qtopia::Suffix ); } |
123 | QString fileAs() const { return find( Qtopia::FileAs ); } | 123 | QString fileAs() const { return find( Qtopia::FileAs ); } |
124 | 124 | ||
125 | 125 | ||
126 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } | 126 | QString defaultEmail() const { return find( Qtopia::DefaultEmail ); } |
127 | QStringList emailList() const; | 127 | QStringList emailList() const; |
128 | 128 | ||
129 | // home | 129 | // home |
130 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } | 130 | QString homeStreet() const { return find( Qtopia::HomeStreet ); } |
131 | QString homeCity() const { return find( Qtopia::HomeCity ); } | 131 | QString homeCity() const { return find( Qtopia::HomeCity ); } |
132 | QString homeState() const { return find( Qtopia::HomeState ); } | 132 | QString homeState() const { return find( Qtopia::HomeState ); } |
133 | QString homeZip() const { return find( Qtopia::HomeZip ); } | 133 | QString homeZip() const { return find( Qtopia::HomeZip ); } |
134 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } | 134 | QString homeCountry() const { return find( Qtopia::HomeCountry ); } |
135 | QString homePhone() const { return find( Qtopia::HomePhone ); } | 135 | QString homePhone() const { return find( Qtopia::HomePhone ); } |
136 | QString homeFax() const { return find( Qtopia::HomeFax ); } | 136 | QString homeFax() const { return find( Qtopia::HomeFax ); } |
137 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } | 137 | QString homeMobile() const { return find( Qtopia::HomeMobile ); } |
138 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } | 138 | QString homeWebpage() const { return find( Qtopia::HomeWebPage ); } |
139 | /** Multi line string containing all non-empty address info in the form | 139 | /** Multi line string containing all non-empty address info in the form |
140 | * Street | 140 | * Street |
141 | * City, State Zip | 141 | * City, State Zip |
142 | * Country | 142 | * Country |
143 | */ | 143 | */ |
144 | QString displayHomeAddress() const; | 144 | QString displayHomeAddress() const; |
145 | 145 | ||
146 | // business | 146 | // business |
147 | QString company() const { return find( Qtopia::Company ); } | 147 | QString company() const { return find( Qtopia::Company ); } |
148 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } | 148 | QString businessStreet() const { return find( Qtopia::BusinessStreet ); } |
149 | QString businessCity() const { return find( Qtopia::BusinessCity ); } | 149 | QString businessCity() const { return find( Qtopia::BusinessCity ); } |
150 | QString businessState() const { return find( Qtopia::BusinessState ); } | 150 | QString businessState() const { return find( Qtopia::BusinessState ); } |
151 | QString businessZip() const { return find( Qtopia::BusinessZip ); } | 151 | QString businessZip() const { return find( Qtopia::BusinessZip ); } |
152 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } | 152 | QString businessCountry() const { return find( Qtopia::BusinessCountry ); } |
153 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } | 153 | QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); } |
154 | QString jobTitle() const { return find( Qtopia::JobTitle ); } | 154 | QString jobTitle() const { return find( Qtopia::JobTitle ); } |
155 | QString department() const { return find( Qtopia::Department ); } | 155 | QString department() const { return find( Qtopia::Department ); } |
156 | QString office() const { return find( Qtopia::Office ); } | 156 | QString office() const { return find( Qtopia::Office ); } |
157 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } | 157 | QString businessPhone() const { return find( Qtopia::BusinessPhone ); } |
158 | QString businessFax() const { return find( Qtopia::BusinessFax ); } | 158 | QString businessFax() const { return find( Qtopia::BusinessFax ); } |
159 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } | 159 | QString businessMobile() const { return find( Qtopia::BusinessMobile ); } |
160 | QString businessPager() const { return find( Qtopia::BusinessPager ); } | 160 | QString businessPager() const { return find( Qtopia::BusinessPager ); } |
161 | QString profession() const { return find( Qtopia::Profession ); } | 161 | QString profession() const { return find( Qtopia::Profession ); } |
162 | QString assistant() const { return find( Qtopia::Assistant ); } | 162 | QString assistant() const { return find( Qtopia::Assistant ); } |
163 | QString manager() const { return find( Qtopia::Manager ); } | 163 | QString manager() const { return find( Qtopia::Manager ); } |
164 | /** Multi line string containing all non-empty address info in the form | 164 | /** Multi line string containing all non-empty address info in the form |
165 | * Street | 165 | * Street |
166 | * City, State Zip | 166 | * City, State Zip |
167 | * Country | 167 | * Country |
168 | */ | 168 | */ |
169 | QString displayBusinessAddress() const; | 169 | QString displayBusinessAddress() const; |
170 | 170 | ||
171 | //personal | 171 | //personal |
172 | QString spouse() const { return find( Qtopia::Spouse ); } | 172 | QString spouse() const { return find( Qtopia::Spouse ); } |
173 | QString gender() const { return find( Qtopia::Gender ); } | 173 | QString gender() const { return find( Qtopia::Gender ); } |
174 | QDate birthday() const; | 174 | QDate birthday() const; |
175 | QDate anniversary() const; | 175 | QDate anniversary() const; |
176 | QString nickname() const { return find( Qtopia::Nickname ); } | 176 | QString nickname() const { return find( Qtopia::Nickname ); } |
177 | QString children() const { return find( Qtopia::Children ); } | 177 | QString children() const { return find( Qtopia::Children ); } |
178 | QStringList childrenList() const; | 178 | QStringList childrenList() const; |
179 | 179 | ||
180 | // other | 180 | // other |
181 | QString notes() const { return find( Qtopia::Notes ); } | 181 | QString notes() const { return find( Qtopia::Notes ); } |
182 | QString groups() const { return find( Qtopia::Groups ); } | 182 | QString groups() const { return find( Qtopia::Groups ); } |
183 | QStringList groupList() const; | 183 | QStringList groupList() const; |
184 | 184 | ||
185 | // // custom | 185 | // // custom |
186 | // const QString &customField( const QString &key ) | 186 | // const QString &customField( const QString &key ) |
187 | // { return find( Custom- + key ); } | 187 | // { return find( Custom- + key ); } |
188 | 188 | ||
189 | static QStringList fields(); | 189 | static QStringList fields(); |
190 | static QStringList trfields(); | 190 | static QStringList trfields(); |
191 | static QStringList untrfields(); | 191 | static QStringList untrfields(); |
192 | 192 | ||
193 | QString toRichText() const; | 193 | QString toRichText() const; |
194 | QMap<int, QString> toMap() const; | 194 | QMap<int, QString> toMap() const; |
195 | QString field( int key ) const { return find( key ); } | 195 | QString field( int key ) const { return find( key ); } |
196 | 196 | ||
197 | 197 | ||
198 | // journaling... | 198 | // journaling... |
199 | void saveJournal( journal_action action, const QString &key = QString::null ); | 199 | void saveJournal( journal_action action, const QString &key = QString::null ); |
200 | void save( QString &buf ) const; | 200 | void save( QString &buf ) const; |
201 | 201 | ||
202 | void setUid( int i ) | 202 | void setUid( int i ) |
203 | { Record::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } | 203 | { OPimRecord::setUid(i); replace( Qtopia::AddressUid , QString::number(i)); } |
204 | 204 | ||
205 | QString toShortText()const; | 205 | QString toShortText()const; |
206 | QString OContact::type()const; | 206 | QString OContact::type()const; |
207 | QMap<QString,QString> OContact::toExtraMap() const; | 207 | QMap<QString,QString> OContact::toExtraMap() const; |
208 | class QString OContact::recordField(int) const; | 208 | class QString OContact::recordField(int) const; |
209 | 209 | ||
210 | // Why private ? (eilers,se) | 210 | // Why private ? (eilers,se) |
211 | QString emailSeparator() const { return " "; } | 211 | QString emailSeparator() const { return " "; } |
212 | // the emails should be seperated by a comma | 212 | // the emails should be seperated by a comma |
213 | void setEmails( const QString &v ); | 213 | void setEmails( const QString &v ); |
214 | QString emails() const { return find( Qtopia::Emails ); } | 214 | QString emails() const { return find( Qtopia::Emails ); } |
215 | 215 | ||
216 | 216 | ||
217 | private: | 217 | private: |
218 | friend class AbEditor; | 218 | friend class AbEditor; |
219 | friend class AbTable; | 219 | friend class AbTable; |
220 | friend class AddressBookAccessPrivate; | 220 | friend class AddressBookAccessPrivate; |
221 | friend class XMLIO; | 221 | friend class XMLIO; |
222 | 222 | ||
223 | void insert( int key, const QString &value ); | 223 | void insert( int key, const QString &value ); |
224 | void replace( int key, const QString &value ); | 224 | void replace( int key, const QString &value ); |
225 | QString find( int key ) const; | 225 | QString find( int key ) const; |
226 | 226 | ||
227 | QString displayAddress( const QString &street, | 227 | QString displayAddress( const QString &street, |
228 | const QString &city, | 228 | const QString &city, |
229 | const QString &state, | 229 | const QString &state, |
230 | const QString &zip, | 230 | const QString &zip, |
231 | const QString &country ) const; | 231 | const QString &country ) const; |
232 | 232 | ||
233 | Qtopia::UidGen &uidGen() { return sUidGen; } | ||
234 | |||
235 | |||
236 | static Qtopia::UidGen sUidGen; | ||
237 | QMap<int, QString> mMap; | 233 | QMap<int, QString> mMap; |
238 | ContactPrivate *d; | 234 | ContactPrivate *d; |
239 | }; | 235 | }; |
240 | 236 | ||
241 | 237 | ||
242 | #endif | 238 | #endif |