|
@@ -5,19 +5,20 @@
|
|
|
# Links
|
|
# Links
|
|
|
# FileFormatdescription: https://docs.fileformat.com/email/vcf/#vcf-30-example
|
|
# FileFormatdescription: https://docs.fileformat.com/email/vcf/#vcf-30-example
|
|
|
# Pytho vobject: http://eventable.github.io/vobject/
|
|
# Pytho vobject: http://eventable.github.io/vobject/
|
|
|
|
|
+
|
|
|
# ChangeLog
|
|
# ChangeLog
|
|
|
|
|
+# 2021-08-03 - multiple E-Mails with different types are working correctly
|
|
|
|
|
|
|
|
import sqlite3
|
|
import sqlite3
|
|
|
import vobject
|
|
import vobject
|
|
|
import uuid
|
|
import uuid
|
|
|
|
|
|
|
|
-SQLconn = sqlite3.connect('../Testdata/system/Contacts/qtcontacts-sqlite/contacts.db')
|
|
|
|
|
|
|
+SQLconn = sqlite3.connect('../Testdata/contacts_with-Phone-Mobile-Fax-Pager-Assistent.db')
|
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
try:
|
|
|
SQLContCur = SQLconn.cursor()
|
|
SQLContCur = SQLconn.cursor()
|
|
|
for row in SQLContCur.execute('SELECT * FROM Contacts'):
|
|
for row in SQLContCur.execute('SELECT * FROM Contacts'):
|
|
|
- print(row[4] + ' ' + row[6])
|
|
|
|
|
|
|
|
|
|
# contactID abfragen
|
|
# contactID abfragen
|
|
|
contactID=row[0]
|
|
contactID=row[0]
|
|
@@ -30,13 +31,16 @@ try:
|
|
|
vcf.add('n').value = vobject.vcard.Name( family=row[6], given=row[4] )
|
|
vcf.add('n').value = vobject.vcard.Name( family=row[6], given=row[4] )
|
|
|
vcf.add('fn').value =row[1]
|
|
vcf.add('fn').value =row[1]
|
|
|
|
|
|
|
|
|
|
+ print("debug: Contact " + row[1])
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
SQLEmailCur = SQLconn.cursor()
|
|
SQLEmailCur = SQLconn.cursor()
|
|
|
|
|
|
|
|
## Abfragen E-Mail-Adressen
|
|
## Abfragen E-Mail-Adressen
|
|
|
for Emailrow in SQLEmailCur.execute('SELECT * from EmailAddresses JOIN Details on Details.detailId= EmailAddresses.detailId where EmailAddresses.contactId = ' + str(contactID)):
|
|
for Emailrow in SQLEmailCur.execute('SELECT * from EmailAddresses JOIN Details on Details.detailId= EmailAddresses.detailId where EmailAddresses.contactId = ' + str(contactID)):
|
|
|
|
|
|
|
|
# debug ausgabe
|
|
# debug ausgabe
|
|
|
- print("debug: " + str(Emailrow[2]) + " at " + str(Emailrow[9]))
|
|
|
|
|
|
|
+ print("...debug: " + str(Emailrow[2]) + " at " + str(Emailrow[9]))
|
|
|
|
|
|
|
|
email = vcf.add('email')
|
|
email = vcf.add('email')
|
|
|
email.value = str(Emailrow[2])
|
|
email.value = str(Emailrow[2])
|
|
@@ -46,7 +50,51 @@ try:
|
|
|
email.type_param = str(Emailrow[9])
|
|
email.type_param = str(Emailrow[9])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ SQLPhoneCur = SQLconn.cursor()
|
|
|
|
|
|
|
|
|
|
+ ## Abfragen Telefonnummer, Fax, SMS - Nummern kommen aus der gleichen Tabelle
|
|
|
|
|
+ for Phonerow in SQLPhoneCur.execute('SELECT * from PhoneNumbers JOIN Details on Details.detailId = PhoneNumbers.detailId where PhoneNumbers.contactId = ' + str(contactID)):
|
|
|
|
|
+
|
|
|
|
|
+ # wir müssen die SubTypen unterscheiden
|
|
|
|
|
+ #Null voice
|
|
|
|
|
+ #1 cell
|
|
|
|
|
+ #2 fax
|
|
|
|
|
+ #3 pager
|
|
|
|
|
+ #6 video
|
|
|
|
|
+ #10 Assistent
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ # debug ausgabe
|
|
|
|
|
+ print("...debug: " + str(Phonerow[2]) + " at " + str(Phonerow[10]) + " subtype=" + str(Phonerow[3]))
|
|
|
|
|
+
|
|
|
|
|
+ # None is a normal phone Number
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if Phonerow[3] == "1":
|
|
|
|
|
+ phcat='cell'
|
|
|
|
|
+ elif Phonerow[3] == "2":
|
|
|
|
|
+ phcat='fax'
|
|
|
|
|
+ elif Phonerow[3] == "3":
|
|
|
|
|
+ phcat='pager'
|
|
|
|
|
+ elif Phonerow[3] == "6":
|
|
|
|
|
+ phcat='video'
|
|
|
|
|
+ elif Phonerow[3] == "10":
|
|
|
|
|
+ phcat='assistent'
|
|
|
|
|
+ elif Phonerow[3] is None:
|
|
|
|
|
+ phcat='voice'
|
|
|
|
|
+
|
|
|
|
|
+ print("...debug: " + phcat)
|
|
|
|
|
+
|
|
|
|
|
+ phone = vcf.add(phcat).value = str(Phonerow[2])
|
|
|
|
|
+
|
|
|
|
|
+ # nur den Typ einpflegen, wenn das hier nicht none ist
|
|
|
|
|
+ if Phonerow[10] != None:
|
|
|
|
|
+ try:
|
|
|
|
|
+ phone.type_param = str(Phonerow[10])
|
|
|
|
|
+ except AttributeError:
|
|
|
|
|
+ continue
|
|
|
|
|
+
|
|
|
|
|
+ # Ausgabe
|
|
|
print(vcf.serialize())
|
|
print(vcf.serialize())
|
|
|
|
|
|
|
|
# hier brauchen wir einige eception handles -> wie bekommen wir die einzelnen exceptions heruas ?
|
|
# hier brauchen wir einige eception handles -> wie bekommen wir die einzelnen exceptions heruas ?
|