summaryrefslogtreecommitdiffabout
path: root/kabc/converter
authorulf69 <ulf69>2004-06-30 22:12:32 (UTC)
committer ulf69 <ulf69>2004-06-30 22:12:32 (UTC)
commit34c8059a5400d4a13456a5b4cb90328369999f20 (patch) (unidiff)
tree694e9a6b7814522ddec59b52cbaad3fe5690afea /kabc/converter
parentbd79f5a89b0d1071ef9ad749fe3a8096bbc25b0b (diff)
downloadkdepimpi-34c8059a5400d4a13456a5b4cb90328369999f20.zip
kdepimpi-34c8059a5400d4a13456a5b4cb90328369999f20.tar.gz
kdepimpi-34c8059a5400d4a13456a5b4cb90328369999f20.tar.bz2
*** empty log message ***
Diffstat (limited to 'kabc/converter') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/converter/converter.pro4
-rw-r--r--kabc/converter/opie/opieconverter.cpp196
-rw-r--r--kabc/converter/opie/opieconverter.h74
-rw-r--r--kabc/converter/opie/opieconverterE.pro31
4 files changed, 305 insertions, 0 deletions
diff --git a/kabc/converter/converter.pro b/kabc/converter/converter.pro
new file mode 100644
index 0000000..0f44d2e
--- a/dev/null
+++ b/kabc/converter/converter.pro
@@ -0,0 +1,4 @@
1
2
3TEMPLATE = subdirs
4SUBDIRS = opie
diff --git a/kabc/converter/opie/opieconverter.cpp b/kabc/converter/opie/opieconverter.cpp
new file mode 100644
index 0000000..fbb5817
--- a/dev/null
+++ b/kabc/converter/opie/opieconverter.cpp
@@ -0,0 +1,196 @@
1/*
2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
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
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/*
22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk
24
25$Id$
26*/
27
28//US
29#include "kglobal.h"
30
31
32#include "opieconverter.h"
33
34using namespace KABC;
35
36OpieConverter::OpieConverter()
37{
38}
39
40OpieConverter::~OpieConverter()
41{
42}
43
44bool OpieConverter::opieToAddressee( OContact &contact, Addressee &addr )
45{
46 // name
47//US QString fileAs() const { return find( Qtopia::FileAs ); }
48
49 addr.setFamilyName( contact.lastName() );
50 addr.setGivenName( contact.firstName() );
51 addr.setAdditionalName( contact.middleName() );
52 addr.setPrefix( contact.title() );
53 addr.setSuffix( contact.suffix() );
54
55
56 // email
57 QStringList emails = contact.emailList();
58 for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
59 addr.insertEmail( *it, ((*it) == contact.defaultEmail()) );
60 }
61
62 // home
63 Address homeaddress;
64 homeaddress.setType(Address::Home);
65//US homeaddress.setPostOfficeBox( "" );
66//US homeaddress.setExtended( "" );
67 homeaddress.setStreet( contact.homeStreet() );
68 homeaddress.setLocality( contact.homeCity() );
69 homeaddress.setRegion( contact.homeState() );
70 homeaddress.setPostalCode( contact.homeZip() );
71 homeaddress.setCountry( contact.homeCountry() );
72
73 addr.insertAddress( homeaddress );
74
75 if (!contact.homePhone().isEmpty())
76 {
77 PhoneNumber homephone;
78 homephone.setType( PhoneNumber::Home );
79 homephone.setNumber( contact.homePhone() );
80 addr.insertPhoneNumber( homephone );
81 }
82
83 if (!contact.homeFax().isEmpty())
84 {
85 PhoneNumber homefax;
86 homefax.setType( PhoneNumber::Home | PhoneNumber::Fax );
87 homefax.setNumber( contact.homeFax() );
88 addr.insertPhoneNumber( homefax );
89 }
90
91 if (!contact.homeMobile().isEmpty())
92 {
93 PhoneNumber homemobile;
94 homemobile.setType( PhoneNumber::Home | PhoneNumber::Cell );
95 homemobile.setNumber( contact.homeMobile() );
96 addr.insertPhoneNumber( homemobile );
97 }
98
99 addr.setUrl( contact.homeWebpage() );
100
101
102 // business
103 Address businessaddress;
104 businessaddress.setType(Address::Work);
105//US businessaddress.setPostOfficeBox( "" );
106//US businessaddress.setExtended( "" );
107 businessaddress.setStreet( contact.businessStreet() );
108 businessaddress.setLocality( contact.businessCity() );
109 businessaddress.setRegion( contact.businessState() );
110 businessaddress.setPostalCode( contact.businessZip() );
111 businessaddress.setCountry( contact.businessCountry() );
112
113 addr.insertAddress( businessaddress );
114
115 if (!contact.businessPhone().isEmpty())
116 {
117 PhoneNumber businessphone;
118 businessphone.setType( PhoneNumber::Work );
119 businessphone.setNumber( contact.businessPhone() );
120 addr.insertPhoneNumber( businessphone );
121 }
122
123 if (!contact.businessFax().isEmpty())
124 {
125 PhoneNumber businessfax;
126 businessfax.setType( PhoneNumber::Work | PhoneNumber::Fax );
127 businessfax.setNumber( contact.businessFax() );
128 addr.insertPhoneNumber( businessfax );
129 }
130
131 if (!contact.businessMobile().isEmpty())
132 {
133 PhoneNumber businessmobile;
134 businessmobile.setType( PhoneNumber::Work | PhoneNumber::Cell );
135 businessmobile.setNumber( contact.businessMobile() );
136 addr.insertPhoneNumber( businessmobile );
137 }
138
139 if (!contact.businessPager().isEmpty())
140 {
141 PhoneNumber businesspager;
142 businesspager.setType( PhoneNumber::Work | PhoneNumber::Pager );
143 businesspager.setNumber( contact.businessPager() );
144 addr.insertPhoneNumber( businesspager );
145 }
146
147 addr.setRole( contact.jobTitle() ); //?
148 addr.setOrganization( contact.company() );
149 addr.insertCustom( "KADDRESSBOOK", "X-Profession", contact.profession() );
150 addr.insertCustom( "KADDRESSBOOK", "X-AssistantsName", contact.assistant() );
151 addr.insertCustom( "KADDRESSBOOK", "X-Department", contact.department() );
152 addr.insertCustom( "KADDRESSBOOK", "X-ManagersName", contact.manager() );
153 addr.insertCustom( "KADDRESSBOOK", "X-Office", contact.office() );
154
155//???
156//US QString businessWebpage() const { return find( Qtopia::BusinessWebPage ); }
157
158 //personal
159 addr.insertCustom( "KADDRESSBOOK", "X-SpousesName", contact.spouse() );
160 addr.insertCustom( "KADDRESSBOOK", "X-Gender", contact.gender() );
161 addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dateToAddresseeString(contact.anniversary()) );
162 addr.insertCustom( "KADDRESSBOOK", "X-Children", contact.children() );
163 addr.setBirthday( contact.birthday() );
164 addr.setNickName( contact.nickname() );
165
166 // other
167 addr.setNote( contact.notes() );
168
169//US QString groups() const { return find( Qtopia::Groups ); }
170//US QStringList groupList() const;
171
172/*US
173 QStringList cats = contact.categoryNames("Contacts");
174 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
175 qDebug("Cat: %s", (*it).latin1());
176 }
177*/
178 addr.setCategories( contact.categoryNames("Contacts") );
179// qDebug("Groups: %s", contact.groups().latin1());
180// addr.setCategories( contact.groupList() );
181
182
183 return true;
184}
185
186bool OpieConverter::addresseeToOpie( const Addressee &addr, OContact &contact )
187{
188 return false;
189}
190
191QString OpieConverter::dateToAddresseeString( const QDate &date )
192{
193 return KGlobal::locale()->formatDate(date, true);
194//US return date.toString("yyyyMMdd");
195}
196
diff --git a/kabc/converter/opie/opieconverter.h b/kabc/converter/opie/opieconverter.h
new file mode 100644
index 0000000..55a869a
--- a/dev/null
+++ b/kabc/converter/opie/opieconverter.h
@@ -0,0 +1,74 @@
1/*
2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
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
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/*
22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk
24
25$Id$
26*/
27
28#ifndef KABC_OPIECONVERTER_H
29#define KABC_OPIECONVERTER_H
30
31#include <qstring.h>
32
33#include "addressee.h"
34#include <opie/ocontact.h>
35
36namespace KABC {
37
38class OpieConverter
39{
40public:
41
42 /**
43 * Constructor.
44 */
45 OpieConverter();
46
47 /**
48 * Destructor.
49 */
50 ~OpieConverter();
51
52 /**
53 * Converts a vcard string to an addressee.
54 *
55 * @param contact The opie contact.
56 * @param addr The addressee.
57 */
58 bool opieToAddressee( OContact &contact, Addressee &addr );
59
60 /**
61 * Converts an addressee to a vcard string.
62 *
63 * @param addr The addressee.
64 * @param contact The opie contact.
65 */
66 bool addresseeToOpie( const Addressee &addr, OContact &contact );
67
68 private:
69 QString dateToAddresseeString( const QDate &date );
70
71};
72
73}
74#endif
diff --git a/kabc/converter/opie/opieconverterE.pro b/kabc/converter/opie/opieconverterE.pro
new file mode 100644
index 0000000..314bb1e
--- a/dev/null
+++ b/kabc/converter/opie/opieconverterE.pro
@@ -0,0 +1,31 @@
1TEMPLATE = lib
2INCLUDEPATH += . ../.. ../../../microkde ../../../microkde/kdecore $(QPEDIR)/include
3#CONFIG += staticlib
4OBJECTS_DIR = obj/$(PLATFORM)
5MOC_DIR = moc/$(PLATFORM)
6
7#for static linkage, put it here
8#DESTDIR=../../lib/$(PLATFORM)
9
10#for dynamic linkage, put it here
11DESTDIR=$(QPEDIR)/lib
12
13LIBS += -lmicrokde
14LIBS += -lmicrokabc
15LIBS += -L$(QPEDIR)/lib
16LIBS += -lopie
17LIBS += -lqpe
18LIBS += -lqte
19
20
21TARGET = microkabc_opieconverter
22
23# Input
24
25HEADERS += \
26 opieconverter.h \
27
28
29SOURCES += \
30 opieconverter.cpp \
31