Diffstat (limited to 'libopie2/opiepim/core/ocontactaccess.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index c12e138..4f9b504 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -28,102 +28,102 @@ | |||
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * ===================================================================== | 30 | * ===================================================================== |
31 | * ToDo: XML-Backend: Automatic reload if something was changed... | 31 | * ToDo: XML-Backend: Automatic reload if something was changed... |
32 | * | 32 | * |
33 | * | 33 | * |
34 | */ | 34 | */ |
35 | 35 | ||
36 | #include "ocontactaccess.h" | 36 | #include "ocontactaccess.h" |
37 | #include "obackendfactory.h" | 37 | #include "obackendfactory.h" |
38 | 38 | ||
39 | #include <qasciidict.h> | 39 | #include <qasciidict.h> |
40 | #include <qdatetime.h> | 40 | #include <qdatetime.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qlist.h> | 43 | #include <qlist.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | 45 | ||
46 | //#include <qpe/qcopenvelope_qws.h> | 46 | //#include <qpe/qcopenvelope_qws.h> |
47 | #include <qpe/global.h> | 47 | #include <qpe/global.h> |
48 | 48 | ||
49 | #include <errno.h> | 49 | #include <errno.h> |
50 | #include <fcntl.h> | 50 | #include <fcntl.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #include <stdlib.h> | 52 | #include <stdlib.h> |
53 | 53 | ||
54 | #include <opie2/ocontactaccessbackend_xml.h> | 54 | #include <opie2/ocontactaccessbackend_xml.h> |
55 | 55 | ||
56 | namespace Opie { | 56 | namespace Opie { |
57 | 57 | ||
58 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | 58 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , |
59 | OPimContactAccessBackend* end, bool autosync ): | 59 | OPimContactAccessBackend* end, bool autosync ): |
60 | OPimAccessTemplate<OPimContact>( end ) | 60 | OPimAccessTemplate<OPimContact>( end ) |
61 | { | 61 | { |
62 | /* take care of the backend. If there is no one defined, we | 62 | /* take care of the backend. If there is no one defined, we |
63 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 63 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
64 | */ | 64 | */ |
65 | if( end == 0 ) { | 65 | if( end == 0 ) { |
66 | qWarning ("Using BackendFactory !"); | 66 | qWarning ("Using BackendFactory !"); |
67 | end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname ); | 67 | end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname ); |
68 | } | 68 | } |
69 | // Set backend locally and in template | 69 | // Set backend locally and in template |
70 | m_backEnd = end; | 70 | m_backEnd = end; |
71 | OPimAccessTemplate<OPimContact>::setBackEnd (end); | 71 | OPimAccessTemplate<OPimContact>::setBackEnd (end); |
72 | 72 | ||
73 | 73 | ||
74 | /* Connect signal of external db change to function */ | 74 | /* Connect signal of external db change to function */ |
75 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); | 75 | QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); |
76 | connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 76 | connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
77 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 77 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
78 | if ( autosync ){ | 78 | if ( autosync ){ |
79 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); | 79 | QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); |
80 | connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), | 80 | connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), |
81 | this, SLOT(copMessage( const QCString &, const QByteArray &)) ); | 81 | this, SLOT(copMessage(const QCString&,const QByteArray&)) ); |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | } | 85 | } |
86 | OPimContactAccess::~OPimContactAccess () | 86 | OPimContactAccess::~OPimContactAccess () |
87 | { | 87 | { |
88 | /* The user may forget to save the changed database, therefore try to | 88 | /* The user may forget to save the changed database, therefore try to |
89 | * do it for him.. | 89 | * do it for him.. |
90 | */ | 90 | */ |
91 | save(); | 91 | save(); |
92 | // delete m_backEnd; is done by template.. | 92 | // delete m_backEnd; is done by template.. |
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | bool OPimContactAccess::save () | 96 | bool OPimContactAccess::save () |
97 | { | 97 | { |
98 | /* If the database was changed externally, we could not save the | 98 | /* If the database was changed externally, we could not save the |
99 | * Data. This will remove added items which is unacceptable ! | 99 | * Data. This will remove added items which is unacceptable ! |
100 | * Therefore: Reload database and merge the data... | 100 | * Therefore: Reload database and merge the data... |
101 | */ | 101 | */ |
102 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) | 102 | if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) |
103 | reload(); | 103 | reload(); |
104 | 104 | ||
105 | bool status = OPimAccessTemplate<OPimContact>::save(); | 105 | bool status = OPimAccessTemplate<OPimContact>::save(); |
106 | if ( !status ) return false; | 106 | if ( !status ) return false; |
107 | 107 | ||
108 | /* Now tell everyone that new data is available. | 108 | /* Now tell everyone that new data is available. |
109 | */ | 109 | */ |
110 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | 110 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
111 | 111 | ||
112 | return true; | 112 | return true; |
113 | } | 113 | } |
114 | 114 | ||
115 | const uint OPimContactAccess::querySettings() | 115 | const uint OPimContactAccess::querySettings() |
116 | { | 116 | { |
117 | return ( m_backEnd->querySettings() ); | 117 | return ( m_backEnd->querySettings() ); |
118 | } | 118 | } |
119 | 119 | ||
120 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const | 120 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const |
121 | { | 121 | { |
122 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 122 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
123 | } | 123 | } |
124 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 124 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
125 | { | 125 | { |
126 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); | 126 | QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); |
127 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); | 127 | return ( OPimRecordList<OPimContact>(matchingContacts, this) ); |
128 | } | 128 | } |
129 | 129 | ||