author | zautrix <zautrix> | 2004-10-23 06:49:54 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-23 06:49:54 (UTC) |
commit | 65989e4ab454f228fb6cd2fa532145ed54366701 (patch) (unidiff) | |
tree | a93a8cd6ef806dd5b6c38e8792a6e007b9e5e413 /kabc/plugins | |
parent | 0f0dc54f0edc8c4ec5b320118c82fa5150591fed (diff) | |
download | kdepimpi-65989e4ab454f228fb6cd2fa532145ed54366701.zip kdepimpi-65989e4ab454f228fb6cd2fa532145ed54366701.tar.gz kdepimpi-65989e4ab454f228fb6cd2fa532145ed54366701.tar.bz2 |
statusmessage added topwm.fixed initialization problem.changed sring in translation
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/qtopiaconverter.h | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopia.cpp | 2 | ||||
-rw-r--r-- | kabc/plugins/qtopia/resourceqtopiaconfig.cpp | 3 |
4 files changed, 0 insertions, 9 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp index 106596f..39d366b 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.cpp +++ b/kabc/plugins/qtopia/qtopiaconverter.cpp | |||
@@ -1,138 +1,136 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | //US | 28 | //US |
29 | #include "kglobal.h" | 29 | #include "kglobal.h" |
30 | #include "klocale.h" | 30 | #include "klocale.h" |
31 | 31 | ||
32 | 32 | ||
33 | #include "qtopiaconverter.h" | 33 | #include "qtopiaconverter.h" |
34 | 34 | ||
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qdir.h> | 36 | #include <qdir.h> |
37 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
38 | //#include <.h> | 38 | //#include <.h> |
39 | 39 | ||
40 | //#include <qpe/categories.h> | ||
41 | #include <libkdepim/ksyncprofile.h> | 40 | #include <libkdepim/ksyncprofile.h> |
42 | //US #include <qpe/categoryselect.h> | ||
43 | 41 | ||
44 | 42 | ||
45 | using namespace KABC; | 43 | using namespace KABC; |
46 | 44 | ||
47 | QtopiaConverter::QtopiaConverter() | 45 | QtopiaConverter::QtopiaConverter() |
48 | { | 46 | { |
49 | m_edit = 0; | 47 | m_edit = 0; |
50 | } | 48 | } |
51 | 49 | ||
52 | QtopiaConverter::~QtopiaConverter() | 50 | QtopiaConverter::~QtopiaConverter() |
53 | { | 51 | { |
54 | deinit(); | 52 | deinit(); |
55 | } | 53 | } |
56 | 54 | ||
57 | bool QtopiaConverter::init() | 55 | bool QtopiaConverter::init() |
58 | { | 56 | { |
59 | QString fn = QDir::homeDirPath() +"/Settings/Categories.xml"; | 57 | QString fn = QDir::homeDirPath() +"/Settings/Categories.xml"; |
60 | m_edit = new CategoryEdit( fn); | 58 | m_edit = new CategoryEdit( fn); |
61 | return true; | 59 | return true; |
62 | } | 60 | } |
63 | 61 | ||
64 | void QtopiaConverter::deinit() | 62 | void QtopiaConverter::deinit() |
65 | { | 63 | { |
66 | if (m_edit) | 64 | if (m_edit) |
67 | { | 65 | { |
68 | delete m_edit; | 66 | delete m_edit; |
69 | m_edit = 0; | 67 | m_edit = 0; |
70 | } | 68 | } |
71 | } | 69 | } |
72 | QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app ) | 70 | QString QtopiaConverter::categoriesToNumber( const QStringList &list, const QString &app ) |
73 | { | 71 | { |
74 | startover: | 72 | startover: |
75 | QStringList dummy; | 73 | QStringList dummy; |
76 | QValueList<OpieCategories>::ConstIterator catIt; | 74 | QValueList<OpieCategories>::ConstIterator catIt; |
77 | QValueList<OpieCategories> categories = m_edit->categories(); | 75 | QValueList<OpieCategories> categories = m_edit->categories(); |
78 | bool found = false; | 76 | bool found = false; |
79 | for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) { | 77 | for ( QStringList::ConstIterator listIt = list.begin(); listIt != list.end(); ++listIt ) { |
80 | /* skip empty category name */ | 78 | /* skip empty category name */ |
81 | if ( (*listIt).isEmpty() ) continue; | 79 | if ( (*listIt).isEmpty() ) continue; |
82 | 80 | ||
83 | found = false; | 81 | found = false; |
84 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { | 82 | for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { |
85 | /* | 83 | /* |
86 | * We currently do not take app into account | 84 | * We currently do not take app into account |
87 | * if name matches and the id isn't already in dummy we'll add it | 85 | * if name matches and the id isn't already in dummy we'll add it |
88 | */ | 86 | */ |
89 | if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name | 87 | if ( (*catIt).name() == (*listIt) && !dummy.contains(( *catIt).id() ) ) { // the same name |
90 | found= true; | 88 | found= true; |
91 | dummy << (*catIt).id(); | 89 | dummy << (*catIt).id(); |
92 | } | 90 | } |
93 | } | 91 | } |
94 | /* if not found and the category is not empty | 92 | /* if not found and the category is not empty |
95 | * | 93 | * |
96 | * generate a new category and start over again | 94 | * generate a new category and start over again |
97 | * ugly goto to reiterate | 95 | * ugly goto to reiterate |
98 | */ | 96 | */ |
99 | 97 | ||
100 | if ( !found && !(*listIt).isEmpty() ){ | 98 | if ( !found && !(*listIt).isEmpty() ){ |
101 | m_edit->addCategory( app, (*listIt) ); // generate a new category | 99 | m_edit->addCategory( app, (*listIt) ); // generate a new category |
102 | goto startover; | 100 | goto startover; |
103 | } | 101 | } |
104 | } | 102 | } |
105 | 103 | ||
106 | return dummy.join(";"); | 104 | return dummy.join(";"); |
107 | } | 105 | } |
108 | 106 | ||
109 | 107 | ||
110 | // FROM TT timeconversion.cpp GPLed | 108 | // FROM TT timeconversion.cpp GPLed |
111 | QDate QtopiaConverter::fromString( const QString &datestr ) | 109 | QDate QtopiaConverter::fromString( const QString &datestr ) |
112 | { | 110 | { |
113 | if (datestr.isEmpty() ) | 111 | if (datestr.isEmpty() ) |
114 | return QDate(); | 112 | return QDate(); |
115 | 113 | ||
116 | int monthPos = datestr.find('.'); | 114 | int monthPos = datestr.find('.'); |
117 | int yearPos = datestr.find('.', monthPos+1 ); | 115 | int yearPos = datestr.find('.', monthPos+1 ); |
118 | if ( monthPos == -1 || yearPos == -1 ) { | 116 | if ( monthPos == -1 || yearPos == -1 ) { |
119 | return QDate(); | 117 | return QDate(); |
120 | } | 118 | } |
121 | int d = datestr.left( monthPos ).toInt(); | 119 | int d = datestr.left( monthPos ).toInt(); |
122 | int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); | 120 | int m = datestr.mid( monthPos+1, yearPos - monthPos - 1 ).toInt(); |
123 | int y = datestr.mid( yearPos+1 ).toInt(); | 121 | int y = datestr.mid( yearPos+1 ).toInt(); |
124 | QDate date ( y,m,d ); | 122 | QDate date ( y,m,d ); |
125 | 123 | ||
126 | 124 | ||
127 | return date; | 125 | return date; |
128 | } | 126 | } |
129 | 127 | ||
130 | QDate QtopiaConverter::dateFromString( const QString& s ) | 128 | QDate QtopiaConverter::dateFromString( const QString& s ) |
131 | { | 129 | { |
132 | QDate date; | 130 | QDate date; |
133 | 131 | ||
134 | if ( s.isEmpty() ) | 132 | if ( s.isEmpty() ) |
135 | return date; | 133 | return date; |
136 | 134 | ||
137 | // Be backward compatible to old Opie format: | 135 | // Be backward compatible to old Opie format: |
138 | // Try to load old format. If it fails, try new ISO-Format! | 136 | // Try to load old format. If it fails, try new ISO-Format! |
diff --git a/kabc/plugins/qtopia/qtopiaconverter.h b/kabc/plugins/qtopia/qtopiaconverter.h index d318ded..cb5b433 100644 --- a/kabc/plugins/qtopia/qtopiaconverter.h +++ b/kabc/plugins/qtopia/qtopiaconverter.h | |||
@@ -1,130 +1,128 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | $Id$ | 24 | $Id$ |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef KABC_QTOPIACONVERTER_H | 27 | #ifndef KABC_QTOPIACONVERTER_H |
28 | #define KABC_QTOPIACONVERTER_H | 28 | #define KABC_QTOPIACONVERTER_H |
29 | 29 | ||
30 | #include <qstring.h> | 30 | #include <qstring.h> |
31 | 31 | ||
32 | #include "addressee.h" | 32 | #include "addressee.h" |
33 | //#include <qpe/pim/contact.h> | ||
34 | //#include <qpe/quuid.h> | ||
35 | 33 | ||
36 | #include <xml/qdom.h> | 34 | #include <xml/qdom.h> |
37 | class Categories; | 35 | class Categories; |
38 | 36 | ||
39 | namespace KABC { | 37 | namespace KABC { |
40 | 38 | ||
41 | 39 | ||
42 | 40 | ||
43 | class OpieCategories { | 41 | class OpieCategories { |
44 | public: | 42 | public: |
45 | //friend class KSync::OpieSocket; | 43 | //friend class KSync::OpieSocket; |
46 | friend bool operator== ( const OpieCategories &a, const OpieCategories &b ); | 44 | friend bool operator== ( const OpieCategories &a, const OpieCategories &b ); |
47 | OpieCategories(); | 45 | OpieCategories(); |
48 | OpieCategories(const QString &id, const QString &name, const QString &app ); | 46 | OpieCategories(const QString &id, const QString &name, const QString &app ); |
49 | OpieCategories(const OpieCategories & ); | 47 | OpieCategories(const OpieCategories & ); |
50 | ~OpieCategories() {}; | 48 | ~OpieCategories() {}; |
51 | OpieCategories &operator=(const OpieCategories & ); | 49 | OpieCategories &operator=(const OpieCategories & ); |
52 | QString id()const; | 50 | QString id()const; |
53 | QString name()const; | 51 | QString name()const; |
54 | QString app()const; | 52 | QString app()const; |
55 | 53 | ||
56 | private: | 54 | private: |
57 | QString m_name; | 55 | QString m_name; |
58 | QString m_app; | 56 | QString m_app; |
59 | QString m_id; | 57 | QString m_id; |
60 | }; | 58 | }; |
61 | 59 | ||
62 | 60 | ||
63 | class CategoryEdit { | 61 | class CategoryEdit { |
64 | public: | 62 | public: |
65 | CategoryEdit(); | 63 | CategoryEdit(); |
66 | CategoryEdit(const QString &fileName); | 64 | CategoryEdit(const QString &fileName); |
67 | ~CategoryEdit(); | 65 | ~CategoryEdit(); |
68 | 66 | ||
69 | void save(const QString&) const; | 67 | void save(const QString&) const; |
70 | int addCategory( const QString &name, int id = 0 ); | 68 | int addCategory( const QString &name, int id = 0 ); |
71 | int addCategory(const QString &appName, const QString &name, int id = 0); | 69 | int addCategory(const QString &appName, const QString &name, int id = 0); |
72 | void parse( const QString &fileName ); | 70 | void parse( const QString &fileName ); |
73 | 71 | ||
74 | QString categoryById(const QString &id, const QString &app )const; | 72 | QString categoryById(const QString &id, const QString &app )const; |
75 | QStringList categoriesByIds( const QStringList& ids, const QString& app ); | 73 | QStringList categoriesByIds( const QStringList& ids, const QString& app ); |
76 | 74 | ||
77 | void clear(); | 75 | void clear(); |
78 | QValueList<OpieCategories> categories()const { return m_categories; }; | 76 | QValueList<OpieCategories> categories()const { return m_categories; }; |
79 | private: | 77 | private: |
80 | /** | 78 | /** |
81 | * this function will be used internally to update the kde categories... | 79 | * this function will be used internally to update the kde categories... |
82 | */ | 80 | */ |
83 | void updateKDE( const QString& app, const QStringList& categories ); | 81 | void updateKDE( const QString& app, const QStringList& categories ); |
84 | QMap<int, bool> ids; // from tt Qtopia::UidGen | 82 | QMap<int, bool> ids; // from tt Qtopia::UidGen |
85 | QValueList<OpieCategories> m_categories; | 83 | QValueList<OpieCategories> m_categories; |
86 | }; | 84 | }; |
87 | 85 | ||
88 | 86 | ||
89 | class QtopiaConverter | 87 | class QtopiaConverter |
90 | { | 88 | { |
91 | public: | 89 | public: |
92 | 90 | ||
93 | /** | 91 | /** |
94 | * Constructor. | 92 | * Constructor. |
95 | */ | 93 | */ |
96 | QtopiaConverter(); | 94 | QtopiaConverter(); |
97 | 95 | ||
98 | /** | 96 | /** |
99 | * Destructor. | 97 | * Destructor. |
100 | */ | 98 | */ |
101 | virtual ~QtopiaConverter(); | 99 | virtual ~QtopiaConverter(); |
102 | 100 | ||
103 | bool init(); | 101 | bool init(); |
104 | void deinit(); | 102 | void deinit(); |
105 | 103 | ||
106 | /** | 104 | /** |
107 | * Converts a vcard string to an addressee. | 105 | * Converts a vcard string to an addressee. |
108 | * | 106 | * |
109 | * @param contact The qtopia contact. | 107 | * @param contact The qtopia contact. |
110 | * @param addr The addressee. | 108 | * @param addr The addressee. |
111 | */ | 109 | */ |
112 | bool qtopiaToAddressee( const QDomElement& el, Addressee &adr ); | 110 | bool qtopiaToAddressee( const QDomElement& el, Addressee &adr ); |
113 | /** | 111 | /** |
114 | * Converts an addressee to a vcard string. | 112 | * Converts an addressee to a vcard string. |
115 | * | 113 | * |
116 | * @param addr The addressee. | 114 | * @param addr The addressee. |
117 | * @param contact The qtopia contact. | 115 | * @param contact The qtopia contact. |
118 | */ | 116 | */ |
119 | bool addresseeToQtopia( const Addressee &ab, QTextStream *stream ); | 117 | bool addresseeToQtopia( const Addressee &ab, QTextStream *stream ); |
120 | 118 | ||
121 | private: | 119 | private: |
122 | QString categoriesToNumber( const QStringList &list, const QString &app ); | 120 | QString categoriesToNumber( const QStringList &list, const QString &app ); |
123 | QString escape( const QString& s){ return s;}; | 121 | QString escape( const QString& s){ return s;}; |
124 | CategoryEdit *m_edit; | 122 | CategoryEdit *m_edit; |
125 | QDate fromString( const QString& ); | 123 | QDate fromString( const QString& ); |
126 | QDate dateFromString( const QString& ); | 124 | QDate dateFromString( const QString& ); |
127 | QString dateToString( const QDate& ); | 125 | QString dateToString( const QDate& ); |
128 | 126 | ||
129 | 127 | ||
130 | }; | 128 | }; |
diff --git a/kabc/plugins/qtopia/resourceqtopia.cpp b/kabc/plugins/qtopia/resourceqtopia.cpp index 4ee3c3c..95fa541 100644 --- a/kabc/plugins/qtopia/resourceqtopia.cpp +++ b/kabc/plugins/qtopia/resourceqtopia.cpp | |||
@@ -1,143 +1,141 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | #include <sys/types.h> | 27 | #include <sys/types.h> |
28 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
29 | #include <unistd.h> | 29 | #include <unistd.h> |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qfileinfo.h> | 34 | #include <qfileinfo.h> |
35 | #include <qregexp.h> | 35 | #include <qregexp.h> |
36 | //US #include <qtimer.h> | 36 | //US #include <qtimer.h> |
37 | 37 | ||
38 | #include <kapplication.h> | 38 | #include <kapplication.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <kdebug.h> | 40 | #include <kdebug.h> |
41 | #include <klocale.h> | 41 | #include <klocale.h> |
42 | //US #include <ksavefile.h> | 42 | //US #include <ksavefile.h> |
43 | #include <kstandarddirs.h> | 43 | #include <kstandarddirs.h> |
44 | #include <kmessagebox.h> | 44 | #include <kmessagebox.h> |
45 | 45 | ||
46 | #include <qpe/pim/addressbookaccess.h> | ||
47 | |||
48 | 46 | ||
49 | #include "resourceqtopiaconfig.h" | 47 | #include "resourceqtopiaconfig.h" |
50 | #include "stdaddressbook.h" | 48 | #include "stdaddressbook.h" |
51 | 49 | ||
52 | #include "qtopiaconverter.h" | 50 | #include "qtopiaconverter.h" |
53 | 51 | ||
54 | #include "resourceqtopia.h" | 52 | #include "resourceqtopia.h" |
55 | 53 | ||
56 | using namespace KABC; | 54 | using namespace KABC; |
57 | extern "C" | 55 | extern "C" |
58 | { | 56 | { |
59 | void *init_microkabc_qtopia() | 57 | void *init_microkabc_qtopia() |
60 | { | 58 | { |
61 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); | 59 | return new KRES::PluginFactory<ResourceQtopia,ResourceQtopiaConfig>(); |
62 | } | 60 | } |
63 | } | 61 | } |
64 | 62 | ||
65 | ResourceQtopia::ResourceQtopia( const KConfig *config ) | 63 | ResourceQtopia::ResourceQtopia( const KConfig *config ) |
66 | : Resource( config ), mConverter (0) | 64 | : Resource( config ), mConverter (0) |
67 | { | 65 | { |
68 | // we can not choose the filename. Therefore use the default to display | 66 | // we can not choose the filename. Therefore use the default to display |
69 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; | 67 | QString fileName = QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml"; |
70 | init( fileName ); | 68 | init( fileName ); |
71 | } | 69 | } |
72 | 70 | ||
73 | ResourceQtopia::ResourceQtopia( const QString &fileName ) | 71 | ResourceQtopia::ResourceQtopia( const QString &fileName ) |
74 | : Resource( 0 ) | 72 | : Resource( 0 ) |
75 | { | 73 | { |
76 | init( fileName ); | 74 | init( fileName ); |
77 | } | 75 | } |
78 | 76 | ||
79 | void ResourceQtopia::init( const QString &fileName ) | 77 | void ResourceQtopia::init( const QString &fileName ) |
80 | { | 78 | { |
81 | #ifdef _USE_DIRWATCH_ | 79 | #ifdef _USE_DIRWATCH_ |
82 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); | 80 | connect( &mDirWatch, SIGNAL( dirty(const QString&) ), SLOT( fileChanged() ) ); |
83 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); | 81 | connect( &mDirWatch, SIGNAL( created(const QString&) ), SLOT( fileChanged() ) ); |
84 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); | 82 | connect( &mDirWatch, SIGNAL( deleted(const QString&) ), SLOT( fileChanged() ) ); |
85 | #endif | 83 | #endif |
86 | setFileName( fileName ); | 84 | setFileName( fileName ); |
87 | } | 85 | } |
88 | 86 | ||
89 | ResourceQtopia::~ResourceQtopia() | 87 | ResourceQtopia::~ResourceQtopia() |
90 | { | 88 | { |
91 | if (mConverter != 0) | 89 | if (mConverter != 0) |
92 | delete mConverter; | 90 | delete mConverter; |
93 | 91 | ||
94 | } | 92 | } |
95 | 93 | ||
96 | void ResourceQtopia::writeConfig( KConfig *config ) | 94 | void ResourceQtopia::writeConfig( KConfig *config ) |
97 | { | 95 | { |
98 | Resource::writeConfig( config ); | 96 | Resource::writeConfig( config ); |
99 | } | 97 | } |
100 | 98 | ||
101 | Ticket *ResourceQtopia::requestSaveTicket() | 99 | Ticket *ResourceQtopia::requestSaveTicket() |
102 | { | 100 | { |
103 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; | 101 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket()" << endl; |
104 | 102 | ||
105 | qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); | 103 | qDebug("ResourceQtopia::requestSaveTicket: %s", fileName().latin1()); |
106 | 104 | ||
107 | if ( !addressBook() ) return 0; | 105 | if ( !addressBook() ) return 0; |
108 | 106 | ||
109 | if ( !lock( fileName() ) ) { | 107 | if ( !lock( fileName() ) ) { |
110 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" | 108 | kdDebug(5700) << "ResourceQtopia::requestSaveTicket(): Unable to lock file '" |
111 | << fileName() << "'" << endl; | 109 | << fileName() << "'" << endl; |
112 | return 0; | 110 | return 0; |
113 | } | 111 | } |
114 | return createTicket( this ); | 112 | return createTicket( this ); |
115 | } | 113 | } |
116 | 114 | ||
117 | 115 | ||
118 | bool ResourceQtopia::doOpen() | 116 | bool ResourceQtopia::doOpen() |
119 | { | 117 | { |
120 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); | 118 | qDebug("ResourceQtopia::doOpen(): %s", fileName().latin1()); |
121 | 119 | ||
122 | 120 | ||
123 | if (mConverter == 0) | 121 | if (mConverter == 0) |
124 | { | 122 | { |
125 | mConverter = new QtopiaConverter(); | 123 | mConverter = new QtopiaConverter(); |
126 | bool res = mConverter->init(); | 124 | bool res = mConverter->init(); |
127 | if ( !res ) | 125 | if ( !res ) |
128 | { | 126 | { |
129 | QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); | 127 | QString msg("Unable to initialize qtopia converter. Most likely a problem with the category file"); |
130 | qDebug(msg); | 128 | qDebug(msg); |
131 | return false; | 129 | return false; |
132 | } | 130 | } |
133 | } | 131 | } |
134 | 132 | ||
135 | return true; | 133 | return true; |
136 | } | 134 | } |
137 | 135 | ||
138 | void ResourceQtopia::doClose() | 136 | void ResourceQtopia::doClose() |
139 | { | 137 | { |
140 | qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); | 138 | qDebug("ResourceQtopia::doClose: %s", fileName().latin1()); |
141 | 139 | ||
142 | 140 | ||
143 | // it seems so, that deletion of access deletes backend as well | 141 | // it seems so, that deletion of access deletes backend as well |
diff --git a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp index b2310c4..0505d0b 100644 --- a/kabc/plugins/qtopia/resourceqtopiaconfig.cpp +++ b/kabc/plugins/qtopia/resourceqtopiaconfig.cpp | |||
@@ -1,110 +1,107 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkabc. | 2 | This file is part of libkabc. |
3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> | 3 | Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | Enhanced Version of the file for platform independent KDE tools. | 22 | Enhanced Version of the file for platform independent KDE tools. |
23 | Copyright (c) 2004 Ulf Schenk | 23 | Copyright (c) 2004 Ulf Schenk |
24 | 24 | ||
25 | $Id$ | 25 | $Id$ |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <klocale.h> | 32 | #include <klocale.h> |
33 | #include <kstandarddirs.h> | 33 | #include <kstandarddirs.h> |
34 | #include <kdialog.h> | 34 | #include <kdialog.h> |
35 | 35 | ||
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include "resourceqtopia.h" | 40 | #include "resourceqtopia.h" |
41 | //US #include <qpe/qpeapplication.h> | ||
42 | |||
43 | //US #include "stdaddressbook.h" | ||
44 | 41 | ||
45 | #include "resourceqtopiaconfig.h" | 42 | #include "resourceqtopiaconfig.h" |
46 | 43 | ||
47 | using namespace KABC; | 44 | using namespace KABC; |
48 | 45 | ||
49 | ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name ) | 46 | ResourceQtopiaConfig::ResourceQtopiaConfig( QWidget* parent, const char* name ) |
50 | : ConfigWidget( parent, name ) | 47 | : ConfigWidget( parent, name ) |
51 | { | 48 | { |
52 | QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, | 49 | QGridLayout *mainLayout = new QGridLayout( this, 1, 2, 0, |
53 | KDialog::spacingHint() ); | 50 | KDialog::spacingHint() ); |
54 | 51 | ||
55 | QLabel *label = new QLabel( i18n( "Location:" ), this ); | 52 | QLabel *label = new QLabel( i18n( "Location:" ), this ); |
56 | mFileNameEdit = new KURLRequester( this ); | 53 | mFileNameEdit = new KURLRequester( this ); |
57 | 54 | ||
58 | connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), | 55 | connect( mFileNameEdit, SIGNAL( textChanged( const QString & ) ), |
59 | SLOT( checkFilePermissions( const QString & ) ) ); | 56 | SLOT( checkFilePermissions( const QString & ) ) ); |
60 | 57 | ||
61 | mainLayout->addWidget( label, 0, 0 ); | 58 | mainLayout->addWidget( label, 0, 0 ); |
62 | mainLayout->addWidget( mFileNameEdit, 0, 1 ); | 59 | mainLayout->addWidget( mFileNameEdit, 0, 1 ); |
63 | 60 | ||
64 | } | 61 | } |
65 | 62 | ||
66 | void ResourceQtopiaConfig::loadSettings( KRES::Resource *res ) | 63 | void ResourceQtopiaConfig::loadSettings( KRES::Resource *res ) |
67 | { | 64 | { |
68 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | 65 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); |
69 | ResourceQtopia *resource = (ResourceQtopia*)( res ); | 66 | ResourceQtopia *resource = (ResourceQtopia*)( res ); |
70 | 67 | ||
71 | if ( !resource ) { | 68 | if ( !resource ) { |
72 | kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl; | 69 | kdDebug(5700) << "ResourceQtopiaConfig::loadSettings(): cast failed" << endl; |
73 | return; | 70 | return; |
74 | } | 71 | } |
75 | 72 | ||
76 | mFileNameEdit->setURL( resource->fileName() ); | 73 | mFileNameEdit->setURL( resource->fileName() ); |
77 | if ( mFileNameEdit->url().isEmpty() ) | 74 | if ( mFileNameEdit->url().isEmpty() ) |
78 | mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); | 75 | mFileNameEdit->setURL( QDir::homeDirPath() + "/Applications/addressbook/addressbook.xml" ); |
79 | 76 | ||
80 | //US Qtopia resources are ReadOnly by definition | 77 | //US Qtopia resources are ReadOnly by definition |
81 | emit setPersistentReadOnly( true ); | 78 | emit setPersistentReadOnly( true ); |
82 | 79 | ||
83 | //US we can not choose the filename for the qtopia backend => make it readonly. | 80 | //US we can not choose the filename for the qtopia backend => make it readonly. |
84 | mFileNameEdit->setEnabled( false ); | 81 | mFileNameEdit->setEnabled( false ); |
85 | 82 | ||
86 | } | 83 | } |
87 | 84 | ||
88 | void ResourceQtopiaConfig::saveSettings( KRES::Resource *res ) | 85 | void ResourceQtopiaConfig::saveSettings( KRES::Resource *res ) |
89 | { | 86 | { |
90 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); | 87 | //US ResourceFile *resource = dynamic_cast<ResourceFile*>( res ); |
91 | ResourceQtopia *resource = (ResourceQtopia*)( res ); | 88 | ResourceQtopia *resource = (ResourceQtopia*)( res ); |
92 | 89 | ||
93 | if ( !resource ) { | 90 | if ( !resource ) { |
94 | kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl; | 91 | kdDebug(5700) << "ResourceQtopiaConfig::saveSettings(): cast failed" << endl; |
95 | return; | 92 | return; |
96 | } | 93 | } |
97 | 94 | ||
98 | resource->setFileName( mFileNameEdit->url() ); | 95 | resource->setFileName( mFileNameEdit->url() ); |
99 | } | 96 | } |
100 | 97 | ||
101 | void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName ) | 98 | void ResourceQtopiaConfig::checkFilePermissions( const QString& fileName ) |
102 | { | 99 | { |
103 | // If file exist but is not writeable... | 100 | // If file exist but is not writeable... |
104 | /*US | 101 | /*US |
105 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) | 102 | if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) |
106 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); | 103 | emit setReadOnly( access( QFile::encodeName( fileName ), W_OK ) < 0 ); |
107 | */ | 104 | */ |
108 | } | 105 | } |
109 | 106 | ||
110 | //US #include "resourceopieconfig.moc" | 107 | //US #include "resourceopieconfig.moc" |