Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KDE PIM Add-ons
Commits
a9e7aff1
Commit
a9e7aff1
authored
Aug 06, 2020
by
Laurent Montel
😁
Browse files
Fix Bug 424940 - Add support for importing Windows contacts from .contact XML files
BUG: 424940 FIXED-IN: 5.16.0
parent
32c293c1
Pipeline
#29848
failed with stage
in 60 minutes
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
kaddressbook/importexportplugins/windows-contacts/autotests/importwindowcontacttest.cpp
View file @
a9e7aff1
This diff is collapsed.
Click to expand it.
kaddressbook/importexportplugins/windows-contacts/importwindowcontact.cpp
View file @
a9e7aff1
...
...
@@ -65,7 +65,6 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
KContacts
::
Email
::
List
lstEmails
;
for
(
QDomElement
emails
=
e
.
firstChildElement
();
!
emails
.
isNull
();
emails
=
emails
.
nextSiblingElement
())
{
const
QString
emailsTag
=
emails
.
tagName
();
qDebug
()
<<
" emailstag "
<<
emailsTag
;
if
(
emailsTag
==
QLatin1String
(
"c:EmailAddress"
))
{
KContacts
::
Email
email
;
for
(
QDomElement
addresses
=
emails
.
firstChildElement
();
!
addresses
.
isNull
();
addresses
=
addresses
.
nextSiblingElement
())
{
...
...
@@ -75,10 +74,12 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
}
else
if
(
addressesTag
==
QLatin1String
(
"c:Address"
))
{
email
.
setEmail
(
addresses
.
text
());
}
else
{
q
Debug
(
)
<<
" address tag not supported yet "
<<
addressesTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" address tag not supported yet "
<<
addressesTag
;
}
}
lstEmails
<<
email
;
if
(
email
.
isValid
())
{
lstEmails
<<
email
;
}
}
contact
.
setEmailList
(
lstEmails
);
}
...
...
@@ -105,11 +106,11 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
}
else
if
(
nameInfoTag
==
QLatin1String
(
"c:Suffix"
))
{
contact
.
setSuffix
(
nameInfo
.
text
());
}
else
{
q
Debug
(
)
<<
" name tag not supported yet "
<<
nameInfoTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" name tag not supported yet "
<<
nameInfoTag
;
}
}
}
else
{
q
Debug
(
)
<<
" name tag unknown:"
<<
nameTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" name tag unknown:"
<<
nameTag
;
}
}
}
else
if
(
tag
==
QLatin1String
(
"c:PhoneNumberCollection"
))
{
...
...
@@ -122,14 +123,14 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
if
(
numberInfoTag
==
QLatin1String
(
"c:Number"
))
{
phoneNumber
.
setNumber
(
numberInfo
.
text
());
}
else
{
q
Debug
(
)
<<
" number info tag not supported yet:"
<<
numberInfoTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" number info tag not supported yet:"
<<
numberInfoTag
;
}
}
if
(
!
phoneNumber
.
isEmpty
())
{
contact
.
insertPhoneNumber
(
phoneNumber
);
}
}
else
{
q
Debug
(
)
<<
" number tag unknown:"
<<
numberTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" number tag unknown:"
<<
numberTag
;
}
}
}
else
if
(
tag
==
QLatin1String
(
"c:IMAddressCollection"
))
{
...
...
@@ -142,14 +143,14 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
if
(
imInfoTag
==
QLatin1String
(
"c:Value"
))
{
impp
.
setAddress
(
QUrl
(
imInfo
.
text
()));
}
else
{
q
Debug
(
)
<<
" im info tag not supported yet "
<<
imInfoTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" im info tag not supported yet "
<<
imInfoTag
;
}
}
if
(
impp
.
isValid
())
{
contact
.
insertImpp
(
impp
);
}
}
else
{
q
Debug
(
)
<<
" im tag unknown:"
<<
imTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" im tag unknown:"
<<
imTag
;
}
}
}
else
if
(
tag
==
QLatin1String
(
"c:PhotoCollection"
))
{
...
...
@@ -161,18 +162,18 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
const
QString
photoInfoTag
=
photoInfo
.
tagName
();
if
(
photoInfoTag
==
QLatin1String
(
"c:Value"
))
{
const
QString
contentType
=
photoInfo
.
attribute
(
QStringLiteral
(
"c:ContentType"
));
picture
.
setRawData
(
photoInfo
.
text
().
to
Latin1
(),
contentType
);
picture
.
setRawData
(
photoInfo
.
text
().
to
Utf8
(),
contentType
);
}
else
if
(
photoInfoTag
==
QLatin1String
(
"c:Url"
))
{
picture
.
setUrl
(
photoInfo
.
text
());
}
else
{
q
Debug
(
)
<<
" photo info tag not supported yet "
<<
photoInfoTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" photo info tag not supported yet "
<<
photoInfoTag
;
}
}
if
(
!
picture
.
isEmpty
())
{
contact
.
setPhoto
(
picture
);
}
}
else
{
q
Debug
(
)
<<
" photo tag unknown:"
<<
photoTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" photo tag unknown:"
<<
photoTag
;
}
}
}
else
if
(
tag
==
QLatin1String
(
"c:PhysicalAddressCollection"
))
{
...
...
@@ -197,14 +198,14 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
}
else
if
(
addressInfoTag
==
QLatin1String
(
"c:POBox"
))
{
addressType
.
setPostOfficeBox
(
addressInfo
.
text
());
}
else
{
q
Debug
(
)
<<
" address info tag not supported yet "
<<
addressInfoTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" address info tag not supported yet "
<<
addressInfoTag
;
}
}
if
(
!
addressType
.
isEmpty
())
{
contact
.
insertAddress
(
addressType
);
}
}
else
{
q
Debug
(
)
<<
" address tag unknown:"
<<
addressTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" address tag unknown:"
<<
addressTag
;
}
}
}
else
if
(
tag
==
QLatin1String
(
"c:PositionCollection"
))
{
...
...
@@ -224,15 +225,15 @@ KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileNa
}
else
if
(
positionInfoTag
==
QLatin1String
(
"c:Role"
))
{
contact
.
setRole
(
positionInfo
.
text
());
}
else
{
q
Debug
(
)
<<
" position info tag not supported yet "
<<
positionInfoTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" position info tag not supported yet "
<<
positionInfoTag
;
}
}
}
else
{
q
Debug
(
)
<<
" position tag unknown:"
<<
positionTag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
" position tag unknown:"
<<
positionTag
;
}
}
}
else
{
q
Debug
(
)
<<
"unknown tag "
<<
tag
;
q
CWarning
(
IMPORTEXPORTWINDOWSCONTACTPLUGIN_LOG
)
<<
"unknown tag "
<<
tag
;
}
}
lst
<<
contact
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment