-rw-r--r-- | kabc/resource.cpp | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/kabc/resource.cpp b/kabc/resource.cpp index 9a1a5f8..9632a3f 100644 --- a/kabc/resource.cpp +++ b/kabc/resource.cpp | |||
@@ -1,95 +1,154 @@ | |||
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 | 27 | ||
28 | #include <kdebug.h> | 28 | #include <kdebug.h> |
29 | 29 | ||
30 | #include <ksyncprofile.h> | ||
31 | |||
30 | #include "resource.h" | 32 | #include "resource.h" |
31 | 33 | ||
32 | using namespace KABC; | 34 | using namespace KABC; |
33 | 35 | ||
34 | Resource::Resource( const KConfig *config ) | 36 | Resource::Resource( const KConfig *config, bool syncable ) |
35 | : KRES::Resource( config ), mAddressBook( 0 ) | 37 | : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) |
36 | { | 38 | { |
39 | if(syncable == true) { | ||
40 | mSyncProfile = new KSyncProfile( identifier() ); | ||
41 | mSyncProfile->setName(resourceName()); | ||
42 | mSyncProfile->readConfig( (KConfig *)config ); | ||
43 | } | ||
37 | } | 44 | } |
38 | 45 | ||
39 | Resource::~Resource() | 46 | Resource::~Resource() |
40 | { | 47 | { |
48 | if (mSyncProfile != 0) { | ||
49 | delete mSyncProfile; | ||
50 | } | ||
41 | } | 51 | } |
42 | 52 | ||
43 | void Resource::writeConfig( KConfig *config ) | 53 | void Resource::writeConfig( KConfig *config ) |
44 | { | 54 | { |
45 | KRES::Resource::writeConfig( config ); | 55 | KRES::Resource::writeConfig( config ); |
56 | |||
57 | if(mSyncProfile != 0) | ||
58 | mSyncProfile->writeConfig( config ); | ||
46 | } | 59 | } |
47 | 60 | ||
61 | |||
48 | void Resource::setAddressBook( AddressBook *ab ) | 62 | void Resource::setAddressBook( AddressBook *ab ) |
49 | { | 63 | { |
50 | mAddressBook = ab; | 64 | mAddressBook = ab; |
51 | } | 65 | } |
52 | 66 | ||
53 | AddressBook *Resource::addressBook() | 67 | AddressBook *Resource::addressBook() |
54 | { | 68 | { |
55 | return mAddressBook; | 69 | return mAddressBook; |
56 | } | 70 | } |
57 | 71 | ||
58 | bool Resource::doOpen() | 72 | bool Resource::doOpen() |
59 | { | 73 | { |
60 | return true; | 74 | return true; |
61 | } | 75 | } |
62 | 76 | ||
63 | void Resource::doClose() | 77 | void Resource::doClose() |
64 | { | 78 | { |
65 | } | 79 | } |
66 | 80 | ||
67 | Ticket *Resource::requestSaveTicket() | 81 | Ticket *Resource::requestSaveTicket() |
68 | { | 82 | { |
69 | return 0; | 83 | return 0; |
70 | } | 84 | } |
71 | 85 | ||
72 | bool Resource::load() | 86 | bool Resource::load() |
73 | { | 87 | { |
74 | return true; | 88 | return true; |
75 | } | 89 | } |
76 | 90 | ||
77 | bool Resource::save( Ticket * ) | 91 | bool Resource::save( Ticket * ) |
78 | { | 92 | { |
79 | return false; | 93 | return false; |
80 | } | 94 | } |
81 | 95 | ||
82 | Ticket *Resource::createTicket( Resource *resource ) | 96 | Ticket *Resource::createTicket( Resource *resource ) |
83 | { | 97 | { |
84 | return new Ticket( resource ); | 98 | return new Ticket( resource ); |
85 | } | 99 | } |
86 | 100 | ||
87 | void Resource::removeAddressee( const Addressee& ) | 101 | void Resource::removeAddressee( const Addressee& ) |
88 | { | 102 | { |
89 | // do nothing | 103 | // do nothing |
90 | } | 104 | } |
91 | 105 | ||
92 | void Resource::cleanUp() | 106 | void Resource::cleanUp() |
93 | { | 107 | { |
94 | // do nothing | 108 | // do nothing |
95 | } | 109 | } |
110 | |||
111 | bool Resource::isSyncable() const | ||
112 | { | ||
113 | return (mSyncProfile != 0); | ||
114 | } | ||
115 | |||
116 | /** | ||
117 | * This method returns the number of elements that are currently in the resource. | ||
118 | */ | ||
119 | int Resource::count() const | ||
120 | { | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * This method removes all elements from the resource!! (Not from the addressbook) | ||
126 | */ | ||
127 | bool Resource::clear() | ||
128 | { | ||
129 | return false; | ||
130 | } | ||
131 | |||
132 | QString Resource::fileName() const | ||
133 | { | ||
134 | return mFileName; | ||
135 | } | ||
136 | |||
137 | void Resource::setFileName( const QString &fileName ) | ||
138 | { | ||
139 | mFileName = fileName; | ||
140 | } | ||
141 | |||
142 | /** | ||
143 | * Set the name of resource.You can override this method, | ||
144 | * but also remember to call Resource::setResourceName(). | ||
145 | */ | ||
146 | void Resource::setResourceName( const QString &name ) | ||
147 | { | ||
148 | KRES::Resource::setResourceName(name); | ||
149 | if(mSyncProfile != 0) { | ||
150 | mSyncProfile->setName( name ); | ||
151 | } | ||
152 | |||
153 | } | ||
154 | |||